VDO使用LVM逻辑卷作为后端设备创建XFS文件系统在线添加磁盘扩容操作过程(推荐)
0.服务器环境信息
192.168.111.192 CentOS 7
安装vdo和kmod-kvdo软件包:
#yum install vdo kmod-kvdo
# pvcreate /dev/sdb
# vgcreate vdovg /dev/sdb
# lvcreate -l 100%VG -n vdolv vdovg
# lvscan
# vdo create --name=vdo0 --device=/dev/vdovg/vdolv --vdoLogicalSize=200G
# systemctl enable vdo
[root@localhost ~]# vdo create --name=vdo0 --device=/dev/vdovg/vdolv --vdoLogicalSize=200G
Creating VDO vdo0
Starting VDO vdo0
Starting compression on VDO vdo0
VDO instance 0 volume is ready at /dev/mapper/vdo0
[root@localhost ~]#
# mkfs.xfs -K /dev/mapper/vdo0
# mount /dev/mapper/vdo0 /mnt
[root@localhost ~]# mkfs.xfs -K /dev/mapper/vdo0
meta-data=/dev/mapper/vdo0 isize=512 agcount=4, agsize=13107200 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=52428800, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=25600, version=2
= sectsz=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@localhost ~]# mount /dev/mapper/vdo0 /mnt
[root@localhost ~]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/centos-root xfs 2.0T 4.6G 2.0T 1% /
devtmpfs devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs tmpfs 1.9G 13M 1.9G 1% /run
tmpfs tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda1 xfs 1014M 284M 731M 29% /boot
tmpfs tmpfs 378M 12K 378M 1% /run/user/42
tmpfs tmpfs 378M 0 378M 0% /run/user/0
/dev/mapper/vdo0 xfs 200G 33M 200G 1% /mnt
[root@localhost ~]#
# touch /mnt/file{1..5}
# ls -l /mnt/
# df -hT
# vgdisplay
# pvdisplay
# lvdisplay
# cd /mnt
# tar -cvf usr.tar /usr
[root@localhost mnt]# vdostats --human-readable
Device Size Used Available Use% Space saving%
/dev/mapper/vdo0 10.0G 6.5G 3.5G 64% 31%
[root@localhost mnt]#
Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/sdc: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
[root@localhost mnt]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/centos-root xfs 2.0T 4.6G 2.0T 1% /
devtmpfs devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs tmpfs 1.9G 13M 1.9G 1% /run
tmpfs tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda1 xfs 1014M 284M 731M 29% /boot
tmpfs tmpfs 378M 12K 378M 1% /run/user/42
tmpfs tmpfs 378M 0 378M 0% /run/user/0
/dev/mapper/vdo0 xfs 200G 15G 186G 8% /mnt
[root@localhost mnt]# vdostats --human-readable
Device Size Used Available Use% Space saving%
/dev/mapper/vdo0 10.0G 6.6G 3.4G 66% 81%
[root@localhost mnt]#
4、在线扩容
# lsblk
# pvcreate /dev/sdc
# pvdisplay
# vgdisplay
# vgextend vdovg /dev/sdc
# lvs
# lvdisplay
# lvextend -l+100%FREE /dev/vdovg/vdolv
# lvs
[root@localhost mnt]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-ao---- <1.95t
swap centos -wi-ao---- 4.00g
vdolv vdovg -wi-ao---- 19.99g
[root@localhost mnt]#
[root@localhost mnt]# vdostats --human-readable
Device Size Used Available Use% Space saving%
/dev/mapper/vdo0 10.0G 7.5G 2.5G 74% 77%
[root@localhost mnt]#
在主节点执行:
# vdo growPhysical --name=vdo0
[root@localhost mnt]# vdostats --human-readable
Device Size Used Available Use% Space saving%
/dev/mapper/vdo0 10.0G 7.5G 2.5G 74% 77%
[root@localhost mnt]# vdo growPhysical --name=vdo0
[root@localhost mnt]# vdostats --human-readable
Device Size Used Available Use% Space saving%
/dev/mapper/vdo0 20.0G 7.6G 12.3G 38% 76%
[root@localhost mnt]#
# vdo growLogical --name=vdo0 --vdoLogicalSize=400G
# xfs_growfs /mnt
# df -hT
[root@localhost mnt]# vdostats --human-readable
Device Size Used Available Use% Space saving%
/dev/mapper/vdo0 20.0G 7.6G 12.3G 38% 76%
[root@localhost mnt]# vdo growLogical --name=vdo0 --vdoLogicalSize=400G
[root@localhost mnt]# xfs_growfs /mnt
meta-data=/dev/mapper/vdo0 isize=512 agcount=4, agsize=13107200 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=52428800, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=25600, version=2
= sectsz=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 52428800 to 104857600
[root@localhost mnt]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/centos-root xfs 2.0T 4.6G 2.0T 1% /
devtmpfs devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs tmpfs 1.9G 13M 1.9G 1% /run
tmpfs tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda1 xfs 1014M 284M 731M 29% /boot
tmpfs tmpfs 378M 12K 378M 1% /run/user/42
tmpfs tmpfs 378M 0 378M 0% /run/user/0
/dev/mapper/vdo0 xfs 400G 18G 383G 5% /mnt
[root@localhost mnt]#
[root@localhost mnt]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 2T 0 disk
tqsda1 8:1 0 1G 0 part /boot
mqsda2 8:2 0 2T 0 part
tqcentos-root 253:0 0 2T 0 lvm /
mqcentos-swap 253:1 0 4G 0 lvm [SWAP]
sdb 8:16 0 10G 0 disk
mqvdovg-vdolv 253:2 0 20G 0 lvm
mqvdo0 253:3 0 400G 0 vdo /mnt
sdc 8:32 0 10G 0 disk
mqvdovg-vdolv 253:2 0 20G 0 lvm
mqvdo0 253:3 0 400G 0 vdo /mnt
sr0 11:0 1 1024M 0 rom
[root@localhost mnt]#
——全文完——