0%

Centos安装Flashcache使用SSD缓存[zt]

Flashcache是Facebook技术团队开发的一个内核模块,通过在文件系统(VFS)和设备驱动之间新增一次缓存层,可以用SSD作为介质的缓存,通过将传统硬盘上的热门数据缓存到SSD上,加速服务器磁盘读写性能。

flashcache

Centos5.7下安装Flashcache,查看系统及内核版本:

1
2
$ uname -a
Linux master.onovps.com 2.6.18-274.17.1.el5 #1 SMP Tue Jan 10 17:25:58 EST 2012 x86_64 x86_64 x86_64 GNU/Linux
1
2
$ cat /etc/issue
CentOS release 5.7 (Final)

下载安装内核源码树:

1
2
3
4
5
6
7
#http://www.onovps.com

yum install rpm-build redhat-rpm-config unifdef
lftp -c "pget -n 10 http://vault.centos.org/5.7/os/SRPMS/kernel-2.6.18-274.el5.src.rpm"
rpm -i kernel-2.6.18-274.el5.src.rpm
cd /usr/src/redhat/SPECS/
rpmbuild -bp --target=$(uname -m) kernel.spec

内核模块编译准备:

1
2
3
4
cd /usr/src/redhat/BUILD/kernel-2.6.18/linux-2.6.18-274.*
make oldconfig
make prepare
make modules_prepare

下载编译Flashcache:

1
2
3
4
wget --no-check-certificate -O flashcache.tar.gz https://github.com/facebook/flashcache/tarball/master
tar zxvf flashcache.tar.gz
cd facebook-flashcache-c4bddf6/
make install

加载Flashcache模块:

1
2
3
4
insmod /lib/modules/2.6.18-274.17.1.el5/extra/flashcache/flashcache.ko
lsmod |grep flashcache
flashcache 112320 0
dm_mod 102289 12 flashcache,dm_multipath,dm_raid45,dm_snapshot,dm_zero,dm_mirror,dm_log

创建Flashcache卷:

1
flashcache_create [-v] [-p back|thru|around] [-b block size] [-m md block size] [-s cache size] [-a associativity] cachedev ssd_devname disk_devname

挂载Flashcache卷:

1
mount /dev/mapper/cachedev /home/wwwroot/

via.http://blog.onovps.com/archives/centos-flashcache.html