磁盘IO性能优化-实践
RAID卡缓存策略调整
可以将RAID卡缓存策略由No Write Cache if bad BBU调整为Write Cache OK if bad BBU,即在电池充放电时不关闭缓存,以此保证I/O性能。但是此法存在数据丢失风险,需要合理评估再做调整。
原因详解
服务器的Riad卡都带有可充电电池,这块可充电电池在不使用时也会有微弱的放电现象,当它的电量放电到低到一定程度时,Raid卡控制器就会对电池进行一次“放电”,将剩余的电量放掉,然后再进行一次“充电”。这其实是一种对电池保护机制,以及对Raid卡可用性提供保障的机制。
默认情况下,当RAID卡的电池的电量低于某阈值时,RAID卡固件认为此时的电池是不可用的,为了保证数据的安全,会禁用RAID的“缓存”,这种默认的机制本来是合理的,但是当RAID的缓存被禁用之后,RAID的I/O能力会大幅度下降。一般情况下,这个充放电(放电->充电)的时间可能会持续几个小时,对于I/O密集型的应用来说,由此带来的性能下降有可能是致命的,可能会导致系统I/O延迟增大、队列堆积、拖慢甚至有可能拖垮整个系统。
有两种方法解决这个问题:
注:下文中的操作适用于基于LSI的MegaRAID卡的服务器。
法一:检查电池的状态,对电池的充放电进行撑握,也可有计划地安排手动充放电。
一般服务器的RAID卡电池充放电周期为90天(具体周期可以通过下文的命令进行查看确认),然后在快接近下次充电的时候,选择在业务低谷时间手动强制充放电;以此避免因RAID卡电池在未知时间做充放电操作带来的性能隐患。
查看电池充放电周期:
MegaCli -AdpBbuCmd -getBbuProperties -aALL|egrep 'Period|Next'
输出样例:
Auto Learn Period: 27 Days
Next Learn time: Tue Sep 18 05:52:27 2018
手动强制充放电:
MegaCli -AdpBbuCmd -BbuLearn –a0
法二:改变RAID卡策略,使其在充放电时,不禁用Raid卡缓存。
这样做电池在自动充放电的时候,就不会关闭写缓存,I/O的性能不会下降;但是,假如在此时服务器断电,Raid卡缓存中的数据会来不及写进磁盘,从而造成数据的丢失;在RAID卡电池充放电的时候刚好遇到服务器断电的概率应该是很低的,但这确实是一个风险点,需要合理评估;对于DB类对数据安全性要求高的应用需要谨慎使用,对于I/O吞吐要求高但是对数据一致性要求不是非常苛刻的场景是非常建议做此调整的。
查看Raid卡当前的缓存策略:
MegaCli -LDGetProp -Cache -LAll -aAll
输出样例
Adapter 0-VD 0(target id: 0): Cache Policy:WriteBack, ReadAhead, Cached, No Write Cache if bad BBU
Adapter 0-VD 1(target id: 1): Cache Policy:WriteBack, ReadAhead, Cached, No Write Cache if bad BBU
Adapter 0-VD 2(target id: 2): Cache Policy:WriteBack, ReadAhead, Cached, No Write Cache if bad BBU
Adapter 0-VD 3(target id: 3): Cache Policy:WriteBack, ReadAhead, Cached, No Write Cache if bad BBU
Adapter 0-VD 4(target id: 4): Cache Policy:WriteBack, ReadAhead, Cached, No Write Cache if bad BBU
Adapter 0-VD 5(target id: 5): Cache Policy:WriteBack, ReadAhead, Cached, No Write Cache if bad BBU
Adapter 0-VD 6(target id: 6): Cache Policy:WriteBack, ReadAhead, Cached, No Write Cache if bad BBU
Adapter 0-VD 7(target id: 7): Cache Policy:WriteBack, ReadAhead, Cached, No Write Cache if bad BBU
Adapter 0-VD 8(target id: 8): Cache Policy:WriteBack, ReadAhead, Cached, No Write Cache if bad BBU
Adapter 0-VD 9(target id: 9): Cache Policy:WriteBack, ReadAhead, Cached, No Write Cache if bad BBU
Adapter 0-VD 10(target id: 10): Cache Policy:WriteBack, ReadAhead, Cached, No Write Cache if bad BBU
Exit Code: 0x00
注:因为此服务器上有11个VD,所以会显示11行,可以看到缓存策略是No Write Cache if Bad BBU,即在电池充放电时关闭缓存。
调整缓存策略,在充放电时不关闭写缓存:
MegaCli -LDSetProp CachedBadBBU -lall -a0
输出样例:
Set Write Cache OK if bad BBU on Adapter 0, VD 0 (target id: 0) success
Set Write Cache OK if bad BBU on Adapter 0, VD 1 (target id: 1) success
Set Write Cache OK if bad BBU on Adapter 0, VD 2 (target id: 2) success
Set Write Cache OK if bad BBU on Adapter 0, VD 3 (target id: 3) success
Set Write Cache OK if bad BBU on Adapter 0, VD 4 (target id: 4) success
Set Write Cache OK if bad BBU on Adapter 0, VD 5 (target id: 5) success
Set Write Cache OK if bad BBU on Adapter 0, VD 6 (target id: 6) success
Set Write Cache OK if bad BBU on Adapter 0, VD 7 (target id: 7) success
Set Write Cache OK if bad BBU on Adapter 0, VD 8 (target id: 8) success
Set Write Cache OK if bad BBU on Adapter 0, VD 9 (target id: 9) success
Set Write Cache OK if bad BBU on Adapter 0, VD 10 (target id: 10) success
确认操作结果,检查Raid卡当前的缓存策略:
Adapter 0-VD 0(target id: 0): Cache Policy:WriteBack, ReadAhead, Cached, Write Cache OK if bad BBU
Adapter 0-VD 1(target id: 1): Cache Policy:WriteBack, ReadAhead, Cached, Write Cache OK if bad BBU
Adapter 0-VD 2(target id: 2): Cache Policy:WriteBack, ReadAhead, Cached, Write Cache OK if bad BBU
Adapter 0-VD 3(target id: 3): Cache Policy:WriteBack, ReadAhead, Cached, Write Cache OK if bad BBU
Adapter 0-VD 4(target id: 4): Cache Policy:WriteBack, ReadAhead, Cached, Write Cache OK if bad BBU
Adapter 0-VD 5(target id: 5): Cache Policy:WriteBack, ReadAhead, Cached, Write Cache OK if bad BBU
Adapter 0-VD 6(target id: 6): Cache Policy:WriteBack, ReadAhead, Cached, Write Cache OK if bad BBU
Adapter 0-VD 7(target id: 7): Cache Policy:WriteBack, ReadAhead, Cached, Write Cache OK if bad BBU
Adapter 0-VD 8(target id: 8): Cache Policy:WriteBack, ReadAhead, Cached, Write Cache OK if bad BBU
Adapter 0-VD 9(target id: 9): Cache Policy:WriteBack, ReadAhead, Cached, Write Cache OK if bad BBU
Adapter 0-VD 10(target id: 10): Cache Policy:WriteBack, ReadAhead, Cached, Write Cache OK if bad BBU
Exit Code: 0x00
注:
缓存策略已经变为Write Cache OK if bad BBU,即在电池充放电时不关闭缓存。
上述调整中是调整了所有的VD,根据不同的场景,我们可以指定VD进行操作。
如果需要将Cache策略修改为原始值,可以通过下面的命令进行操作:
MegaCli -LDSetProp NoCachedBadBBU -lall -a0
操作实例
我们ELK的机器都是2块磁盘RAID1,作为系统盘;10块数据盘做单盘RAID0。我们现在要把系统盘的CachedBadBBU关闭(前面把所有VD的缓存策略都调整为了CachedBadBBU),以保证数据安全性。
# 调整系统盘所在的VD0的缓存策略为NoCachedBadBBU
[root@BJSH-ELK-137-114.meitu-inc.com ~]# MegaCli -LDSetProp NoCachedBadBBU -l0 -a0
Set No Write Cache if bad BBU on Adapter 0, VD 0 (target id: 0) success
Exit Code: 0x00
[root@BJSH-ELK-137-114.meitu-inc.com ~]#
# 查看系统盘所在的VD0
[root@BJSH-ELK-137-114.meitu-inc.com ~]# MegaCli -LDGetProp -Cache -L0 -aAll
Adapter 0-VD 0(target id: 0): Cache Policy:WriteBack, ReadAhead, Cached, No Write Cache if bad BBU
Exit Code: 0x00
# 查看所有VD
[root@BJSH-ELK-137-114.meitu-inc.com ~]# MegaCli -LDGetProp -Cache -LAll -aAll
Adapter 0-VD 0(target id: 0): Cache Policy:WriteBack, ReadAhead, Cached, No Write Cache if bad BBU
Adapter 0-VD 1(target id: 1): Cache Policy:WriteBack, ReadAhead, Cached, Write Cache OK if bad BBU
Adapter 0-VD 2(target id: 2): Cache Policy:WriteBack, ReadAhead, Cached, Write Cache OK if bad BBU
Adapter 0-VD 3(target id: 3): Cache Policy:WriteBack, ReadAhead, Cached, Write Cache OK if bad BBU
Adapter 0-VD 4(target id: 4): Cache Policy:WriteBack, ReadAhead, Cached, Write Cache OK if bad BBU
Adapter 0-VD 5(target id: 5): Cache Policy:WriteBack, ReadAhead, Cached, Write Cache OK if bad BBU
Adapter 0-VD 6(target id: 6): Cache Policy:WriteBack, ReadAhead, Cached, Write Cache OK if bad BBU
Adapter 0-VD 7(target id: 7): Cache Policy:WriteBack, ReadAhead, Cached, Write Cache OK if bad BBU
Adapter 0-VD 8(target id: 8): Cache Policy:WriteBack, ReadAhead, Cached, Write Cache OK if bad BBU
Adapter 0-VD 9(target id: 9): Cache Policy:WriteBack, ReadAhead, Cached, Write Cache OK if bad BBU
Adapter 0-VD 10(target id: 10): Cache Policy:WriteBack, ReadAhead, Cached, Write Cache OK if bad BBU
Exit Code: 0x00
[root@BJSH-ELK-137-114.meitu-inc.com ~]#
I/O 调度算法
目前默认为cfq,算法比较中庸,固态硬盘可调整为noop;针对机械磁盘,不同的应用可以对比测试下deadline等其他调度算法的性能表现。对于数据库等应用,避免饿死的情况,建议调整为deadline。
文件系统journal
文件系统日志,默认开启,可以暂时不做调整。
磁盘挂载参数
为提升磁盘I/O性能,可以考虑将磁盘挂载参数调整为async,noatime,data=writeback,barrier=0,nobh。
参数含义:
async:采用异步I/O
noatime:访问文件不修改文件元信息,提高文件系统读写性能
data=writeback: 启用回写模式,不记录data journal,提高文件系统写入性能
barrier=0:关闭barrier
nobh:关闭buffer_head,防止内核打断大块数据的IO操作
操作实例
调整ELK服务器data目录的此案挂载参数
[root@ELK-133-10 ~]# mount|grep data
/dev/sdc1 on /data1 type xfs (rw,noatime,nodiratime)
/dev/sdd1 on /data2 type xfs (rw,noatime,nodiratime)
/dev/sde1 on /data3 type xfs (rw,noatime,nodiratime)
/dev/sdf1 on /data4 type xfs (rw,noatime,nodiratime)
/dev/sdg1 on /data5 type xfs (rw,noatime,nodiratime)
/dev/sdb1 on /data6 type xfs (rw,noatime,nodiratime,barrier=1)
[root@ELK-133-10 ~]#
# 生成remount命令
[root@ELK-133-10 ~]# mount|grep data|awk '{print "mount "$1" "$3" -o remount,rw,noatime,data=writeback,barrier=0,nobh"}'
mount /dev/sdc1 /data1 -o remount,rw,noatime,data=writeback,barrier=0,nobh
mount /dev/sdd1 /data2 -o remount,rw,noatime,data=writeback,barrier=0,nobh
mount /dev/sde1 /data3 -o remount,rw,noatime,data=writeback,barrier=0,nobh
mount /dev/sdf1 /data4 -o remount,rw,noatime,data=writeback,barrier=0,nobh
mount /dev/sdg1 /data5 -o remount,rw,noatime,data=writeback,barrier=0,nobh
mount /dev/sdb1 /data6 -o remount,rw,noatime,data=writeback,barrier=0,nobh
[root@ELK-133-10 ~]#
# 执行remount命令
[root@ELK-133-10 ~]# mount|grep data|awk '{print "mount "$1" "$3" -o remount,rw,noatime,data=writeback,barrier=0,nobh"}'|bash
[root@ELK-133-10 ~]#
# 确认remount结果
[root@ELK-133-10 ~]# mount|grep data
/dev/sdc1 on /data1 type xfs (rw,noatime,data=writeback,barrier=0,nobh)
/dev/sdd1 on /data2 type xfs (rw,noatime,data=writeback,barrier=0,nobh)
/dev/sde1 on /data3 type xfs (rw,noatime,data=writeback,barrier=0,nobh)
/dev/sdf1 on /data4 type xfs (rw,noatime,data=writeback,barrier=0,nobh)
/dev/sdg1 on /data5 type xfs (rw,noatime,data=writeback,barrier=0,nobh)
/dev/sdb1 on /data6 type xfs (rw,noatime,data=writeback,barrier=0,nobh)
[root@ELK-133-10 ~]#
性能数据对比
(待补充)
磁盘IO性能优化-实践的更多相关文章
- etcd 性能优化实践
https://mp.weixin.qq.com/s/lD2b-DZyvRJ3qWqmlvHpxg 从零开始入门 K8s | etcd 性能优化实践 原创 陈星宇 阿里巴巴云原生 2019-12-16 ...
- 第17 章 : 深入理解 etcd:etcd 性能优化实践
深入理解 etcd:etcd 性能优化实践 本文将主要分享以下五方面的内容: etcd 前节课程回顾复习: 理解 etcd 性能: etcd 性能优化 -server 端: etcd 性能优化 -cl ...
- 性能调优之访问日志IO性能优化
性能调优之访问日志IO性能优化 poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标.如果对课程感兴趣,请大家咨询qq:908821 ...
- Linux如何查看与测试磁盘IO性能
1. 查看磁盘 IO 性能 1.1 top 命令 top 命令通过查看 CPU 的 wa% 值来判断当前磁盘 IO 性能,如果这个数值过大,很可能是磁盘 IO 太高了,当然也可能是其他原因,例如网络 ...
- 让Elasticsearch飞起来!——性能优化实践干货
原文:让Elasticsearch飞起来!--性能优化实践干货 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog ...
- 018 磁盘 IO 性能监控/压测工具(sar、iotop、fio、iostat)
1 sar 命令查看当前磁盘 IO 读写 sar(System Activity Reporter 系统活动情况报告)是 Linux 上最为全面的系统性能分析工具之一,可以从多方面对系统的活动进行报告 ...
- 直播推流端弱网优化策略 | 直播 SDK 性能优化实践
弱网优化的场景 网络直播行业经过一年多的快速发展,衍生出了各种各样的玩法.最早的网络直播是主播坐在 PC 前,安装好专业的直播设备(如摄像头和麦克风),然后才能开始直播.后来随着手机性能的提升和直播技 ...
- 手游录屏直播技术详解 | 直播 SDK 性能优化实践
在上期<直播推流端弱网优化策略 >中,我们介绍了直播推流端是如何优化的.本期,将介绍手游直播中录屏的实现方式. 直播经过一年左右的快速发展,衍生出越来越丰富的业务形式,也覆盖越来越广的应用 ...
- 磁盘IO性能监控(Linux 和 Windows)
磁盘IO性能监控(Linux 和 Windows) 作者:终南 <li.zhongnan@hotmail.com> 磁盘的IO性能是衡量计算机总体性能的一个重要指标.Linux提供了i ...
随机推荐
- vue根据参数不同的路由跳转以及name的作用
最近在做VUE路由跳转根据参数的值不同但是跳转的是同一个路由的功能.点击左边的目录,根据目录ID跳转不同的列表.如下图. 路由跳转的代码: this.$router.push({path: '/RFI ...
- 【HTTP/FTP客户端库】
[HTTP/FTP客户端库]资料来源:http://curl.haxx.se/libcurl/competitors.html Free Software and Open Source projec ...
- 解决Python print输出不换行没空格的问题
今天在做编程题的时候发现Python的print输出默认换行输出,并且输出后有空格. 题目要求输出 122 而我的输出是: 1 2 2 于是我百度查到取消print自动换行的方法:就是在print的值 ...
- jquery版本轮播图(es5版本,兼容高)
优势:基于es5,兼容高.切换动画css配置,轻量,不包含多余代码,可扩展性很高,多个轮播图不会冲突,可配置独有namespace 注: 1.项目需要所写,所以只写了页码的切换,未写上一页下一页按钮, ...
- 用JS实现快速排序
"快速排序"的思想很简单,整个排序过程只需要三步: (1)在数据集之中,选择一个元素作为"基准"(pivot). (2)所有小于"基准"的元 ...
- Quaternions 四元数
四元数是一个乱七八糟得到东西还没搞懂搞懂后再补 先添加unity API transform.rotation 是Quaternionlei类并非Vector3向量 不能进行直接转化 那如何将Vect ...
- HTML5——新表单元素 表单属性 语义元素
表单元素 新的表单元素 datalist——输入域选项列表 keygen——提供一种验证用户的可靠方法 output——不同类型的输出,比如计算或脚本输出 表单属性 <form> / &l ...
- 安装docker-下载加速、失败、成功安装
前提:已装VMware虚拟机和Centos系统(具体安装包和过程可以百度) 先看这里:非root身份登录系统需要在下面的命令前加“sudo ”(sudo:代表给权限,用root登录则不需要输入) 一. ...
- Springboot2.x集成Redis集群模式
Springboot2.x集成Redis集群模式 说明 Redis集群模式是Redis高可用方案的一种实现方式,通过集群模式可以实现Redis数据多处存储,以及自动的故障转移.如果想了解更多集群模式的 ...
- Coding 地址
Coding 连接 https://dev.tencent.com/u/leexi