This is an old revision of the document!
Table of Contents
Setup LVMCache for monitor.zappa.cx with RAID-1 on SSD
Orig LV: monitor-disk F3_2TB -wi-ao---- 6.00g
SSD PV's has been added to F3_2TB VG and SSD tags has been added.
bigbang:~# pvs -o +tags PV VG Fmt Attr PSize PFree PV Tags /dev/cciss/c0d0p2 F3_2TB lvm2 a-- 1.79t 734.65g HDD /dev/sdb1 F3_2TB lvm2 a-- 400.00g 400.00g SSD /dev/sdc1 F3_2TB lvm2 a-- 400.00g 400.00g SSD bigbang:~#
Create a 2-way RAID1 cache data LV (1GB)
bigbang:~# lvcreate --type raid1 -m 1 -n monitorCDLV -L 1G F3_2TB @SSD Logical volume "monitorCDLV" created. bigbang:~#
Create a 2-way RAID1 cache metadata LV (8MB minimum or 1000 times smaller than cache LV)
bigbang:~# lvcreate --type raid1 -m 1 -n monitorCMLV -L 8M F3_2TB @SSD Logical volume "monitorCMLV" created. bigbang:~#
Create a cache pool LV combining cache data LV and cache metadata LV
bigbang:~# lvconvert --type cache-pool --poolmetadata F3_2TB/monitorCMLV F3_2TB/monitorCDLV WARNING: Converting logical volume F3_2TB/monitorCDLV and F3_2TB/monitorCMLV to cache pool's data and metadata volumes with metadata wiping. THIS WILL DESTROY CONTENT OF LOGICAL VOLUME (filesystem etc.) Do you really want to convert F3_2TB/monitorCDLV and F3_2TB/monitorCMLV? [y/n]: y Converted F3_2TB/monitorCDLV to cache pool. bigbang:~#
Create a cached LV by combining the cache pool LV and origin LV
bigbang:~# lvconvert --type cache --cachepool F3_2TB/monitorCDLV F3_2TB/monitor-disk Do you want wipe existing metadata of cache pool volume F3_2TB/monitorCDLV? [y/n]: y Logical volume F3_2TB/monitor-disk is now cached. bigbang:~#
Done
To change cache mode
bigbang:~# lvs -o +cachemode F3_2TB/monitor-disk LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert CacheMode monitor-disk F3_2TB Cwi-aoC--- 6.00g [monitorCDLV] [monitor-disk_corig] 13.33 1.90 0.00 writethrough bigbang:~#
bigbang:~# lvchange --cachemode writeback F3_2TB/monitor-disk Logical volume F3_2TB/monitor-disk changed. bigbang:~#
bigbang:~# lvs -o +cachemode F3_2TB/monitor-disk LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert CacheMode monitor-disk F3_2TB Cwi-aoC--- 6.00g [monitorCDLV] [monitor-disk_corig] 13.37 2.83 5.02 writeback bigbang:~#
bigbang:~# lvchange --cachemode writethrough F3_2TB/monitor-disk Flushing 107 blocks for cache F3_2TB/monitor-disk. Flushing 79 blocks for cache F3_2TB/monitor-disk. Logical volume F3_2TB/monitor-disk changed. bigbang:~#
bigbang:~# lvs -o +cachemode F3_2TB/monitor-disk LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert CacheMode monitor-disk F3_2TB Cwi-aoC--- 6.00g [monitorCDLV] [monitor-disk_corig] 13.37 2.83 0.00 writethrough bigbang:~#
To remove cache
Make sure it is in writethrough - just to be safe. Also check that no blocks are dirty.
bigbang:~# lvconvert --uncache F3_2TB/monitor-disk Logical volume "monitorCDLV" successfully removed Logical volume F3_2TB/monitor-disk is not cached. bigbang:~#
Setup LVMCache and ThinPool for caching multiple LV's with RAID-1 on SSD
Setting up ThinPool (size 500GB on the HW RAID-1 HDD and metadata on LVM mirrored SSD's)
Create 500GB LV for ThinPool0 on the HW raided HDD's
bigbang:~# lvcreate -n ThinPool0 -L 500G F3_2TB @HDD Logical volume "ThinPool0" created. bigbang:~#
Create 1GB LV for ThinPool0_meta using LVM RAID-1 on the SSD's
bigbang:~# lvcreate --type raid1 -m 1 -n ThinPool0_meta -L 1G F3_2TB @SSD Logical volume "ThinPool0_meta" created. bigbang:~#
Create the ThinPool0 by combining data data and metadata LV's
bigbang:~# lvconvert --type thin-pool --poolmetadata F3_2TB/ThinPool0_meta F3_2TB/ThinPool0 Thin pool volume with chunk size 64.00 KiB can address at most 15.81 TiB of data. WARNING: Converting F3_2TB/ThinPool0 and F3_2TB/ThinPool0_meta to thin pool's data and metadata volumes with metadata wiping. THIS WILL DESTROY CONTENT OF LOGICAL VOLUME (filesystem etc.) Do you really want to convert F3_2TB/ThinPool0 and F3_2TB/ThinPool0_meta? [y/n]: y Converted F3_2TB/ThinPool0 and F3_2TB/ThinPool0_meta to thin pool. bigbang:~#
ThinPool0 has now been created, LV's using it can be created like so
# lvcreate -n ThinLV -V VirtualSize --thinpool ThinPool0 F3_2TB
Snapshots are created without specifying the size as it is automatically using the data from the ThinPool0 LV for storing the difference.
# lvcreate -n ThinLV_s1 -s F3_2TB/ThinLV
Adding caching for the ThinPool0
Create a 2-way RAID1 cache data LV (50GB)
bigbang:~# lvcreate --type raid1 -m 1 -n ThinPool0_CDLV -L 50G F3_2TB @SSD Logical volume "ThinPool0_CDLV" created. bigbang:~#
Create a 2-way RAID1 cache metadata LV (8MB minimum or 1000 times smaller than cache LV)
bigbang:~# lvcreate --type raid1 -m 1 -n ThinPool0_CMLV -L 50M F3_2TB @SSD Rounding up size to full physical extent 52.00 MiB Logical volume "ThinPool0_CMLV" created. bigbang:~#
Create a writeback cached LV by combining the cache pool LV cache metadata and origin LV
bigbang:~# lvconvert --type cache --cachemode writeback --cachepool ThinPool0_CDLV --poolmetadata ThinPool0_CMLV F3_2TB/ThinPool0 WARNING: Converting F3_2TB/ThinPool0_CDLV and F3_2TB/ThinPool0_CMLV to cache pool's data and metadata volumes with metadata wiping. THIS WILL DESTROY CONTENT OF LOGICAL VOLUME (filesystem etc.) Do you really want to convert F3_2TB/ThinPool0_CDLV and F3_2TB/ThinPool0_CMLV? [y/n]: y Converted F3_2TB/ThinPool0_CDLV and F3_2TB/ThinPool0_CMLV to cache pool. WARNING: Cached thin pool's data cannot be currently resized and require manual uncache before resize! Logical volume F3_2TB/ThinPool0_tdata is now cached. bigbang:~#
Removing cache from ThinPool0
Change to writethrough before separating cache pool from cache LV
bigbang:~# lvchange --cachemode writethrough F3_2TB/ThinPool0_tdata Flushing 0 blocks for cache F3_2TB/ThinPool0_tdata. Logical volume F3_2TB/ThinPool0_tdata changed.
Separate and keep the cache pool from a cache LV.
bigbang:~# lvconvert --splitcache F3_2TB/ThinPool0 Logical volume F3_2TB/ThinPool0_tdata is not cached and cache pool F3_2TB/ThinPool0_CDLV is unused.
Attach cache LV to previously separated cache pool
bigbang:~# lvconvert --type cache --cachemode writeback --cachepool F3_2TB/ThinPool0_CDLV F3_2TB/ThinPool0 Do you want wipe existing metadata of cache pool F3_2TB/ThinPool0_CDLV? [y/n]: y WARNING: Cached thin pool's data cannot be currently resized and require manual uncache before resize! Logical volume F3_2TB/ThinPool0_tdata is now cached.