Buscar

5.4.7. Creating LVM Cache Logical Volumes

download PDF
As of the Red Hat Enterprise Linux 6.7 release, LVM provides full support for LVM cache logical volumes. A cache logical volume uses a small logical volume consisting of fast block devices (such as SSD drives) to improve the performance of a larger and slower logical volume by storing the frequently used blocks on the smaller, faster logical volume.
LVM caching uses the following LVM logical volume types. All of these associated logical volumes must be in the same volume group.
  • Origin logical volume — the large, slow logical volume
  • Cache pool logical volume — the small, fast logical volume, which is composed of two devices: the cache data logical volume, and the cache metadata logical volume
  • Cache data logical volume — the logical volume containing the data blocks for the cache pool logical volume
  • Cache metadata logical volume — the logical volume containing the metadata for the cache pool logical volume, which holds the accounting information that specifies where data blocks are stored (for example, on the origin logical volume or the cache data logical volume).
  • Cache logical volume — the logical volume containing the origin logical volume and the cache pool logical volume. This is the resultant usable device which encapsulates the various cache volume components.
The following procedure creates an LVM cache logical volume.
  1. Create a volume group that contains a slow physical volume and a fast physical volume. In this example. /dev/sde1 is a slow device and /dev/sdf1 is a fast device and both devices are contained in volume group VG.
    # pvcreate /dev/sde1
    # pvcreate /dev/sdf1
    # vgcreate VG /dev/sde1 /dev/sdf1
  2. Create the origin volume. This example creates an origin volume named lv that is 4G in size and that consists of /dev/sde1, the slow physical volume.
    # lvcreate -L 4G -n lv VG /dev/sde1
  3. Create the cache data logical volume. This logical volume will hold data blocks from the origin volume. The size of this logical volume is the size of the cache and will be reported as the size of the cache pool logical volume. This example creates the cache data volume named lv_cache. It is 2G in size and is contained on the fast device /dev/sdf1, which is part of the volume group VG.
    # lvcreate -L 2G -n lv_cache VG /dev/sdf1
  4. Create the cache metadata logical volume. This logical volume will hold cache pool metadata. The ratio of the size of the cache data logical volume to the size of the cache metadata logical volume should be about 1000:1, with a minimum size of 8MiB for the cache metadata logical volume. This example creates the cache metadata volume named lv_cache_meta. It is 12M in size and is also contained on the fast device /dev/sdf1, which is part of the volume group VG.
    # lvcreate -L 12M -n lv_cache_meta VG /dev/sdf1
  5. Create the cache pool logical volume by combining the cache data and the cache metadata logical volumes into a logical volume of type cache-pool. You can set the behavior of the cache pool in this step; in this example the cachemode argument is set to writethrough, which indicates that a write is considered complete only when it has been stored in both the cache pool logical volume and on the origin logical volume.
    When you execute this command, the cache data logical volume is renamed with _cdata appended to the original name of the cache data logical volume, and the cache metadata logical volume is renamed with _cmeta appended to the original name of the cache data logical volume; both of these volumes become hidden.
    # lvconvert --type cache-pool --cachemode writethrough --poolmetadata VG/lv_cache_meta VG/lv_cache
      WARNING: Converting logical volume VG/lv_cache and VG/lv_cache_meta to pool's data and metadata volumes.
      THIS WILL DESTROY CONTENT OF LOGICAL VOLUME (filesystem etc.)
      Converted VG/lv_cache to cache pool.
    # lvs -a -o +devices
      LV               VG  Attr       LSize   Pool Origin Data%  Meta% Cpy%Sync Devices
      lv               VG  -wi-a-----   4.00g                                   /dev/sde1(0)
      lv_cache         VG  Cwi---C---   2.00g                                   lv_cache_cdata(0)
      [lv_cache_cdata] VG  Cwi-------   2.00g                                   /dev/sdf1(0)
      [lv_cache_cmeta] VG  ewi-------  12.00m                                   /dev/sdf1(512)
      [lvol0_pmspare]  VG  ewi-------  12.00m                                   /dev/sde1(1024)
    
  6. Create the cache logical volume by combining the cache pool logical volume with the origin logical volume. The user-accessible cache logical volume takes the name of the origin logical volume. The origin logical volume becomes a hidden logical volume with _corig appended to the original name. You can execute this command when the origin logical volume is in use.
    # lvconvert --type cache --cachepool VG/lv_cache VG/lv
      Logical volume VG/lv is now cached.
    # lvs -a -o +devices
      LV                VG  Attr       LSize   Pool       Origin            Data%  Meta% Cpy%Sync Devices
      lv                VG  Cwi-a-C---   4.00g [lv_cache] [lv_corig] 0.02   2.31  0.00            lv_corig(0)
      [lv_corig]        VG  owi-aoC---   4.00g                                                    /dev/sde1(0)
      [lv_cache]        VG  Cwi---C---   2.00g                              0.02   2.31  0.00     lv_cache_cdata(0)
      [lv_cache_cdata]  VG  Cwi-ao----   2.00g                                                    /dev/sdf1(0)
      [lv_cache_cmeta]  VG  ewi-ao----  12.00m                                                    /dev/sdf1(512)
      [lvol0_pmspare]   VG  ewi-------  12.00m                                                    /dev/sde1(1024)
    
For further information on LVM cache volumes, including additional administrative examples, see the lvmcache(7) man page.
Red Hat logoGithubRedditYoutubeTwitter

Aprender

Pruebe, compre y venda

Comunidades

Acerca de la documentación de Red Hat

Ayudamos a los usuarios de Red Hat a innovar y alcanzar sus objetivos con nuestros productos y servicios con contenido en el que pueden confiar.

Hacer que el código abierto sea más inclusivo

Red Hat se compromete a reemplazar el lenguaje problemático en nuestro código, documentación y propiedades web. Para más detalles, consulte el Blog de Red Hat.

Acerca de Red Hat

Ofrecemos soluciones reforzadas que facilitan a las empresas trabajar en plataformas y entornos, desde el centro de datos central hasta el perímetro de la red.

© 2024 Red Hat, Inc.