Flashcache基本使用及注意事项
Flashcache基本使用及注意事项
安装方法
Contents [hide]
|
1
2
3
|
rpm --import http://elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh http://elrepo.org/elrepo-release-6-5.el6.elrepo.noarch.rpm
yum install flashcache-utils kmod-flashcache
|
2.源码安装
|
1
2
3
4
5
6
|
rpm -ivh http://mirrors.ustc.edu.cn/centos/6.5/os/x86_64/Packages/kernel-headers-2.6.32-431.el6.x86_64.rpm
rpm -ivh http://mirrors.ustc.edu.cn/centos/6.5/os/x86_64/Packages/kernel-devel-2.6.32-431.el6.x86_64.rpm
wget https://github.com/facebook/flashcache/archive/3.1.2.tar.gz
tar xf 3.1.2.tar.gz
cd flashcache-3.1.2
make && make install
|
自动加载模块
开机自动加载模块配置:
|
1
2
3
4
5
6
7
8
|
vim /etc/sysconfig/modules/flashcache.modules
#! /bin/sh
/sbin/modinfo -F filename flashcache > /dev/null 2>&1
if [ $? -eq 0 ]; then
/sbin/modprobe flashcache
fi
chmod +x /etc/sysconfig/modules/flashcache.modules
|
模块的自动加载最好不要采用写入/etc/rc.local的方式
|
1
2
3
4
5
6
7
8
9
10
|
##加载flashcache模块
modprobe flashcache
##查看flashcache模块是否加载
[root@localhost ~]# lsmod |grep flashcache
flashcache 92068 0
dm_mod 84209 14 flashcache,dm_mirror,dm_log
##删除flashcache模块
rmmod flashcache
|
创建Flashcache
|
1
|
flashcache_create -p back -b 4k cachedev /dev/sdc /dev/sdb2
|
生成/dev/mapper/cachedev设备
指定flashcache的block大小与Percona的page大小相同,一般默认
flashcache_create相关参数说明:
-p:缓存模式 writeback(数据先写到SSD,随后写到普通硬盘),
writethrough(数据同时写到SSD和普通硬盘),
writearound(数据绕过SSD,直接写到普通硬盘)三种,三种模式的所有读都会被缓存到flashcache可以通过dev.flashcache.<cachedev>.cache_all参数调整
-s:缓存大小,可选项,如果未指定则整个SSD设备被用于缓存,默认的计数单位是扇区(sectors),但是可以接受k/m/g单位。
-b:指定块大小,可选项,默认为4KB,必须为2的指数。默认单位为扇区。也可以用K作为单位,一般选4KB。
-f:强制创建,不进行检查
-m:设备元数据块大小,只有writeback需要存储metadata块,默认4K
查看帮助
|
1
2
3
4
|
[root@localhost ~]# flashcache_create
Usage: flashcache_create [-v] [-p back|thru|around] [-b block size] [-m md block size] [-s cache size] [-a associativity] cachedev ssd_devname disk_devname
Usage : flashcache_create Cache Mode back|thru|around is required argument
Usage : flashcache_create Default units for -b, -m, -s are sectors, or specify in k/M/G. Default associativity is 512
|
其他帮助参考flashcache源码目录下的man目录
加载缓存设备
|
1
|
flashcache_load /dev/sdc cachedev (系统重启时使用来加载已经创建过的缓存设备cachedev)
|
加载已存在的flashcache操作仅用于writeback模式,writethrough和writearound模式重启机器后需要重新使用flashcache_create创建
使用Flashcache
创建好的flashcache设备是块设备,可格式文件系统后挂在使用,也可以继续对其分区等
mount /dev/mapper/cachedev /data
销毁Flashcache
flashcache_destroy /dev/sdc
这种方式删除writeback模式的flashcache时会将SSD上的所有数据删除包括脏数据
建议使用dmsetup命令(device-mapper软件包)删除,会自动将脏数据写入磁盘
dmsetup remove cachedev
Flashcache参数优化
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
[root@localhost ]#sysctl dev.flashcache
dev.flashcache.sdc+sdb2.io_latency_hist = 0
dev.flashcache.sdc+sdb2.do_sync = 0
dev.flashcache.sdc+sdb2.stop_sync = 0
dev.flashcache.sdc+sdb2.dirty_thresh_pct = 20
dev.flashcache.sdc+sdb2.max_clean_ios_total = 4
dev.flashcache.sdc+sdb2.max_clean_ios_set = 2
dev.flashcache.sdc+sdb2.do_pid_expiry = 0
dev.flashcache.sdc+sdb2.max_pids = 100
dev.flashcache.sdc+sdb2.pid_expiry_secs = 60
dev.flashcache.sdc+sdb2.reclaim_policy = 0
dev.flashcache.sdc+sdb2.zero_stats = 0
dev.flashcache.sdc+sdb2.fast_remove = 0
dev.flashcache.sdc+sdb2.cache_all = 1
dev.flashcache.sdc+sdb2.fallow_clean_speed = 2
dev.flashcache.sdc+sdb2.fallow_delay = 900
dev.flashcache.sdc+sdb2.skip_seq_thresh_kb = 0
dev.flashcache.sdc+sdb2.clean_on_read_miss = 0
dev.flashcache.sdc+sdb2.clean_on_write_miss = 0
dev.flashcache.sdc+sdb2.lru_promote_thresh = 2
dev.flashcache.sdc+sdb2.lru_hot_pct = 75
dev.flashcache.sdc+sdb2.new_style_write_merge = 0
|
参数介绍参考:https://github.com/facebook/flashcache/blob/master/doc/flashcache-sa-guide.txt
针对MySQL作此优化
|
1
2
3
4
5
6
|
dev.flashcache.sdc+sdb2.cache_all = 1 默认值1表示缓存所有,0都不缓存,另外通过进程黑白名单控制
dev.flashcache.sdc+sdb2.reclaim_policy = 1 缓存回收策略,0:FIFO,1:LRU,可动态调整
dev.flashcache.sdbc+sdb2.fast_remove = 1 0表示不同步脏块到磁盘,1表示同步脏块到磁盘
dev.flashcache.sdc+sdb2.dirty_thresh_pct = 90 每组脏块占有的百分比,过低会减少块覆盖,增加磁盘写操作和读缓存
dev.flashcache.sdc+sdb2.new_style_write_merge = 1 打开写入合并,提升写磁盘的性能(旧版本dev.flashcache.sdc+sdb2.write_merge)
dev.flashcache.sdb1+sda6.skip_seq_thresh_kb = 256 表示不缓存超过256kb的顺序IO(由于SSD的随机读写比SAS好,但顺序读写相差不大,故作此优化)
|
Flashcache开机启动
flashcache模块自动加载–flashcache设备自动加载flashcache_load /dev/sdc cachedev
A.模块自动加载请参考安装部分
B.开机自动加载已创建的缓存设备及挂载
|
1
2
3
4
5
6
7
8
9
10
|
cd /usr/src/flashcache-3.1.2/utils
cp flashcache /etc/init.d/
chmod +x /etc/init.d/flashcache
修改/etc/init.d/flashcache
SSD_DISK= /dev/sdc
BACKEND_DISK= /dev/sdb2
CACHEDEV_NAME= cachedev
MOUNTPOINT= /data
FLASHCACHE_NAME=sdc+sdb2
chkconfig flashcache on
|
Flashcache状态监控
|
1
2
3
4
5
6
7
8
9
10
|
dmsetup status cachedev
dmsetup table cachedev
错误日志报告
/proc/flashcache/sdc+sdb2/flashcache_errors
状态报告
/proc/flashcache/sdc+sdb2/flashcache_stats
亦可使用flashstat命令实时查看
|
到此flashcache的基本使用就是这样,看了网上很多资料都是各种抄袭,不凡错误的,最后还是读了官方的帮助,总结出自己的以便以后使用;
后续要做的就是增加了SSD缓存后,要观察SSD的使用情况及缓存命中率等在逐渐调试优化,下一篇增加MySQL数据库从系统/MySQL方面的一些优化总结和大家分享,请继续关注
推荐IO测试工具
fio、iozone 更多参考https://github.com/geekwolf/sa-scripts/blob/master/devops.md
注意事项:
flashcache_create创建了缓存设备之后挂载即可使用,如创建之后使用flashcache_load /dev/sdc cachedev会提示Invalid Flashcache superblock的错误
Flashcache基本使用及注意事项的更多相关文章
- flashcache 介绍
rpm: flashcache-utils-0.0-4.1.el6.x86_64 kmod-flashcache-0.0-3.el6.x86_64 基本介绍: Flashcache是Facebook技 ...
- jQuery UI resizable使用注意事项、实时等比例拉伸及你不知道的技巧
这篇文章总结的是我在使用resizable插件的过程中,遇到的问题及变通应用的奇思妙想. 一.resizable使用注意事项 以下是我在jsfiddle上写的测试demo:http://jsfiddl ...
- Windows Server 2012 NIC Teaming介绍及注意事项
Windows Server 2012 NIC Teaming介绍及注意事项 转载自:http://www.it165.net/os/html/201303/4799.html Windows Ser ...
- TODO:Golang指针使用注意事项
TODO:Golang指针使用注意事项 先来看简单的例子1: 输出: 1 1 例子2: 输出: 1 3 例子1是使用值传递,Add方法不会做任何改变:例子2是使用指针传递,会改变地址,从而改变地址. ...
- app开发外包注意事项,2017最新资讯
我们见过很多创业者,栽在这app外包上.很多创业者对于app外包这件事情不是特别重视,以为将事情交给app外包公司就完事了,实际上不是的.无论是从选择app外包公司还是签订合同.售后维护等各方面都有许 ...
- favicon.ioc使用以及注意事项
1.效果 2.使用引入方法 2.1 注意事项:(把图标命名为favicon.ico,并且放在根目录下,同时使用Link标签,多重保险) 浏览器默认使用根目录下的favicon.ico 图标(如果你并没 ...
- ORACLE分区表梳理系列(二)- 分区表日常维护及注意事项(红字需要留意)
版权声明:本文发布于http://www.cnblogs.com/yumiko/,版权由Yumiko_sunny所有,欢迎转载.转载时,请在文章明显位置注明原文链接.若在未经作者同意的情况下,将本文内 ...
- 【原】Masonry+UIScrollView的使用注意事项
[原]Masonry+UIScrollView的使用注意事项 本文转载请注明出处 —— polobymulberry-博客园 1.问题描述 我想实现的使用在一个UIScrollView依次添加三个UI ...
- 《连载 | 物联网框架ServerSuperIO教程》- 5.轮询通讯模式开发及注意事项。附:网友制作的类库说明(CHM)
1.C#跨平台物联网通讯框架ServerSuperIO(SSIO)介绍 <连载 | 物联网框架ServerSuperIO教程>1.4种通讯模式机制. <连载 | 物联网框架Serve ...
随机推荐
- HTML的报告
import HTMLTestRunner class HTMLReporter(object): def reporter(self,filename,reportername,reporterdi ...
- Python generator 的yield (enumerate)
生成杨辉三角 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 def triangles(max): L = [1,] while len(L) - 1 < ...
- android udp 无法收到数据 (模拟器中)
解决方法:1. 运行模拟器2. 打开window 命令行执行:telnet localhost 55545554是模拟器的端口,执行之后会进入android console3. 在console下执行 ...
- Spring整合jedis 集群模式
引入jedis依赖 <dependency> <groupId>redis.clients</groupId> <artifactId>jedis< ...
- SQL查找指定行的记录
select top 1 * from (select top 4 * from T_GasStationPrice order by EnableTime) a order by EnableTim ...
- 在win8 App中,StorageFile比Path更好用
Skip the path: stick to the StorageFile: http://blogs.msdn.com/b/wsdevsol/archive/2012/12/05/stray-f ...
- viewer.js使用
viewer GitHub 地址: JS 版本:https://github.com/fengyuanchen/viewerjs jQuery 版本:https://github.com/fengyu ...
- hibernate项目
http://blog.csdn.net/wzygis/article/details/22985751
- linux_关闭防火墙
centos6版本 永久关闭 chkconfig iptables off 查看状态 chkconfig iptables --list 此时关闭开机重新启动 service iptables sto ...
- Win8.1无法安装更新,提示0x800*****错误的解决方法
Win8.1无法安装更新,提示0x800*****错误的解决方法 注:本教程同样适用于Win10系统 有时候Win8.1某个系统文件的损坏会导致无法安装Windows更新,表现为Windows更新 ...