[root@node0 host2]# grep mpt /sys/class/scsi_host/host?/proc_name /sys/class/scsi_host/host2/proc_name:mptspi [root@node0 host2]# vi /etc/exports [root@node0 host2]# echo "- - -" > /sys/class/scsi_host/host2/scan [root@node0 host2]# fdisk -l Disk /dev/sda: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 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: 0x00056562 Device Boot Start End Blocks Id System /dev/sda1 * 1 39 307200 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 39 2358 18631680 83 Linux /dev/sda3 2358 2611 2031616 82 Linux swap / Solaris Disk /dev/sdb: 1073 MB, 1073741824 bytes 255 heads, 63 sectors/track, 130 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(3).初始化sdb
[root@node0 host2]# fdisk /dev/sdb Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0x55dbe72b. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). Command (m for help): m Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-130, default 1): Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-130, default 130): Using default value 130 Command (m for help): t Selected partition 1 Hex code (type L to list codes): 8e Changed system type of partition 1 to 8e (Linux LVM) Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
(4).建立lvm
[root@node0 host2]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created
[root@node0 host2]# partprobe
Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy). As a result, it may not reflect all of your changes until after reboot.
[root@node0 host2]# pvdisplay
"/dev/sdb1" is a new physical volume of "1019.72 MiB"
--- NEW Physical volume ---
PV Name /dev/sdb1
VG Name
PV Size 1019.72 MiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID dWj8Zh-V5X8-m9wc-tnnp-txIC-VqQq-jX2aRG
[root@node0 host2]# vgscan
Reading all physical volumes. This may take a while...
No volume groups found
[root@node0 host2]# vgcreate pgdata /dev/sdb1
Volume group "pgdata" successfully created
[root@node0 host2]# vgdisplay
--- Volume group ---
VG Name pgdata
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 1016.00 MiB
PE Size 4.00 MiB
Total PE 254
Alloc PE / Size 0 / 0
Free PE / Size 254 / 1016.00 MiB
VG UUID gYuSRU-nm7P-mnLq-2cC0-CbSG-mAXS-9CzfDS
[root@node0 host2]# lvcreate -L 500M -n lvdata pgdata
Logical volume "lvdata" created
[root@node0 host2]# lvdisplay
--- Logical volume ---
LV Path /dev/pgdata/lvdata
LV Name lvdata
VG Name pgdata
LV UUID tcseQe-JSS8-P280-M46S-pBTN-tGuU-Wkl4Z5
LV Write Access read/write
LV Creation host, time node0, 2015-12-27 06:56:46 -0800
LV Status available
# open 0
LV Size 500.00 MiB
Current LE 125
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
[root@node0 host2]# mkfs -t ext4 /dev/pgdata/lvdata
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
128016 inodes, 512000 blocks
25600 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67633152
63 block groups
8192 blocks per group, 8192 fragments per group
2032 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 23 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
(5).建立本地映射
[root@node0 ha]# pwd /home/ha [root@node0 ha]# mkdir data [root@node0 ha]# mount /dev/pgdata/lvdata data/ [root@node0 ha]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda2 18G 3.7G 13G 22% / tmpfs 491M 224K 491M 1% /dev/shm /dev/sda1 291M 33M 243M 12% /boot /dev/mapper/pgdata-lvdata 485M 11M 449M 3% /home/ha/data
(6).建立远程映射
[root@node0 ha]# rpm -qa | grep nfs nfs-utils-1.2.3-64.el6.x86_64 nfs-utils-lib-devel-1.1.5-11.el6.x86_64 nfs4-acl-tools-0.3.3-7.el6.x86_64 nfs-utils-lib-1.1.5-11.el6.x86_64 [root@node0 ha]# rpm -qa | grep rpcbind rpcbind-0.2.0-11.el6.x86_64 [root@node0 ha]# cat /etc/exports /home/ha/data/ 192.168.238.0/24(rw,no_root_squash,no_all_squash,sync) [root@node0 ha]# /etc/init.d/rpcbind status rpcbind (pid 1802) is running... [root@node0 ha]# /etc/init.d/nfs status rpc.svcgssd is stopped rpc.mountd is stopped nfsd is stopped rpc.rquotad is stopped [root@node0 ha]# /etc/init.d/nfs start Starting NFS services: [ OK ] Starting NFS quotas: [ OK ] Starting NFS mountd: [ OK ] Starting NFS daemon: [ OK ] Starting RPC idmapd: [ OK ] [root@node0 ha]#
[root@localhost ~]# cd /home/ha/ [root@localhost ha]# mkdir data [root@localhost ha]# mount -t nfs 192.168.238.129:/home/ha/data/ data/ [root@localhost ha]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda2 18G 3.5G 14G 21% / tmpfs 491M 232K 491M 1% /dev/shm /dev/sda1 291M 33M 243M 12% /boot 192.168.238.129:/home/ha/data/ 485M 11M 449M 3% /home/ha/data [root@localhost ha]#
(7).添加一个2G硬盘后初始化,同(3)。
(8).扩容
[root@node0 ha]# pvcreate /dev/sdc1 Physical volume "/dev/sdc1" successfully created [root@node0 ha]# pvdisplay --- Physical volume --- PV Name /dev/sdb1 VG Name pgdata PV Size 1019.72 MiB / not usable 3.72 MiB Allocatable yes PE Size 4.00 MiB Total PE 254 Free PE 129 Allocated PE 125 PV UUID dWj8Zh-V5X8-m9wc-tnnp-txIC-VqQq-jX2aRG "/dev/sdc1" is a new physical volume of "2.00 GiB" --- NEW Physical volume --- PV Name /dev/sdc1 VG Name PV Size 2.00 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID WCO5zU-ExbX-1thO-E1to-N9tJ-Hpmu-kytdTQ [root@node0 ha]# vgdisplay --- Volume group --- VG Name pgdata System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 2 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 1 Max PV 0 Cur PV 1 Act PV 1 VG Size 1016.00 MiB PE Size 4.00 MiB Total PE 254 Alloc PE / Size 125 / 500.00 MiB Free PE / Size 129 / 516.00 MiB VG UUID gYuSRU-nm7P-mnLq-2cC0-CbSG-mAXS-9CzfDS [root@node0 ha]# vgextend pgdata /dev/sdc1 Volume group "pgdata" successfully extended [root@node0 ha]# vgdisplay --- Volume group --- VG Name pgdata System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 3 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 1 Max PV 0 Cur PV 2 Act PV 2 VG Size 2.99 GiB PE Size 4.00 MiB Total PE 765 Alloc PE / Size 125 / 500.00 MiB Free PE / Size 640 / 2.50 GiB VG UUID gYuSRU-nm7P-mnLq-2cC0-CbSG-mAXS-9CzfDS [root@node0 ha]# lvdisplay --- Logical volume --- LV Path /dev/pgdata/lvdata LV Name lvdata VG Name pgdata LV UUID tcseQe-JSS8-P280-M46S-pBTN-tGuU-Wkl4Z5 LV Write Access read/write LV Creation host, time node0, 2015-12-27 06:56:46 -0800 LV Status available # open 1 LV Size 500.00 MiB Current LE 125 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0 [root@node0 ha]# lvextend -L 2.2G /dev/pgdata/lvdata Rounding size to boundary between physical extents: 2.20 GiB Extending logical volume lvdata to 2.20 GiB Logical volume lvdata successfully resized [root@node0 ha]# resize2fs /dev/pgdata/lvdata resize2fs 1.41.12 (17-May-2010) Filesystem at /dev/pgdata/lvdata is mounted on /home/ha/data; on-line resizing required old desc_blocks = 2, new_desc_blocks = 9 Performing an on-line resize of /dev/pgdata/lvdata to 2310144 (1k) blocks. The filesystem on /dev/pgdata/lvdata is now 2310144 blocks long. [root@node0 ha]#
(9).验证
[root@node0 ha]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda2 18G 3.7G 13G 22% / tmpfs 491M 224K 491M 1% /dev/shm /dev/sda1 291M 33M 243M 12% /boot /dev/mapper/pgdata-lvdata 2.2G 11M 2.1G 1% /home/ha/data [root@node0 ha]#