在线为数据盘添加Cache。

原磁盘/dev/sde1为8T磁盘,通过lvm管理,目前该空间有数据。

命令:lvm,pvcreate,vgcreate,lvcreate,vgextend,

lvcreate -n cache -L 9G vg_faster
lvcreate -n meta -l 100%FREE vg_faster
vgextend 8t_test /dev/disk/by-id/wwn-0x5e83a97ee1537d85-part5
lvcreate --type cache-pool --name cache -L 8G 8t_test /dev/disk/by-id/wwn-0x5e83a97ee1537d85-part5
lvconvert --type cache --cachepool 8t_test/cache 8t_test/8tall


root@HomeServer-Master:/opt/seafile# pvdisplay /dev/sde1  && vgdisplay 8t_test && lvs
--- Physical volume ---
PV Name /dev/sde1
VG Name 8t_test
PV Size <7.28 TiB / not usable 4.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 1907720
Free PE 0
Allocated PE 1907720
PV UUID noAsRL-SkDF-Zn2D-X8p6-UXD4-bXLV-kd27s6
--- Volume group ---
VG Name 8t_test
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 7
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 2
Act PV 2
VG Size <7.29 TiB
PE Size 4.00 MiB
Total PE 1910279
Alloc PE / Size 1909774 / <7.29 TiB
Free PE / Size 505 / 1.97 GiB
VG UUID BLj8Le-q4vP-YaKb-fYvT-h8oY-Pa64-A1s6Lq
One or more devices used as PVs in VG ubuntu_vg have changed sizes.
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
8tall 8t_test Cwi-aoC--- <7.28t [cache] [8tall_corig] 1.64 8.85 0.00
root ubuntu_vg -wi-ao---- 23.28g
swap_1 ubuntu_vg -wi-ao---- 952.00m

如果Faster SSD生成的cache\meta和Slow Disk生成的data数据区不再同一个VG时会提示如下错误:

lvm cache VG name mismatch from position arg (8t_test) and option arg (vg_faster).

可以通过将cache/meta所在的SSD通过vgextend的方式加入到现有的VG中。

vgextend 8t_test /dev/disk/by-id/wwn-0x5e83a97ee1537d85-part5

然后从SSD空间中创建Cache

lvcreate –type cache-pool –name cache -L 8G 8t_test /dev/disk/by-id/wwn-0x5e83a97ee1537d85-part5

or
lvcreate –type cache-pool –name cache -l +100%free vg_name pv_name


root@HomeServer-Master:/mnt/8t# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
8tall 8t_test Cwi-aoC--- <7.28t [cache] [8tall_corig] 4.20 8.98 0.00
root ubuntu_vg -wi-ao---- 23.28g
swap_1 ubuntu_vg -wi-ao---- 952.00m
root@HomeServer-Master:/mnt/8t#

root@HomeServer-Master:/mnt/8t# lvs -a
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
8tall 8t_test Cwi-aoC--- <7.28t [cache] [8tall_corig] 4.20 8.98 0.00
[8tall_corig] 8t_test owi-aoC--- <7.28t
[cache] 8t_test Cwi---C--- 8.00g 4.20 8.98 0.00
[cache_cdata] 8t_test Cwi-ao---- 8.00g
[cache_cmeta] 8t_test ewi-ao---- 12.00m
[lvol0_pmspare] 8t_test ewi------- 12.00m
root ubuntu_vg -wi-ao---- 23.28g
swap_1 ubuntu_vg -wi-ao---- 952.00m
root@HomeServer-Master:/mnt/8t#