lvm的安装
在线安装 yum install lvm2
离线安装,下载后执行 rpm -ivh * --nodeps --force
在如下网站中挨个下载http://mirrors.163.com/centos/7/os/x86_64/Packages/
device-mapper-1.02.170-6.el7_9.5.x86_64.rpm
device-mapper-event-1.02.170-6.el7_9.5.x86_64.rpm
device-mapper-event-libs-1.02.170-6.el7_9.5.x86_64.rpm
device-mapper-libs-1.02.170-6.el7_9.5.x86_64.rpm
device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64.rpm
libaio-0.3.109-13.el7.x86_64.rpm
lvm2-2.02.187-6.el7_9.5.x86_64.rpm
lvm2-libs-2.02.187-6.el7_9.5.x86_64.rpm
使用lvm将磁盘不分区创建逻辑券并挂载
1.创建pv
[root@ecs-fcgxtjsxm-app-prd-0003 centos]# pvcreate /dev/vdb3
Physical volume "/dev/vdb3" successfully created.
2.创建vg
[root@ecs-fcgxtjsxm-app-prd-0003 centos]# vgcreate zhvg /dev/vdb1 /dev/vdb2
Volume group "zhvg" successfully created
3.创建lv
[root@ecs-fcgxtjsxm-app-prd-0003 centos]# lvcreate -n zhlv -L +150G zhvg
WARNING: xfs signature detected on /dev/zhvg/zhlv at offset 0. Wipe it? [y/n]: y
Wiping xfs signature on /dev/zhvg/zhlv.
Logical volume "zhlv" created.
4.格式化文件系统
[root@ecs-fcgxtjsxm-app-prd-0003 /]# mkfs.xfs /dev/zhvg/zhlv
meta-data=/dev/zhvg/zhlv isize=512 agcount=4, agsize=9830400 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=39321600, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=19200, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
5.磁盘挂载
[root@ecs-fcgxtjsxm-app-prd-0003 /]# mount /dev/zhvg/zhlv /mydata
[root@ecs-fcgxtjsxm-app-prd-0003 /]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 1024M 0 rom
vda 253:0 0 100G 0 disk
└─vda1 253:1 0 100G 0 part /
vdb 253:16 0 500G 0 disk
├─vdb1 253:17 0 100G 0 part
│ └─zhvg-zhlv 252:0 0 150G 0 lvm /mydata
├─vdb2 253:18 0 100G 0 part
│ └─zhvg-zhlv 252:0 0 150G 0 lvm /mydata
└─vdb3 253:19 0 100G 0 part
[root@ecs-fcgxtjsxm-app-prd-0003 /]# blkid
/dev/vda1: UUID="6cd50e51-cfc6-40b9-9ec5-f32fa2e4ff02" TYPE="xfs"
/dev/vdb1: UUID="tfiIX7-TU5B-jPSd-ZmnO-LTcT-hKdC-Kiwce9" TYPE="LVM2_member"
/dev/vdb2: UUID="1ydi74-WbOo-jRuY-ZlAe-9ITo-9t1x-4sd8PC" TYPE="LVM2_member"
/dev/mapper/zhvg-zhlv: UUID="ab669eaf-c2bc-45da-9b8a-ec4b64939d6b" TYPE="xfs"
6.设置开机启动
echo "/dev/mapper/myvg-mydata /data xfs defaults 0 0" >> /etc/fstab
lvm逻辑券常用命令
pvremove /dev/vdb3 #删除pv
vgextend zhvg /dev/vdb3 #vg扩容
vgreduce zhvg /dev/vdb3 #vg缩容,移除pv
vgremove zhvg #删除卷组
lvextend -L180G /dev/zhvg/zhlv #lv扩容 180g是扩容后的容量,必须大于现有的容量
lvreduce -L 20G /dev/zhvg/zhlv #lv缩容 20G是缩容后的容量
lvremove /dev/zhvg/zhlv #删除lv
xfs_growfs /dev/zhvg/zhlv #lv扩容后需执行此命令 df -h中的实际容量才会生效
mount -a #执行/etc/fstab的内容
mount -l #查看磁盘挂载情况
pvs vgs lvs 查询券的情况
pvscan vgscan lvscan 查询券的情况
pvdispaly vgdisplay lvdispaly 查看券的详情