Red Hat Training
A Red Hat training course is available for RHEL 8
11.4. 使用 cachepool 为逻辑卷启用 dm-cache 缓存
这个过程可让您单独创建缓存数据和缓存元数据逻辑卷,然后将卷合并到缓存池中。
先决条件
-
您希望使用
dm-cache
加快的逻辑卷存在于系统中。 - 包含较慢逻辑卷的卷组还包含在快速块设备中未使用的物理卷。
流程
在快速设备中创建
cachepool
卷:# lvcreate --type cache-pool --size <cachepool-size> --name <fastpool> <vg /dev/fast>
替换以下值:
cachepool-size
-
cachepool
的大小,如5G
fastpool
-
cachepool
卷的名称 vg
- 卷组名称
/dev/fast
到快速块设备的路径,如
/dev/sdf1
注意您可以使用
--poolmetadata
选项指定创建 cache-pool 时池元数据的位置。例 11.3. 创建一个
cachepool
卷# lvcreate --type cache-pool --size 5G --name fastpool vg /dev/sde Logical volume "fastpool" created.
将
cachepool
附加到主逻辑卷中开始缓存:# lvconvert --type cache --cachepool <fastpool> <vg/main>
替换以下值:
fastpool
-
cachepool
卷的名称 vg
- 卷组名称
main
较慢的逻辑卷名称
例 11.4. 将
cachepool
附加到主 LV# lvconvert --type cache --cachepool fastpool vg/main Do you want wipe existing metadata of cache pool vg/fastpool? [y/n]: y Logical volume vg/main is now cached.
验证步骤
检查具有
cache-pool
类型的新创建的设备卷:# lvs --all --options +devices <vg> LV Pool Type Devices [fastpool_cpool] cache-pool fastpool_pool_cdata(0) [fastpool_cpool_cdata] linear /dev/sdf1(4) [fastpool_cpool_cmeta] linear /dev/sdf1(2) [lvol0_pmspare] linear /dev/sdf1(0) main [fastpoool_cpool] cache main_corig(0) [main_corig] linear /dev/sdf1(O)
其他资源
-
lvcreate(8)
手册页 -
lvmcache (7)
手册页 -
lvconvert(8)
手册页