创建物理卷 [root@***client ~]# pvcreate /dev/sdb1 Physical volume "/dev/sdb1" successfully created [root@***client ~]# pvcreate /dev/sdc1 Physical volume "/dev/sdc1" successfully created [root@***client ~]# 创建卷组 [root@***client ~]# vgcreate lvmdisk /dev/sdb1 /dev/sdc1 Volume group "lvmdisk" successfully created [root@***client ~]# 查看创建的信息 [root@***client ~]# pvdisplay --- Physical volume --- PV Name /dev/sdb1 VG Name lvmdisk PV Size 5.01 GiB / not usable 2.10 MiB Allocatable yes PE Size 4.00 MiB Total PE 1282 Free PE 1282 Allocated PE 0 PV UUID fguwZS-C82R-at0C-oMjR-yeoo-FCAx-XqHs4n --- Physical volume --- PV Name /dev/sdc1 VG Name lvmdisk PV Size 10.00 GiB / not usable 4.54 MiB Allocatable yes PE Size 4.00 MiB Total PE 2560 Free PE 2560 Allocated PE 0 PV UUID PNLzcH-JvyU-BQa3-2I6U-as35-r4QJ-c2G7pd [root@***client ~]# vgdisplay --- Volume group --- VG Name lvmdisk System ID Format lvm2 Metadata Areas 2 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 2 Act PV 2 VG Size 15.01 GiB PE Size 4.00 MiB Total PE 3842 Alloc PE / Size 0 / 0 Free PE / Size 3842 / 15.01 GiB VG UUID daYbkb-BN42-dgdp-lCYD-sQAD-kPwv-657HPr [root@***client ~]# 创建逻辑卷 [root@***client ~]# lvcreate -L 12G -n mysqldata lvmdisk mkfs.ext4 /dev/lvmdisk/mysqldata [root@***client ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda2 30G 2.2G 26G 8% / tmpfs 491M 0 491M 0% /dev/shm /dev/sda1 190M 40M 141M 23% /boot /dev/mapper/lvmdisk-mysqldata 12G 30M 12G 1% /mnt/mysqldata [root@***client ~]# 给卷组添加容量 磁盘分区的时候 partx -a /dev/sdb 让系统识别分区 [root@***client ~]# pvcreate /dev/sdb2 [root@***client ~]# vgextend lvmdisk /dev/sdb2 从卷组中去掉一块分区 如果有数据移动到别的盘里面 [root@***client ~]# pvmove /dev/sdb1 /dev/sdc1 [root@***client ~]# vgreduce lvmdisk /dev/sdb1 逻辑卷的扩展和减少 lvextend -L +3G /dev/lvmdisk/mysqldata #mysqldata 创建的时候就指定了卷组 [root@***client ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda2 30G 2.2G 26G 8% / tmpfs 491M 0 491M 0% /dev/shm /dev/sda1 190M 40M 141M 23% /boot /dev/mapper/lvmdisk-mysqldata 15G 30M 14G 1% /mnt/mysqldata [root@***client ~]# resize2fs /dev/mapper/lvmdisk-mysqldata #df -h 查看出来的文件系统边界
转载于:https://blog.51cto.com/wsxxsl/1912916