顯示具有 linux 標籤的文章。 顯示所有文章
顯示具有 linux 標籤的文章。 顯示所有文章

2017年9月22日 星期五

SSH no matching host key type found. Their offer: ssh-dss , DH GEX group out of range

ssh -o HostKeyAlgorithms=ssh-dss -o KexAlgorithms=diffie-hellman-group1-sha1

ssh -v -o HostKeyAlgorithms=ssh-dss -o KexAlgorithms=diffie-hellman-group1-sha1

加 -v 可以看看中間在做什麼

http://www.itdadao.com/articles/c15a1454203p0.html
ssh在7.2版本时,有一个security增强,将minimum modulus size提高到了2048;我当时连的设备好像是1024,所以这是导致问题的因素。
很多网络设备,路由器资源接入的时候,由于秘钥长度不匹配或者ssh和ssl版本问题导致不能选择DH GEX group,因此不能选择modulus sizes。


Linux 在 FileSystem 下控制目錄大小



dd if=/dev/zero of=/userdisk.fs bs=1024 count= 100000,
 mkfs.ext3 /userdisk.fs, 
mount -t ext3 -o loop /userdisk.fs /home/user



1GB 的 BS 大約是  1073741824




2017年1月20日 星期五

linux mpio



編輯 /etc/multipath.conf
把 blacklist {} 區段註解掉
然後把 default{} 區段打開

chkconfig multipathd on
service multipathd start

然後 fdisk -l 會看到多出 dm-n 的硬碟 但 dm-n 不能直接掛來用
要用 /dev/mapper/mpathNpN
詳細資料待查

引用

#vi /etc/multipath.conf
然後可以看到檔案裡面有這些東西
blacklist {
        devnode "*"
}

把這幾行mark掉吧
另外可以看到有一些本來被mark掉的
#defaults {
#       udev_dir                /dev
#       polling_interval        10
#       selector                "round-robin 0"
#       path_grouping_policy    multibus
#       getuid_callout          "/sbin/scsi_id -g -u -s /block/%n"
#       prio_callout            /bin/true
#       path_checker            readsector0
#       rr_min_io               100
#       max_fds                 8192
#       rr_weight               priorities
#       failback                immediate
#       no_path_retry           fail
#       user_friendly_names     yes
#}
這裡是設定一些multipath參數的地方
設定好就拿掉mark吧,如果不會設定的話直接拿掉mark也是可以的
存檔後就可以開啟service了
#chkconfig multipathd on
#service multipathd start
在啟動之前可以看到我硬碟是這樣
Disk /dev/sdb: 997.9 GB, 997999509504 bytes
255 heads, 63 sectors/track, 121333 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1        1306    10490413+  83  Linux
/dev/sdb2            1307        2612    10490445   83  Linux


Disk /dev/sdc: 997.9 GB, 997999509504 bytes
255 heads, 63 sectors/track, 121333 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *           1        1306    10490413+  83  Linux
/dev/sdc2            1307        2612    10490445   83  Linux

啟動之後可以看到多出幾個device
Disk /dev/dm-0: 997.9 GB, 997999509504 bytes
255 heads, 63 sectors/track, 121333 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

     Device Boot      Start         End      Blocks   Id  System
/dev/dm-0p1   *           1        1306    10490413+  83  Linux
/dev/dm-0p2            1307        2612    10490445   83  Linux

Disk /dev/dm-1: 10.7 GB, 10742183424 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/dm-1 doesn't contain a valid partition table

Disk /dev/dm-2: 10.7 GB, 10742215680 bytes
255 heads, 63 sectors/track, 1306 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/dm-2 doesn't contain a valid partition table

其中dm-0是sdb和sdc的合體,但是因為sdb和sdc有兩個partition,
所以multipath也順便把這兩個合成dm-1和dm-2,
這時候會發現在device下面找不到dm-0p1和dm-0p2可以用,
因為他放到/dev/mapper裡面去了,在裡面可以看到mpath1p1和mpath1p2分別就是兩個partition
如果要更改設定的話除了在multipath.conf裡面更改再重新啟動之外
也可以用multipath指令即時更新,另外"multipath -ll"也可以看到目前path的組成以及狀況





參考

http://tnth.pixnet.net/blog/post/26222957-linux%E4%B8%8A%E7%9A%84mpio

https://access.redhat.com/documentation/zh-TW/Red_Hat_Enterprise_Linux/6/html/DM_Multipath/mpio_setup.html

2016年6月14日 星期二

linux remove disk



http://www.redhatgeek.com/linux/remove-a-disk-from-redhatcentos-linux-without-rebooting-the-system

先 umount 停止IO
echo "offline" > /sys/block/sdc/device/state

echo "1" > /sys/block/sdc/device/delete







=======END=========

2016年6月2日 星期四

Squid3 ubuntu



Squid3 安裝


http://www.ez2o.com/Blog/Post/Ubuntu-Install-Proxy-Server-Squid


apt-get install squid

vi /etc/squid3/squid.conf

設定允許所有人連入 Proxy :

將 http_access allow localhost  改為 http_access allow all

將 http_access deny all 註解

/etc/init.d/squid restart

在 Wget 使用 proxy


Via ~/.wgetrc file:
use_proxy=yes http_proxy=127.0.0.1:8080
or
via -e options placed after the URL:
wget ... -e use_proxy=yes -e http_proxy=127.0.0.1:8080 ...

用 ftp proxy 的時候 用 -e ftp_proxy=127.0.0.1:8080


在 yum 使用 proxy



$ export http_proxy=http://proxy:3128
$ export ftp_proxy=http://proxy:3128
$ yum update
If you want to make the proxy settings permanent, you can add a proxy directive to /etc/yum.conf:
$ grep proxy /etc/yum.conf
proxy=http://proxy:3128











=END

Linux Mint / Ubuntu Natty apt update






Medibuntu has now been shut down


source.list 要抓掉
http://askubuntu.com/questions/356794/the-medibuntu-project-has-come-to-an-end-what-do-i-do-now


aptitude purge medibuntu-keyring rm -f /etc/apt/sources.list.d/medibuntu.list aptitude update
aptitude purge $(dpkg-query -W -f='${PackageSpec}\t${Maintainer}\n' '*' |\ grep medibuntu-maintainers@lists.launchpad.net |\ cut -f1)




archive.ubuntu.com 跟 security.ubuntu.com 換成 old-releases.ubuntu.com


 perl -p -i.bak -e 's/security.ubuntu.com|archive.ubuntu.com/old-releases.ubuntu.com/g' sources.list


Header 錯誤


E: Encountered a section with no Package: header 
E: Problem with MergeList /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_natty_main_binary-i386_Packages 
E: The package lists or status file could not be parsed or opened.

sudo rm -vf /var/lib/apt/lists/* 

Next, generate a new one by running a simple update:
sudo apt-get update





2016年5月30日 星期一

Linux add new HD

http://linoxide.com/file-system/create-mount-extend-xfs-filesystem/


先在 VC 完成配置 掛載給 guest

然後到

[root@db3 ~]# fdisk -l

Disk /dev/sdb: 17482.2 GB, 17482234881024 bytes
255 heads, 63 sectors/track, 2125427 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/sda: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0009d767

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        7833    62401536   8e  Linux LVM

Disk /dev/sdc: 171.8 GB, 171798691840 bytes
255 heads, 63 sectors/track, 20886 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/vg_db3-lv_root: 27.4 GB, 27376222208 bytes
255 heads, 63 sectors/track, 3328 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/vg_db3-lv_swap: 33.8 GB, 33848033280 bytes
255 heads, 63 sectors/track, 4115 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/vg_db3-lv_home: 2671 MB, 2671771648 bytes
255 heads, 63 sectors/track, 324 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

[root@db3 ~]# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/mapper/vg_db3-lv_root
                      26315036  10435876  14542432  42% /
tmpfs                 33050200       232  33049968   1% /dev/shm
/dev/sda1               495844     38022    432222   9% /boot
/dev/mapper/vg_db3-lv_home
                       2568144     70116   2367572   3% /home
/dev/sdc             167690240 136033260  31656980  82% /hissp1/temp
/dev/sdb             17070408088 12905911056 4164497032  76% /hissp1/oradbf
f6n1:/exp            21441282048 9812445888 11628836160  46% /exp
[root@db3 ~]# cd /proc/scsi/sg
[root@db3 sg]# cat device_hdr devices
host    chan    id      lun     type    opens   qdepth  busy    online
1       0       0       0       5       1       1       0       1
2       0       0       0       0       1       32      0       1
2       0       1       0       0       1       32      0       1
2       0       2       0       0       1       32      0       1
[root@db3 sg]# echo "- - -" > /sys/class/scsi_host/host2/scan
[root@db3 sg]# cat device_hdr devices
host    chan    id      lun     type    opens   qdepth  busy    online
1       0       0       0       5       1       1       0       1
2       0       0       0       0       1       32      0       1
2       0       1       0       0       1       32      0       1
2       0       2       0       0       1       32      0       1
2       0       3       0       0       1       32      0       1
[root@db3 sg]# fdisk -l

Disk /dev/sdb: 17482.2 GB, 17482234881024 bytes
255 heads, 63 sectors/track, 2125427 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/sda: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0009d767

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        7833    62401536   8e  Linux LVM

Disk /dev/sdc: 171.8 GB, 171798691840 bytes
255 heads, 63 sectors/track, 20886 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/vg_db3-lv_root: 27.4 GB, 27376222208 bytes
255 heads, 63 sectors/track, 3328 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/vg_db3-lv_swap: 33.8 GB, 33848033280 bytes
255 heads, 63 sectors/track, 4115 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/vg_db3-lv_home: 2671 MB, 2671771648 bytes
255 heads, 63 sectors/track, 324 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/sdd: 10885.2 GB, 10885165114368 bytes
255 heads, 63 sectors/track, 1323379 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

[root@db3 sg]#

[root@db3 /]# mkfs.xfs /dev/sdd
mkfs.xfs: /dev/sdd appears to contain an existing filesystem (LVM2_member).
mkfs.xfs: Use the -f option to force overwrite.
[root@db3 /]# mkfs.xfs -f /dev/sdd
meta-data=/dev/sdd               isize=256    agcount=10, agsize=268435455 blks
         =                       sectsz=512   attr=2, projid32bit=0
data     =                       bsize=4096   blocks=2657511014, imaxpct=5
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0
log      =internal log           bsize=4096   blocks=521728, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[root@db3 /]# mount /dev/sdd /hissp1exp
[root@db3 /]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_db3-lv_root
                       26G   10G   14G  42% /
tmpfs                  32G  232K   32G   1% /dev/shm
/dev/sda1             485M   38M  423M   9% /boot
/dev/mapper/vg_db3-lv_home
                      2.5G   69M  2.3G   3% /home
/dev/sdc              160G  130G   31G  82% /hissp1/temp
/dev/sdb               16T   13T  3.9T  76% /hissp1/oradbf
f6n1:/exp              20T  9.2T   11T  46% /exp
/dev/sdd              9.9T   33M  9.9T   1% /hissp1exp
[root@db3 /]# 


2015年10月1日 星期四

CentOS 6 udev 改 NIC 名稱

see http://www.ichiayi.com/wiki/tech/udev

/etc/udev/rules.d/70-presistent-net.rules
會記錄 MAC ADDRESS 與 eth* 的對應

在 VM Template 可以
移掉 
 /etc/sysconfig/network-scripts/ifcfg-eth0 內的 UUID 以及 HWADDR
刪除 /etc/udev/rules.d/70-persistent-net.rules 這個檔案


臨時使用

ifconfig eth0 192.168.1.x netmask 255.255.255.0
ifconfig eth0 up
route add default gw 192.168.1.254

2015年6月25日 星期四

linux mail 加附檔

用 mutt

mutt -e 'my_hdr from:bbb<bbb@bbb.com>' -s "標題" -a 附檔  收件人  < 信件內容

2015年1月30日 星期五

linux extend filesystem

[root@ms2 ~]# fdisk -l

Disk /dev/sda: 290.9 GB, 290984034304 bytes
255 heads, 63 sectors/track, 35376 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14       35376   284053297+  8e  Linux LVM

Disk /dev/sdb: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/sdc: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdc doesn't contain a valid partition table

Disk /dev/sdd: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdd doesn't contain a valid partition table

Disk /dev/sde: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sde doesn't contain a valid partition table

Disk /dev/sdf: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdf doesn't contain a valid partition table

Disk /dev/sdg: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdg doesn't contain a valid partition table


[root@ms2 ~]#  cd /proc/scsi/sg
[root@ms2 sg]# cat device_hdr devices
host    chan    id      lun     type    opens   qdepth  busy    online
0       2       0       0       0       1       128     0       1
5       0       0       0       0       1       254     0       1
5       0       0       1       0       1       254     0       1
5       0       0       2       0       1       254     1       1
5       0       0       3       0       1       254     0       1
5       0       0       4       0       1       254     0       1
5       0       0       5       0       1       254     0       1
[root@ms2 sg]# echo "- - -" > /sys/class/scsi_host/host5/scan
[root@ms2 sg]# cat device_hdr devices
host    chan    id      lun     type    opens   qdepth  busy    online
0       2       0       0       0       1       128     0       1
5       0       0       0       0       1       254     1       1
5       0       0       1       0       1       254     0       1
5       0       0       2       0       1       254     0       1
5       0       0       3       0       1       254     0       1
5       0       0       4       0       1       254     0       1
5       0       0       5       0       1       254     0       1
5       0       0       6       0       1       254     0       1
5       0       0       7       0       1       254     0       1
5       0       0       8       0       1       254     0       1
[root@ms2 sg]#
[root@ms2 sg]#  fdisk -l

Disk /dev/sda: 290.9 GB, 290984034304 bytes
255 heads, 63 sectors/track, 35376 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14       35376   284053297+  8e  Linux LVM

Disk /dev/sdb: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/sdc: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdc doesn't contain a valid partition table

Disk /dev/sdd: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdd doesn't contain a valid partition table

Disk /dev/sde: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sde doesn't contain a valid partition table

Disk /dev/sdf: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdf doesn't contain a valid partition table

Disk /dev/sdg: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdg doesn't contain a valid partition table

Disk /dev/sdh: 1099.5 GB, 1099511627776 bytes
255 heads, 63 sectors/track, 133674 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdh doesn't contain a valid partition table

Disk /dev/sdi: 1099.5 GB, 1099511627776 bytes
255 heads, 63 sectors/track, 133674 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdi doesn't contain a valid partition table

Disk /dev/sdj: 1099.5 GB, 1099511627776 bytes
255 heads, 63 sectors/track, 133674 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdj doesn't contain a valid partition table
原本只有到 sdg 現在多了 h i j 三個 1TB 的 disk

[root@ms2 sg]# pvcreate /dev/sdh
  Physical volume "/dev/sdh" successfully created
[root@ms2 sg]# pvcreate /dev/sdi
  Physical volume "/dev/sdi" successfully created
[root@ms2 sg]# pvcreate /dev/sdj
  Physical volume "/dev/sdj" successfully created
[root@ms2 sg]#
[root@ms2 sg]# pvscan
  PV /dev/sdb    VG mboxvg          lvm2 [500.00 GB / 0    free]
  PV /dev/sdc    VG mboxvg          lvm2 [500.00 GB / 0    free]
  PV /dev/sdd    VG mboxvg          lvm2 [500.00 GB / 0    free]
  PV /dev/sde    VG mboxvg          lvm2 [500.00 GB / 0    free]
  PV /dev/sdf    VG mboxvg          lvm2 [500.00 GB / 0    free]
  PV /dev/sdg    VG mboxvg          lvm2 [500.00 GB / 109.98 GB free]
  PV /dev/sda2   VG VolGroup00      lvm2 [270.88 GB / 110.72 GB free]
  PV /dev/sdh                       lvm2 [1.00 TB]
  PV /dev/sdi                       lvm2 [1.00 TB]
  PV /dev/sdj                       lvm2 [1.00 TB]
  Total: 10 [6.19 TB] / in use: 7 [3.19 TB] / in no VG: 3 [3.00 TB]
[root@ms2 sg]#
[root@ms2 sg]# vgextend mboxvg /dev/sdh
  Volume group "mboxvg" successfully extended
[root@ms2 sg]# vgextend mboxvg /dev/sdi
  Volume group "mboxvg" successfully extended
[root@ms2 sg]# vgextend mboxvg /dev/sdj
  Volume group "mboxvg" successfully extended
[root@ms2 sg]# pvscan
  PV /dev/sdb    VG mboxvg       lvm2 [500.00 GB / 0    free]
  PV /dev/sdc    VG mboxvg       lvm2 [500.00 GB / 0    free]
  PV /dev/sdd    VG mboxvg       lvm2 [500.00 GB / 0    free]
  PV /dev/sde    VG mboxvg       lvm2 [500.00 GB / 0    free]
  PV /dev/sdf    VG mboxvg       lvm2 [500.00 GB / 0    free]
  PV /dev/sdg    VG mboxvg       lvm2 [500.00 GB / 109.98 GB free]
  PV /dev/sdh    VG mboxvg       lvm2 [1024.00 GB / 1024.00 GB free]
  PV /dev/sdi    VG mboxvg       lvm2 [1024.00 GB / 1024.00 GB free]
  PV /dev/sdj    VG mboxvg       lvm2 [1024.00 GB / 1024.00 GB free]
  PV /dev/sda2   VG VolGroup00   lvm2 [270.88 GB / 110.72 GB free]
  Total: 10 [6.19 TB] / in use: 10 [6.19 TB] / in no VG: 0 [0   ]
[root@ms2 sg]#
[root@ms2 sg]# vgdisplay
  --- Volume group ---
  VG Name               mboxvg
  System ID
  Format                lvm2
  Metadata Areas        9
  Metadata Sequence No  17
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                9
  Act PV                9
  VG Size               5.93 TB
  PE Size               4.00 MB
  Total PE              1554423
  Alloc PE / Size       739840 / 2.82 TB
  Free  PE / Size       814583 / 3.11 TB
  VG UUID               Xtfhe3-APFS-MFzs-wZq0-QNeE-aqEo-1CK1YV

  --- Volume group ---
  VG Name               VolGroup00
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  5
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                4
  Open LV               4
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               270.88 GB
  PE Size               32.00 MB
  Total PE              8668
  Alloc PE / Size       5125 / 160.16 GB
  Free  PE / Size       3543 / 110.72 GB
  VG UUID               LOAoah-0vIN-pWRq-sLkP-A9mG-zypc-uyLcGa

[root@ms2 sg]#
[root@ms2 sg]# lvdisplay

  --- Logical volume ---
  LV Name                /dev/mboxvg/mbox01
  VG Name                mboxvg
  LV UUID                G15z3j-lomU-encc-LQnS-BNq3-3zyl-qzhiqJ
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                2.82 TB
  Current LE             739840
  Segments               6
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:4


[root@ms2 sg]#
[root@ms2 sg]# lvresize -l +100%FREE /dev/mboxvg/mbox01
  Extending logical volume mbox01 to 5.93 TB
  Logical volume mbox01 successfully resized
[root@ms2 sg]# lvdisplay
  --- Logical volume ---
  LV Name                /dev/mboxvg/mbox01
  VG Name                mboxvg
  LV UUID                G15z3j-lomU-encc-LQnS-BNq3-3zyl-qzhiqJ
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                5.93 TB
  Current LE             1554423
  Segments               9
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:4

  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
  LV UUID                iYqCos-T3g8-Sf00-5GTb-UkQQ-fTeD-qTge70
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                39.06 GB
  Current LE             1250
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol03
  VG Name                VolGroup00
  LV UUID                fTrr9M-46ZG-Hi2X-18wf-jkCm-CpYk-OXGtXx
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                39.06 GB
  Current LE             1250
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol02
  VG Name                VolGroup00
  LV UUID                XlBlhu-inCm-6vsL-OsGw-zuuA-UBUZ-fr1qIj
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                78.12 GB
  Current LE             2500
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2

  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol01
  VG Name                VolGroup00
  LV UUID                6edOs6-pyle-Bbn3-4FQT-UCyW-Ud5q-LcSWHS
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                3.91 GB
  Current LE             125
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:3

[root@ms2 sg]#
[root@ms2 sg]# resize2fs /dev/mapper/mboxvg-mbox01
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/mapper/mboxvg-mbox01 is mounted on /home01; on-line resizing required
Performing an on-line resize of /dev/mapper/mboxvg-mbox01 to 1591729152 (4k) blocks.
The filesystem on /dev/mapper/mboxvg-mbox01 is now 1591729152 blocks long.
[root@ms2 sg]# df -g
df: invalid option -- g
Try `df --help' for more information.
[root@ms2 sg]# df -g
df: invalid option -- g
Try `df --help' for more information.
[root@ms2 sg]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       38G  9.5G   27G  27% /
/dev/mapper/VolGroup00-LogVol03
                       38G  177M   36G   1% /tmp
/dev/mapper/VolGroup00-LogVol02
                       76G  9.6G   63G  14% /var
/dev/sda1              99M   19M   76M  20% /boot
tmpfs                 2.0G     0  2.0G   0% /dev/shm
/dev/mapper/mboxvg-mbox01
                      5.9T  1.7T  3.9T  31% /home01
[root@ms2 sg]#

REF:
http://linux.vbird.org/linux_basic/0420quota.php#lvm_whatis

http://linux.vbird.org/linux_basic/0230filesystem.php#fdisk

http://www.thegeekstuff.com/2011/04/identify-file-system-type/

http://linternux.com/2009/06/adding-san-disk/

http://www.milliondollarserver.com/add-new-hard-drive-in-centosrheloel-without-reboot/

http://setaoffice.com/2010/03/28/resizing-an-ext3-filesystem-mounted-on-a-logical-volume-in-a-linux/


2013年5月29日 星期三

ubuntu mount cifs 出現 mount error(13): Permission denied

 mount -t cifs -o sec=lanman -o ip=10.0.2.2,workgroup=WORKGROUP,guest,rw //10.0.2.2/Internal /private 

加入紅字部分

原因不明
https://bugs.launchpad.net/ubuntu/+source/cifs-utils/+bug/1113395

2013年1月16日 星期三

CENTOS 6 , Tomcat 7 使用 service 啟動

ln -s /tomcat7/bin/catalina.sh /etc/init.d/tomcat

然後在 catalina.sh 加上


# chkconfig: 2345 10 90
# description:Tomcat service

chkconfig --add tomcat

2012年12月5日 星期三

SELinux


getenforce

[SAMBA]
setsebool -P samba_export_all_ro on 
setsebool -P samba_export_all_ro on 

2012年9月7日 星期五

Linux iptables

列出所有 rule

iptables -L -n

iptables-save


刪除某條規則
......
-A INPUT -j ACCEPT
......
可以
iptables -D INPUT -j ACCEPT

存檔
/etc/init.d/iptables save

see /etc/sysconfig/iptables

2012年9月6日 星期四

CENTOS minimal NFS

預設沒有

yum -y install nfs-utils nfs-utils-lib

自己安裝

然後要記得開 rpcbind 

# /etc/init.d/rpcbind start設定開機時啟動
# chkconfig --level 3 rpcbind on

使用 logrotate 處理 log rotate

使用 yum 安裝 logrotate

設定檔在 /etc/logrotate.conf ,
 不同的設定檔放在 /etc/logrotate.d/ tomcat

原廠推荐的三種處理 catalina.out 的方式之一
 (不過log.properties 裡面已經設定 daily rotate了)

* tomcat 要用  copytruncate 的方式


daily 每天整理,其他還有 weekly, monthly, yearly
missingok 允許 log 檔不存在
nomissingok 不允許 log 檔不存在,會丟出錯誤 (預設)
rotate 7 保留 7 次的分割
size 1M 大小超過 1M 就執行分割,單位可以是 1024, 100k, 4M, 1G
dateext 用日期來建立分割檔名,而非流水號
dateformat -%Y%m%d 日期格式
compress 壓縮分割,預設用 gzip (預設)
nocompress 不壓縮分割
delaycompress 延後壓縮直到下一次 rotate
notifempty 如果 log 是空的就不執行
copytruncate 以[複製清空]的方式分割 log,這樣可以用不到 postrotate 設定
mail xxx@address 將分割內容用 mail 寄出
prerotate/endscript 分割前要執行的指令
postrotate/endscript 分割後要執行的指令 


Ref
http://jax-work-archive.blogspot.tw/2012/09/ubuntu-logrotate-apache-log.html
http://blog.jsdan.com/3616

2012年4月24日 星期二

Linux (Redhat / Fedora / CentOS) 更改 hostname 的方式

* 改 /etc/hosts
* 改 /ets/sysconfig/network
* 用 hostname ${NewName} 再改一次

2012年4月19日 星期四

CentOS 6 ,SSH 使用 Public Key 登入

ssh-keygen -t dsa
產生  DSA key pair

id_dsa  ( Private Key )
id_dsa.pub  ( Public Key )

cd ~/.ssh
cat id_dsa.pub > authorized_keys
cat id_dsa.pub > authorized_keys2

** .ssh 本身的權限

chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys2

** 有 SELinux 的話
/sbin/restorecon -R -v /home/$ACCOUNT/.ssh

參見

下載  Private Key

-- XShell
import 進 Key Manager

-- Putty
使用 PUTTYGEN.EXE 匯入
再轉成 Putty 的格式

import -> private key
save private key -> 存成 Putty 能用的 ppk 格式
然後在 putty 中指定 ppk 位置


--------------
需要把 key 送去別台 server

ssh-copy-id -i ~/.ssh/id_dsa.pub USER@HOST

*這個 script 的方向是 送出去 而不是 拉過來
*預設是用 RSA Key . 所以 DSA Key 要自己用 -i 指定 key 位置
*預設走 port 22 , 如果有改 port 要改寫 Script
*CentOS 6 以後有這個指令可以用
---------------




2012年3月28日 星期三

Linux 下清除 GPT

如何清除GPT標簽

--------------------------------
可以用 CENTOS 5.4 的 BOOT CD  進入 RESCUE MODE 然後就有 DD  跟 FDISK 可以用
--------------------------------
1) 看到GPT很不爽

# fdisk -l /dev/sdc

WARNING: GPT (GUID Partition Table) detected on '/dev/sdc'! The util fdisk doesn't support GPT. Use GNU Parted.


Disk /dev/sdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdc doesn't contain a valid partition table

2)先把前兩個sectors洗掉

# dd if=/dev/zero of=/dev/sdc bs=512 count=2; sync
2+0 records in
2+0 records out
1024 bytes (1.0 kB) copied, 0.00061 seconds, 1.7 MB/s

3)GPT標簽還在

# fdisk -l /dev/sdc

WARNING: GPT (GUID Partition Table) detected on '/dev/sdc'! The util fdisk doesn't support GPT. Use GNU Parted.


Disk /dev/sdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdc doesn't contain a valid partition table

4)再把后兩個sectors也洗掉 (500107862016 / 512 - 2 = 976773166)

# dd if=/dev/zero of=/dev/sdc bs=512 seek=976773166 count=2; sync
2+0 records in
2+0 records out
1024 bytes (1.0 kB) copied, 0.000616 seconds, 1.7 MB/s

5)完成。

# fdisk -l /dev/sdc

Disk /dev/sdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdc doesn't contain a valid partition table


------------
another way

parted /dev/sd*

mklabel msdos

quit

2012年3月21日 星期三

CENTOS 6 Samba

 yum -y install samba samba-client samba-common

/etc/samba/smb.conf


[global]
        # 與主機名稱有關的設定資訊
        workgroup     = workgroup
        netbios name  = wasap12
        server string = wasap12

        # 與語系方面有關的設定項目喔,為何如此設定請參考前面的說明
        unix charset    = utf8
        display charset = utf8
        dos charset     = cp950

        # 與登錄檔有關的設定項目,注意變數 (%m)
        log file = /var/log/samba/log.%m
        max log size = 50

        # 這裡才是與密碼有關的設定項目哩!
        security = share

        # 修改一下印表機的載入方式,不要載入啦!
        load printers = no
        hosts allow = 172.22.93., 172.22.94.

# 2. 分享的資源設定方面:主要得將舊的註解,新的加入!
#    先取消 [homes], [printers] 的項目,然後針對 /tmp 的設定,可瀏覽且可寫入喔
[ADMISSION]                                  
#分享資源名稱
        comment    = ADMISSION_LOG
#簡單的解釋此資源
        path       = /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/logs/admission_server/              
#實際 Linux 分享的目錄
        writable   = no                
#是否可寫入?在此例為是的
        browseable = yes                
#能不能被瀏覽到資源名稱
        guest ok   = yes                
#單純分享時,讓用戶隨意登入的設定


#################################################################


#!/bin/sh
chkconfig smb on
chkconfig nmb on
/etc/rc.d/init.d/smb restart
/etc/rc.d/init.d/nmb restart


##################################################################
原版的 smb.conf 有寫怎樣調整 SELinux

setsebool -P samba_domain_controller on
setsebool -P samba_enable_home_dirs on

setsebool -P samba_export_all_rw on
setsebool -P samba_export_all_rw ro