bcache on CentOS-7

bcache在3.10开始正式加入内核,但是CentOS 7.3中默认没有编译bcache模块,所以要想使用此功能需要编译bcache.ko.

# 下载kernel源码
wget http://vault.centos.org/7.3.1611/os/Source/SPackages/kernel-3.10.0-514.el7.src.rpm
rpm2cpio ./kernel-3.10.0-514.el7.src.rpm | cpio -idmv
tar -xf linux-3.10.0-514.el7.tar.xz
cd linux-3.10.0-514.el7
cp /boot/config-3.10.0-514.el7.x86_64 .config
修改.config将CONFIG_BCACHE=m加入其中
make -j `grep processor /proc/cpuinfo | wc -l`
make过程中有些提示,直接回车
mkdir /lib/modules/`uname -r`/kernel/drivers/md/bcache/
cp drivers/md/bcache/bcache.ko  /lib/modules/`uname -r`/kernel/drivers/md/bcache/
depmod -A
# 必须-f才能加载
modprobe -f bcache
lsmod |grep bcache
# 开机加载
echo 'modprobe -f bcache' >> /etc/rc.local

或者试试我在centos-7.3上编译的bcache.ko:bcache.zip

yum -y install pkgconfig libblkid-devel
git clone https://github.com/g2p/bcache-tools.git
cd bcache-tools
make && make install

编译安装的bcache-tools没有bcache-status命令1),要使用该命令需要额外操作如下:

# 在前面附件里
cp ./bcache-status /usr/sbin/bcache-status
chmod +x /usr/sbin/bcache-status

将下面的脚本写到/etc/rc.local,CentOS-7.3亲测。

#!/bin/bash
mkdir /lib/modules/`uname -r`/kernel/drivers/md/bcache/
cp /usr/local/bcache.ko /lib/modules/`uname -r`/kernel/drivers/md/bcache/
depmod -A
modprobe -f bcache
echo /dev/disk/by-id/dm-name-INTEL_SSDSC2BB800G6_BTWA611505L5800HGN1 > /sys/fs/bcache/register
echo /dev/vg_data/lv_data > /sys/fs/bcache/register_quiet
mount -U "f05d5339-3d0c-49e7-b156-a0d27a29ea36" /mnt/ovirt
CacheSetUUID=`ls -d /sys/fs/bcache/*-*-* | cut -f5 -d/`
# writeback
echo writeback > /sys/block/bcache0/bcache/cache_mode
# 关闭IO跟踪
echo 0 > /sys/fs/bcache/$CacheSetUUID/congested_read_threshold_us
echo 0 > /sys/fs/bcache/$CacheSetUUID/congested_write_threshold_us
# 开启顺序IO缓存
echo 0 > /sys/block/bcache0/bcache/sequential_cutoff


1)
实际就是一个python脚本,我从fedora26上安装的bcache-tools里提取出来的,修改脚本的解释器为#!/usr/bin/python,不然直接运行会说没有python3.
  • storage/缓存技术/bcache/bcache_on_centos7.txt
  • 最后更改: 2019/04/16 18:31
  • (外部编辑)