参考:
flashcache和bcache的性能比较
看起来似乎bcache要更好一些
适用的场景:离散读写较多的情况
安装:
- <p style="margin: 8px 0px; font-family: Helvetica,;" hiragino="" sans="" yahei=""><span style="line-height: 25.6px;">yum install dkms gcc make
- yum-utils kernel-devel -y</span></p><p>
- </p><p style="margin: 8px 0px; font-family: Helvetica,;" hiragino="" sans="" yahei=""><span style="line-height: 25.6px;">
- yum -y install dkms
- gcc make yum-utils kernel kernel-devel git make gcc-c++ device-mapper</span></p><p>
- </p><p style="margin: 8px 0px; font-family: Helvetica,;" hiragino="" sans="" yahei=""><span style="line-height: 25.6px;">
- yum -y install
- unifdef.x86_64</span></p>
复制代码
获取源码
- <p style="margin: 8px 0px; font-family: Helvetica,;" hiragino="" sans="" yahei=""><span style="line-height: 25.6px;"><wbr>wget "<a href="https://github.com/facebookarchive/flashcache/archive/3.1.2.zip"><font color="#0066cc">https://github.com/facebookarchive/flashcache/archive/3.1.2.zip"</font></a></span></p><p>
- </p><p style="margin: 8px 0px; font-family: Helvetica,;" hiragino="" sans="" yahei="">unzip flashcache-master.zip</p><p>
- </p><p style="margin: 8px 0px; font-family: Helvetica,;" hiragino="" sans="" yahei=""> <wbr>cd flashcache-master</p>
复制代码
--编译安装
- <p style="margin: 8px 0px; font-family: Helvetica,;" hiragino="" sans="" yahei=""><wbr>make
- KERNEL_TREE=/usr/src/kernels/2.6.32-431.el6.x86_64/</p><p>
- </p><p style="margin: 8px 0px; font-family: Helvetica,;" hiragino="" sans="" yahei=""> <wbr>make install</p>
复制代码
加载模块:
modprobe flashcache
检查:
dmesg | tail
创建设备:
1、原数据盘为/dev/sda5 , 作为缓存的ssd盘在/dev/sdb1
盘必须不在使用,所以已经挂载的盘需要先卸载
umount /data
2、对ssd 盘进行分区
fdisk /dev/ssd
做一个分区
3、建立带cache的虚拟盘
flashcache_create -p back cachedev /dev/sdb1 /dev/sda5
fdisk -l 可以看到如下的设备:
Disk /dev/mapper/cachedev: 939.2 GB, 939174920192 bytes
255 heads, 63 sectors/track, 114181 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
- <p style="margin: 8px 0px; font-family: Helvetica,;" hiragino="" sans="" yahei="">[root@localhost ~]# lsblk</p><p>
- </p><p style="margin: 8px 0px; font-family: Helvetica,;" hiragino="" sans="" yahei="">NAME <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>
- <wbr>MAJ:MIN RM <wbr> SIZE RO TYPE MOUNTPOINT</p><p>
- </p><p style="margin: 8px 0px; font-family: Helvetica,;" hiragino="" sans="" yahei="">sdb <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>
- <wbr> 8:16 <wbr> 0 447.1G <wbr>0 disk <wbr></p><p>
- </p><p style="margin: 8px 0px; font-family: Helvetica,;" hiragino="" sans="" yahei="">└─sdb1 <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>
- <wbr>8:17 <wbr> 0 447.1G <wbr>0 part <wbr></p><p>
- </p><p style="margin: 8px 0px; font-family: Helvetica,;" hiragino="" sans="" yahei=""> <wbr> └─cachedev (dm-0) 253:0 <wbr> <wbr>0 874.7G <wbr>0
- dm <wbr> <wbr></p><p>
- </p><p style="margin: 8px 0px; font-family: Helvetica,;" hiragino="" sans="" yahei="">sda <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>
- <wbr> 8:0 <wbr> <wbr>0 931.5G <wbr>0 disk <wbr></p><p>
- </p><p style="margin: 8px 0px; font-family: Helvetica,;" hiragino="" sans="" yahei="">├─sda1 <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>
- <wbr>8:1 <wbr> <wbr>0 <wbr> 200M <wbr>0 part /boot</p><p>
- </p><p style="margin: 8px 0px; font-family: Helvetica,;" hiragino="" sans="" yahei="">├─sda2 <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>
- <wbr>8:2 <wbr> <wbr>0 <wbr>48.8G <wbr>0 part /</p><p>
- </p><p style="margin: 8px 0px; font-family: Helvetica,;" hiragino="" sans="" yahei="">├─sda3 <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>
- <wbr>8:3 <wbr> <wbr>0 <wbr> 7.8G <wbr>0 part [SWAP]</p><p>
- </p><p style="margin: 8px 0px; font-family: Helvetica,;" hiragino="" sans="" yahei="">├─sda4 <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>
- <wbr>8:4 <wbr> <wbr>0 <wbr> <wbr> 1K <wbr>0 part <wbr></p><p>
- </p><p style="margin: 8px 0px; font-family: Helvetica,;" hiragino="" sans="" yahei="">└─sda5 <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>
- <wbr>8:5 <wbr> <wbr>0 874.7G <wbr>0 part <wbr></p><p>
- </p><p style="margin: 8px 0px; font-family: Helvetica,;" hiragino="" sans="" yahei=""> <wbr> └─cachedev (dm-0) 253:0 <wbr> <wbr>0 874.7G <wbr>0
- dm <wbr> <wbr></p><p>
- </p><p style="margin: 8px 0px; font-family: Helvetica,;" hiragino="" sans="" yahei="">sr0 <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>
- <wbr>11:0 <wbr> <wbr>1 <wbr>1024M <wbr>0 rom </p>
复制代码
flashcache_create -p back cachedev /dev/sdb1 /dev/sda5
查看信息:
dmsetup status cachedev
dmsetup table cachedev
dmsetup info cachedev
4、参数优化:
sysctl -a |grep flashcache 可以查看到所有的参数
- <p style="margin: 8px 0px; font-family: Helvetica,;" hiragino="" sans="" yahei="">vi /etc/sysctl.conf</p><p>
- </p><p style="margin: 8px 0px; font-family: Helvetica,;" hiragino="" sans="" yahei="">dev.flashcache.sdb1+sda5.reclaim_policy = 1</p><p>
- </p><p style="margin: 8px 0px; font-family: Helvetica,;" hiragino="" sans="" yahei="">dev.flashcache.sdb1+sda5.fast_remove = 0</p><p>
- </p><p style="margin: 8px 0px; font-family: Helvetica,;" hiragino="" sans="" yahei="">dev.flashcache.sdb1+sda5.new_style_write_merge = 1</p><p>
- </p><p style="margin: 8px 0px; font-family: Helvetica,;" hiragino="" sans="" yahei="">dev.flashcache.sdb1+sda5.skip_seq_thresh_kb = 256</p>
复制代码
sysctl -p
|