Lvm2: Difference between revisions
Created page with "= LVM2 Cache Feature = One of the LVM2 great features is the Cache option. The main idea of this feature is to store frequently used blocks of the large and slow LV (called a..." |
No edit summary |
||
(6 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
= LVM2 Cache Feature = | = LVM2 Cache Feature = | ||
One of the LVM2 great features is the Cache option. The main idea of this feature is to store frequently used blocks of the large and slow LV (called as '''origin LV''') on the small and fast LV (called as '''cache pool LV'''). Large and slow is a well known old friend HDD, small and fast is our new friend SSD. LVM2 caching feature is built on top of dm-cache. As a result of this, cache pool LV consists of two parts: the '''cache data LV''' and '''cache metadata LV'''. The cache data LV stores blocks from the origin LV to increase access speed. The cache metadata LV holds the summary information specifying where are the data blocks stored (e.g. on the origin LV or on the cache data LV). All of these associated LVs must be in the same VG. | One of the LVM2 great features is the Cache option. The main idea of this feature is to store frequently used blocks of the large and slow LV (called as '''origin LV''') on the small and fast LV (called as '''cache pool LV'''). Large and slow is a well known old friend HDD, small and fast is our new friend SSD. LVM2 caching feature is built on top of dm-cache<ref>[http://blog-vpodzime.rhcloud.com/?p=45 Life reflections - bcache vs LVMcache]</ref>. As a result of this, cache pool LV consists of two parts: the '''cache data LV''' and '''cache metadata LV'''. The cache data LV stores blocks from the origin LV to increase access speed. The cache metadata LV holds the summary information specifying where are the data blocks stored (e.g. on the origin LV or on the cache data LV). All of these associated LVs must be in the same VG<ref>[http://man7.org/linux/man-pages/man7/lvmcache.7.html Linux manual pages - LVMcache]</ref><ref>[https://rwmj.wordpress.com/2014/05/22/using-lvms-new-cache-feature/ Richard VM Jones - LVM new cache feature]</ref>. | ||
== Short Topology == | == Short Topology == | ||
Line 16: | Line 19: | ||
|cache LV ||CacheLV || OriginLV + CachePoolLV | |cache LV ||CacheLV || OriginLV + CachePoolLV | ||
|} | |} | ||
== Requirments == | |||
1. utilities (lvm2)<br /> | |||
2a. regular root permissions to install and run package<br /> | |||
2b. specific user permissions to install software if missing as well as specefic permissions to run utilities<br /> | |||
(superuser can allow user to run specific commands)<ref>[http://www.atrixnet.com/allow-an-unprivileged-user-to-run-a-certain-command-with-sudo/ Tommy Butler blog - allow user a command]</ref> | |||
== Setting UP == | == Setting UP == | ||
1. create OriginLV | 1. create OriginLV. | ||
<source lang="bash"> | <source lang="bash"> | ||
Line 114: | Line 124: | ||
lvremove VG/CachePoolLV | lvremove VG/CachePoolLV | ||
</source> | </source> | ||
== Summary == | |||
New LVM2 feature is a great opportunity to improve disk system performance. All you need is a fast SSD drive. Of course, you have to take into concideration the risks of using a single SSD drive to cache the Origin volume. It is much more safe to use a RAID1 mirror for the cache LV as well as a mirror for the Origin LV to avoid a possibility of physical failure. Good news, that small SSDs aren't that expensive and it is really possible to create safe and productive business solution to cache the most used data of big and slow hard disk drives using fast solid state drives. | |||
== Artice references == | == Artice references == | ||
<references /> | |||
[[Category:Operatsioonisüsteemide administreerimine ja sidumine]] |
Latest revision as of 15:04, 5 January 2016
LVM2 Cache Feature
One of the LVM2 great features is the Cache option. The main idea of this feature is to store frequently used blocks of the large and slow LV (called as origin LV) on the small and fast LV (called as cache pool LV). Large and slow is a well known old friend HDD, small and fast is our new friend SSD. LVM2 caching feature is built on top of dm-cache[1]. As a result of this, cache pool LV consists of two parts: the cache data LV and cache metadata LV. The cache data LV stores blocks from the origin LV to increase access speed. The cache metadata LV holds the summary information specifying where are the data blocks stored (e.g. on the origin LV or on the cache data LV). All of these associated LVs must be in the same VG[2][3].
Short Topology
origin LV | OriginLV | large slow LV |
cache data LV | CacheDataLV | small fast LV for cache pool data |
cache metadata LV | CacheMetaLV | small fast LV for cache pool metadata |
cache pool LV | CachePoolLV | CacheDataLV + CacheMetaLV |
cache LV | CacheLV | OriginLV + CachePoolLV |
Requirments
1. utilities (lvm2)
2a. regular root permissions to install and run package
2b. specific user permissions to install software if missing as well as specefic permissions to run utilities
(superuser can allow user to run specific commands)[4]
Setting UP
1. create OriginLV.
lvcreate -n OriginLV -L LargeSize VG /dev/slow
Example
lvcreate -n originlogvol -L 100G cacheVG /dev/hda
2. create CacheDataLV.
This LV will store the data blocks from OriginLV and this volume size will be reported as the cache pool size.
lvcreate -n CacheDataLV -L CacheSize VG /dev/fast
Example
lvcreate -n cachedata -L 10G cacheVG /dev/sda1
3. create CacheMetaLV.
This will create cache metadata LV. This volume will hold the cache metadata.
This volume size must be 1000 times smaller than the cache data LV, with a minimum size of 8MiB.
lvcreate -n CacheMetaLV -L MetaSize VG /dev/fast
Example
lvcreate -n cachemeta -L 12M cacheVG /dev/sda2
4. create CachePoolLV.
Merge the data and metadata LVs into a cache pool LV.
During this step we configure LVM to use volumes that we prepared before to work as a cache pool LV.
CachePoolLV takes the name of CacheDataLV.
CacheDataLV is renamed CachePoolLV_cdata and becomes hidden.
CacheMetaLV is renamed CachePoolLV_cmeta and becomes hidden.
lvconvert --type cache-pool --poolmetadata VG/CacheMetaLV VG/CacheDataLV
Example
lvconvert --type cache-pool --poolmetadata cacheVG/cachemeta cacheVG/cachedata
5.create CacheLV.
Finally, you have to create a cache LV.
This is done by linking the cache pool LV to the origin LV.
CacheLV takes the name of OriginLV.
OriginLV is renamed OriginLV_corig and becomes hidden.
lvconvert --type cache --cachepool VG/CachePoolLV VG/OriginLV
Example
lvconvert --type cache --cachepool cacheVG/cachedata cacheVG/originlogvol
6. Enjoy!
Removing
1. Safely split volumes and write back data from the cache data pool onto the main origin volume.
lvconvert --splitcache VG/CacheLV
2. Safely write data back to the origin volume and remove the cache pool.
lvremove VG/CachePoolLV
Summary
New LVM2 feature is a great opportunity to improve disk system performance. All you need is a fast SSD drive. Of course, you have to take into concideration the risks of using a single SSD drive to cache the Origin volume. It is much more safe to use a RAID1 mirror for the cache LV as well as a mirror for the Origin LV to avoid a possibility of physical failure. Good news, that small SSDs aren't that expensive and it is really possible to create safe and productive business solution to cache the most used data of big and slow hard disk drives using fast solid state drives.