概要
VDOを試してみる その1の続き。前回はVDOの導入とVDOボリュームの作成まで行った。
VDOでのデータ圧縮
VDOボリュームでどれくらいデータ圧縮が行われるか確認してみる。
パーティション作成とフォーマット
その前にまだブロックデバイスとしてしか認識されていないので、パーティション作成とフォーマットを行う。
sdb~sdeはUSB HDDで以前にZFSのテストで利用していたもの。どれかが今回のVDOボリュームに利用されている。
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 111.8G 0 disk
tqsda1 8:1 0 1G 0 part /boot
mqsda2 8:2 0 110.8G 0 part
tqcl-root 253:0 0 50G 0 lvm /
tqcl-swap 253:1 0 7.8G 0 lvm [SWAP]
mqcl-home 253:2 0 53G 0 lvm /home
sdb 8:16 0 232.9G 0 disk
sdc 8:32 0 232.9G 0 disk
sdd 8:48 0 232.9G 0 disk
sde 8:64 0 232.9G 0 disk
mqsde1 8:65 0 232.9G 0 part
mqvdovolume 253:3 0 1T 0 vdo
sr0 11:0 1 1024M 0 rom
# vdostats
Device 1K-blocks Used Available Use% Space saving%
/dev/mapper/vdovolume 244197540 3187900 241009640 1% N/A
# vdostats --human-readable
Device Size Used Available Use% Space saving%
/dev/mapper/vdovolume 232.9G 3.0G 229.8G 1% N/A
適当にパーティション作成
# fdisk -l /dev/mapper/vdovolume
Disk /dev/mapper/vdovolume: 1099.5 GB, 1099511627776 bytes, 268435456 sectors
Units = sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O サイズ (最小 / 推奨): 4096 バイト / 4096 バイト
# fdisk /dev/mapper/vdovolume
# fdisk -l /dev/mapper/vdovolume
Disk /dev/mapper/vdovolume: 1099.5 GB, 1099511627776 bytes, 268435456 sectors
Units = sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O サイズ (最小 / 推奨): 4096 バイト / 4096 バイト
Disk label type: dos
ディスク識別子: 0xd18f4dbb
デバイス ブート 始点 終点 ブロック Id システム
/dev/mapper/vdovolume1 256 268435455 1073740800 83 Linux
EXT4でフォーマット。ファイルシステムは何でも良いが、DISCARDオプションに対応している必要がある。
# kpartx -an /dev/mapper/anothervdovolume
# mkfs.ext4 /dev/mapper/vdovolume1
マウント先を作成してマウント。ここでDISCARDオプションを設定している。
# mkdir /mnt/vdopart
# mount -o "discard" /dev/mapper/vdovolume1 /mnt/vdopart/
# mount | grep vdovolume1
/dev/mapper/vdovolume1 on /mnt/vdopart type ext4 (rw,relatime,seclabel,discard,data=ordered)
テスト用データを保存してみる
とりあえず/dev/zeroで埋めた1GBのファイルを作成。Space saving%
から99%の省スペースが出来ていることが分かる。
VDOボリュームに書き込み後すぐにvdostats
すると書き込み途中での情報が表示されるため、sync
してから確認する。
# dd if=/dev/zero of=/mnt/vdopart/zero1g.dat bs=1M count=1024
1024+0 レコード入力
1024+0 レコード出力
1073741824 バイト (1.1 GB) コピーされました、 1.21151 秒、 886 MB/秒
# vdostats
Device 1K-blocks Used Available Use% Space saving%
/dev/mapper/vdovolume 244197540 3193020 241004520 1% 99%
# vdostats --human-readable
Device Size Used Available Use% Space saving%
/dev/mapper/vdovolume 232.9G 3.0G 229.8G 1% 99%
追加で/dev/urandomで埋めた1GBのファイルを作成。Space saving%
の値が53%になっている。
# dd if=/dev/urandom of=/mnt/vdopart/rand1g.dat bs=1M count=1024
1024+0 レコード入力
1024+0 レコード出力
1073741824 バイト (1.1 GB) コピーされました、 6.02776 秒、 178 MB/秒
# vdostats
Device 1K-blocks Used Available Use% Space saving%
/dev/mapper/vdovolume 244197540 4246812 239950728 1% 53%
# vdostats --human-readable
Device Size Used Available Use% Space saving%
/dev/mapper/vdovolume 232.9G 4.1G 228.8G 1% 53%
作成したファイルを削除してみる。当然だが/dev/urandomから作成したファイルはほとんど圧縮が効かない様子。
# rm /mnt/vdopart/zero1g.dat
# vdostats
Device 1K-blocks Used Available Use% Space saving%
/dev/mapper/vdovolume 244197540 4246844 239950696 1% 12%
# rm /mnt/vdopart/rand1g.dat
# vdostats
Device 1K-blocks Used Available Use% Space saving%
/dev/mapper/vdovolume 244197540 3198292 240999248 1% 99%
大きなデータを保存してみる
40GB超のテキストデータをVDOボリュームに保存してみる。
# vdostats
Device 1K-blocks Used Available Use% Space saving%
/dev/mapper/vdovolume 244197540 30893904 213303636 12% 36%
# vdostats --human-readable
Device Size Used Available Use% Space saving%
/dev/mapper/vdovolume 232.9G 29.5G 203.4G 12% 36%
# df -h
ファイルシス サイズ 使用 残り 使用% マウント位置
/dev/mapper/cl-root 50G 26G 25G 51% /
devtmpfs 7.6G 0 7.6G 0% /dev
tmpfs 7.7G 0 7.7G 0% /dev/shm
tmpfs 7.7G 129M 7.5G 2% /run
tmpfs 7.7G 0 7.7G 0% /sys/fs/cgroup
/dev/sda1 1014M 325M 690M 33% /boot
/dev/mapper/cl-home 54G 36M 53G 1% /home
/dev/mapper/vdovolume1 1008G 42G 916G 5% /mnt/vdopart
tmpfs 1.6G 0 1.6G 0% /run/user/0
# vdostats --all
/dev/mapper/vdovolume :
version : 26
release version : 131337
data blocks used : 6910521
overhead blocks used : 812955
logical blocks used : 10821891
physical blocks : 61049385
logical blocks : 268435456
1K-blocks : 244197540
1K-blocks used : 30893904
1K-blocks available : 213303636
used percent : 12
saving percent : 36
block map cache size : 134217728
write policy : sync
block size : 4096
(snip)
compressed fragments written : 7738273
compressed blocks written : 3858580
compressed fragments in packer : 15
(snip)
dedupe advice valid : 1564
dedupe advice stale : 0
dedupe advice timeouts : 0
ZFSみたいにcompression, deduplication がどれくらい効いているのか分かるコマンドがないだろうか。
deduplicationが有効になってないかもしれないと思って確認してみたが大丈夫そうだった。
参考: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/storage_administration_guide/vdo-ig-commands
# vdo printConfigFile
config: !Configuration
vdos:
vdovolume: !VDOService
_operationState: finished
ackThreads: 1
activated: enabled
bioRotationInterval: 64
bioThreads: 4
blockMapCacheSize: 128M
blockMapPeriod: 16380
compression: enabled
cpuThreads: 2
deduplication: enabled
device: /dev/disk/by-id/usb-I-O_DATA_HDPS-U_XXXXXXXXXXXX-0:0-part1
hashZoneThreads: 1
indexCfreq: 0
indexMemory: 0.25
indexSparse: disabled
indexThreads: 0
logicalBlockSize: 4096
logicalSize: 1T
logicalThreads: 1
name: vdovolume
physicalSize: 244197540K
physicalThreads: 1
readCache: disabled
readCacheSize: 0M
slabSize: 2G
writePolicy: auto
version: 538380551
filename: /etc/vdoconf.yml
念のために同一ファイルをコピーしてどうなるかテスト。前述のテキストファイルは削除してある。
compressionとdeduplication併せて50%以上のディスクスペース節約となっている。
# cd /mnt/vdopart
# wget http://ftp.iij.ad.jp/pub/linux/centos/7/isos/x86_64/CentOS-7-x86_64-DVD-1804.iso
# vdostats
Device 1K-blocks Used Available Use% Space saving%
/dev/mapper/vdovolume 244197540 7486872 236710668 3% 6%
# cp CentOS-7-x86_64-DVD-1804.iso CentOS-7-x86_64-DVD-1804.iso.bak
# vdostats
Device 1K-blocks Used Available Use% Space saving%
/dev/mapper/vdovolume 244197540 7492344 236705196 3% 52%
気が向いたら速度のベンチマークをしてみる。