实验环境:
centos 7
vdo的作用
VDO的主要作用是节省磁盘空间,比如让1T的磁盘能装下1.5T的数据,从而降低数据中心的成本。
vdo原理主要是重删和压缩,重删就是硬盘里拷贝来相同的数据,以前要占多份空间,现在只需要1份空间就可以了。类似我们在百度网盘中上传一个大型软件安装包,能实现秒传,其实是之前就有,所以无需再传一遍,也无需再占百度一份空间。另一方面是数据压缩,类似于压缩软件的算法,也可以更加节省磁盘空间。
步骤:
先添加一块64GB的硬盘上去 (未分区的新磁盘)
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 300G 0 disk
├─sda1 8:1 0 300M 0 part /boot
├─sda2 8:2 0 5.2G 0 part [SWAP]
└─sda3 8:3 0 294.5G 0 part /
sdb 8:16 0 64G 0 disk //此处我已经添加好了
sr0 11:0 1 1024M 0 rom
[root@localhost ~]#
安装vdo软件和模块
[root@localhost ~]# yum -y install vdo kmod-kvdo
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.bfsu.edu.cn
* extras: mirrors.bfsu.edu.cn
* updates: mirrors.bfsu.edu.cn
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/2): extras/7/x86_64/primary_db | 254 kB 00:00:00
(2/2): updates/7/x86_64/primary_db | 26 MB 00:00:55
Package vdo-6.1.3.23-5.el7.x86_64 already installed and latest version
Package kmod-kvdo-6.1.3.23-5.el7.x86_64 already installed and latest version
Nothing to do
创建一个VDO卷
--name=myvdo //名字
--device=/dev/sdb //磁盘路径
--vdoLogicalSize=200G //vdo大小 逻辑⼤⼩⼀般采⽤物理容量的1.5 - 3倍,这⾥选物理容量的3倍左右
vdo create --name=myvdo --device=/dev/sdb --vdoLogicalSize=200G
Creating VDO myvdo
Starting VDO myvdo
Starting compression on VDO myvdo
VDO instance 1 volume is ready at /dev/mapper/myvdo
[root@localhost ~]#
查看刚刚创建好的卷
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 300G 0 disk
├─sda1 8:1 0 300M 0 part /boot
├─sda2 8:2 0 5.2G 0 part [SWAP]
└─sda3 8:3 0 294.5G 0 part /
sdb 8:16 0 64G 0 disk
└─myvdo 253:0 0 200G 0 vdo
sr0 11:0 1 1024M 0 rom
[root@localhost ~]#
[root@localhost ~]# fdisk -l /dev/mapper/myvdo
Disk /dev/mapper/myvdo: 214.7 GB, 214748364800 bytes, 52428800 sectors
Units = sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
[root@localhost ~]#
关闭vdo
[root@localhost ~]# vdo stop -n myvdo
Stopping VDO myvdo
开启vdo
[root@localhost ~]# vdo start -n myvdo
Starting VDO myvdo
Starting compression on VDO myvdo
VDO instance 2 volume is ready at /dev/mapper/myvdo
[root@localhost ~]#
查看vdo、查看状态、以及查看物理空间
[root@localhost ~]# vdo list
myvdo
[root@localhost ~]# vdo status -n myvdo
VDO status:
Date: '2024-03-25 01:12:42-07:00'
Node: localhost.localdomain
Kernel module:
Loaded: true
Name: kvdo
Version information:
kvdo version: 6.1.3.23
Configuration:
File: /etc/vdoconf.yml
Last modified: '2024-03-25 01:03:55'
省略。。。。。
[root@localhost ~]# vdostats --human-readable
Device Size Used Available Use% Space saving%
/dev/mapper/myvdo 64.0G 4.0G 60.0G 6% N/A
[root@localhost ~]#
格式化创建的vdo
一定要加 -K(大写) 选项这里和普通的创建文件系统一样,注意要加-K,类似windows格式中的快速格式化,否则会花很多时间
[root@localhost ~]# mkfs.xfs -K /dev/mapper/myvdo
meta-data=/dev/mapper/myvdo 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 ~]#
创建挂载目录,并挂载
[root@localhost ~]# mkdir /123vdo
[root@localhost ~]# cd /
[root@localhost /]# mou
mount mount.cifs mount.fuse mount.glusterfs mount.nfs mount.nfs4 mountpoint mountstats mousetweaks
[root@localhost /]# mou
mount mount.cifs mount.fuse mount.glusterfs mount.nfs mount.nfs4 mountpoint mountstats mousetweaks
[root@localhost /]# mount /dev/mapper/myvdo /123vdo/
[root@localhost /]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 5.1G 0 5.1G 0% /dev
tmpfs tmpfs 5.1G 0 5.1G 0% /dev/shm
tmpfs tmpfs 5.1G 13M 5.1G 1% /run
tmpfs tmpfs 5.1G 0 5.1G 0% /sys/fs/cgroup
/dev/sda3 xfs 295G 4.7G 290G 2% /
/dev/sda1 xfs 297M 163M 134M 55% /boot
tmpfs tmpfs 1.1G 24K 1.1G 1% /run/user/0
/dev/mapper/myvdo xfs 200G 33M 200G 1% /123vdo //这里为刚刚创建的vdo
[root@localhost /]#
到这里vdo 就创建完成了