一、创建LV
1.新建磁盘分区及物理pv
[root@rac1 nfsvg]# fdisk /dev/sdg
n
p
t
8e #此格式为Linux系统LVM专用格式
w
[root@rac1 nfsvg]# pvcreate /dev/sda{9,1 0,11 }
Physical volume “/dev/sda9 “successfully created
Physical volume “/dev/sda10 “successfully created
Physical volume “/dev/sdai1 “successfully created
2.创建逻辑卷组
[root@rac1 nfsvg]# vgcreate nfsvg /dev/sda{9,1 0}
Volumegroup “nfsvg “successfully created
注:批量跨盘多分区建卷组
[root@rac1 nfsvg]#vgcreate nfsvg /dev/sdg1 /dev/sdh1
3.创建逻辑卷
[root@rac1 etc]# lvcreate -L 5120M -n lvshareplex nfsvg
Logical volume “lvshareplex” created
4.格式化
[root@rac1 nfsvg]# mkfs.ext3 /dev/nfsvg/lvshareplex
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
655360 inodes, 1310720 blocks
65536 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1342177280
40 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 21 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
5.挂载
[root@rac1 nfsvg]# mkdir /shareplex
[root@rac1 nfsvg]# mount /dev/nfsvg/lvshareplex /shareplex/
6.查看卷组信息
[root@rac1 /]# vgdisplay nfsvg
— Volume group —
VG Name nfsvg
System ID
Format lvm2
Metadata Areas 2
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 2
Act PV 2
VG Size 19.99 GB
PE Size 4.00 MB
Total PE 5118
Alloc PE / Size 1280 / 5.00 GB
Free PE / Size 3838 / 14.99 GB
VG UUID 3FaCdX-3agJ-xRpb-nUjR-UMv3-q33U-Cf0a35二、扩展逻辑卷、卷组
1.给逻辑卷增加容量
[root@rac1 /]# lvextend -L +5120M /dev/nfsvg/lvshareplex
Extending logical volume lvshareplex to 10.00 GB
Logical volume lvshareplex successfully resized
2.刷新文件系统容量,刷新容量会对读写操作产生影响,因为需要重建inode和block
[root@rac1 /]# resize2fs /dev/nfsvg/lvshareplex
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/nfsvg/lvshareplex is mounted on /shareplex; on-line resizing required
Performing an on-line resize of /dev/nfsvg/lvshareplex to 2621440 (4k) blocks.
The filesystem on /dev/nfsvg/lvshareplex is now 2621440 blocks long.
3.扩展逻辑卷
[root@rac1 /]# vgextend nfsvg /dev/sdi1
Volume group “nfsvg” successfully extended
三、移动卷
1.迁移数据(使用上面加入nfsvg中的新PV sdi1)
[root@rac1 /]# pvmove /dev/sdh1 /dev/sdi1
/dev/sdh1:Moved:100.0%
2.数据已从/dev/sdh1移至/dev/sdi1中,现在可卸载/dev/sdh1
[root@rac1 /]# vgreduce nfsvg /dev/sdh1
Removed “/dev/sdh1” from volumegroup “nfsvg”
3.删除物理卷
[root@rac1 /]# pvremove /dev/sdh1
Labels on physical volume “/dev/sdh1” successfully wiped
《结束》