Centos 检查磁盘读写性能
启动Tomcat发现deploy war的速度明显变慢, 怀疑磁盘出问题
测试写入
[tomcat@localhost ~]$ dd if=/dev/zero of=kwxgd bs=64k count=4k oflag=dsync
+ records in
+ records out
bytes ( MB) copied, 127.514 s, 2.1 MB/s
测试读取
dd if=kwxgd of=/dev/zero bs=64k count=4k iflag=direct
io状态
[tomcat@localhost ~]$ iostat -x
Linux 2.6.-.el6.x86_64 (localhost.localdomain) 2015年07月02日 _x86_64_( CPU) avg-cpu: %user %nice %system %iowait %steal %idle
0.77 0.00 0.12 0.00 0.00 99.11 Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util
sda 0.01 55.48 0.03 2.42 3.20 463.18 190.22 0.04 14.74 0.69 0.17 avg-cpu: %user %nice %system %iowait %steal %idle
0.00 0.00 0.04 0.04 0.00 99.92 Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util
sda 0.00 0.00 1.00 0.00 16.00 0.00 16.00 0.01 11.00 11.00 1.10
Linux 2.6.-.el6.x86_64 (localhost.localdomain) 2015年07月02日 _x86_64_( CPU) avg-cpu: %user %nice %system %iowait %steal %idle
0.77 0.00 0.12 0.00 0.00 99.11 Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
sda 2.45 3.20 463.21
rrqm/s: 每秒进行 merge 的读操作数目。即 delta(rmerge)/s
wrqm/s: 每秒进行 merge 的写操作数目。即 delta(wmerge)/s
r/s: 每秒完成的读 I/O 设备次数。即 delta(rio)/s
w/s: 每秒完成的写 I/O 设备次数。即 delta(wio)/s
rsec/s: 每秒读扇区数。即 delta(rsect)/s
wsec/s: 每秒写扇区数。即 delta(wsect)/s
rkB/s: 每秒读K字节数。是 rsect/s 的一半,因为每扇区大小为512字节。(需要计算)
wkB/s: 每秒写K字节数。是 wsect/s 的一半。(需要计算)
avgrq-sz: 平均每次设备I/O操作的数据大小 (扇区)。delta(rsect+wsect)/delta(rio+wio)
avgqu-sz: 平均I/O队列长度。即 delta(aveq)/s/1000 (因为aveq的单位为毫秒)。
await: 平均每次设备I/O操作的等待时间 (毫秒)。即 delta(ruse+wuse)/delta(rio+wio)
svctm: 平均每次设备I/O操作的服务时间 (毫秒)。即 delta(use)/delta(rio+wio)
%util: 一秒中有百分之多少的时间用于 I/O 操作,或者说一秒中有多少时间 I/O 队列是非空的。即 delta(use)/s/1000 (因为use的单位为毫秒)
硬盘性能测试
一、安装hdparm
yum install hdparm -y
二、评估读取
SSD 硬盘,请使用hdparm命令进行读取测试。
hdparm -t /dev/xvda
SSH执行以上命令,可使用hdparm评估SSD的读取速率。
“/dev/xvda”指的是对应磁盘的驱动号,请执行“fdisk -l”查看
# 测试随机写IOPS,运行以下命令:
fio -direct= -iodepth= -rw=randwrite -ioengine=libaio -bs=4k -size=1G -numjobs= -runtime= -group_reporting -filename=iotest -name=Rand_Write_Testing # 测试随机读IOPS,运行以下命令:
fio -direct= -iodepth= -rw=randread -ioengine=libaio -bs=4k -size=1G -numjobs= -runtime= -group_reporting -filename=iotest -name=Rand_Read_Testing # 测试顺序写吞吐量,运行以下命令:
fio -direct= -iodepth= -rw=write -ioengine=libaio -bs=1024k -size=1G -numjobs= -runtime= -group_reporting -filename=iotest -name=Write_PPS_Testing # 测试顺序读吞吐量,运行以下命令:
fio -direct= -iodepth= -rw=read -ioengine=libaio -bs=1024k -size=1G -numjobs= -runtime= -group_reporting -filename=iotest -name=Read_PPS_Testing
下表以测试随机写IOPS的命令为例,说明命令中各种参数的含义。
-direct= 表示测试时忽略I/O缓存,数据直写。
-iodepth= 表示使用AIO时,同时发出I/O数的上限为128。
-rw=randwrite 表示测试时的读写策略为随机写(random writes)。作其它测试时可以设置为: randread(随机读random reads)
read(顺序读sequential reads)
write(顺序写sequential writes)
randrw(混合随机读写mixed random reads and writes) -ioengine=libaio 表示测试方式为libaio(Linux AIO,异步I/O)。应用程序使用I/O通常有两种方式: 同步 同步的I/O一次只能发出一个I/O请求,等待内核完成才返回。这样对于单个线程iodepth总是小于1,但是可以透过多个线程并发执行来解决。通常会用16−32根线程同时工作将iodepth塞满。
异步 异步的I/O通常使用libaio这样的方式一次提交一批I/O请求,然后等待一批的完成,减少交互的次数,会更有效率。 -bs=4k 表示单次I/O的块文件大小为4 KB。未指定该参数时的默认大小也是4 KB。 测试IOPS时,建议将bs设置为一个比较小的值,如本示例中的4k。 测试吞吐量时,建议将bs设置为一个较大的值,如本示例中的1024k。
-size=1G 表示测试文件大小为1 GiB。
-numjobs= 表示测试线程数为1。
-runtime= 表示测试时间为1000秒。如果未配置,则持续将前述-size指定大小的文件,以每次-bs值为分块大小写完。
-group_reporting 表示测试结果里汇总每个进程的统计信息,而非以不同job汇总展示信息。
-filename=iotest 指定测试文件的名称,比如iotest。测试裸盘可以获得真实的硬盘性能,但直接测试裸盘会破坏文件系统结构,请在测试前提前做好数据备份。
-name=Rand_Write_Testing 表示测试任务名称为Rand_Write_Testing,可以随意设定。
关于fdisk磁盘信息
Command (m for help): p
Disk /dev/sdc: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 33553920 bytes
Disklabel type: gpt
Disk identifier: 249AFED8-1A62-461E-9A07-23B686A34DF4 Command (m for help): n
Partition number (1-128, default 1):
First sector (34-976773134, default 2048):
关于logical sector size 和 physical sector size的说明:
- The physical_block_size is the minimal size of a block the drive is able to write in an atomic operation.
- The logical_block_size is the smallest size the drive is able to write (cf. the linux kernel documentation).
The logical sector size being smaller than the physical sector size is normal for most modern disks. This is simply how Advanced Format disks are most often implemented. Some external disks use the same (4096-byte) sector size for both physical and logical sectors, and I've heard that some high-end internal disks now do the same, but most disks these days are Advanced Format models with 512-byte logical sectors and 4096-byte physical sectors. There's nothing you can (or should try to) do about this.
关于First sector default 2048的说明:
Most modern disk drives need a partition to be aligned on sector 2048 to avoid writes overlapping two sectors, but for a long time the sector 63 was used by the fdisk utility and distro's installers by default. This can cause severe performance issues on modern disks. Often they will try to cover up for it in firmware, which means the issue will be still there, but the pain will be just low enough to not really find out whats wrong.
The best solution is to use either GPT/EFI partitions or switch to using LVM since partitions have been an outdated concept for many years now.
On modern distros like Ubuntu the fdisk utility is patched to default to 2048 sectors. You need to use sector 63? In fact it does not even allowed doing it wrong anymore
Centos 检查磁盘读写性能的更多相关文章
- DD测磁盘读写性能
1.测试磁盘的纯写入性能 dd if=/dev/zero of=/file [oracle@11g ~]$ touch ddTest[oracle@11g ~]$ time dd if=/dev/ze ...
- linux磁盘读写性能优化
在LINUX系统中,如果有大量读请求,默认的请求队列或许应付不过来,我们可以 动态调整请求队列数来提高效率,默认的请求队列数存放在/sys/block/xvda/queue/nr_requests 文 ...
- centos文件/文件夹操作-检查磁盘、内存、cpu使用情况-vi操作命令
Part1:CentOS文件/文件夹操作 1.新建文件夹 即创建目录 mkdir 文件名 新建一个名为test的文件夹在home下 vi source1 mkdir /home/test 注意:当创建 ...
- 检查 Linux 服务器性能
如何用十条命令在一分钟内检查 Linux 服务器性能 如果你的Linux服务器突然负载暴增,报警短信快发爆你的手机,如何在最短时间内找出Linux性能问题所在?来看Netflix性能工程团队的这篇博文 ...
- 检查Linux服务器性能的关键十条命令
检查Linux服务器性能的关键十条命令 概述 通过执行以下命令,可以在1分钟内对系统资源使用情况有个大致的了解. uptime dmesg | tail vmstat 1 mpstat -P ALL ...
- [转帖]如何用十条命令在一分钟内检查 Linux 服务器性能
如何用十条命令在一分钟内检查 Linux 服务器性能 时间:2016-09-28 作者:admin 分类:新手入门 阅读:246次 http://embeddedlinux.org.cn/emb- ...
- 磁盘IO性能优化-实践
RAID卡缓存策略调整 原因详解 操作实例 I/O 调度算法 文件系统journal 磁盘挂载参数 操作实例 性能数据对比 RAID卡缓存策略调整 可以将RAID卡缓存策略由No Write Cach ...
- 万字长文详解HBase读写性能优化
一.HBase 读优化 1. HBase客户端优化 和大多数系统一样,客户端作为业务读写的入口,姿势使用不正确通常会导致本业务读延迟较高实际上存在一些使用姿势的推荐用法,这里一般需要关注四个问题: 1 ...
- (转)innodb 与 myisam 读写性能分析
前提: mysql在5.0之前,读写性能相差很大,读性能:myisam 很强 mysql在5.0之后,差距不是很大 http://passover.blog.51cto.com/2431658/507 ...
随机推荐
- 【转】Android NFC学习笔记
一:NFC的tag分发系统 如果想让android设备感应到NFC标签,你要保证两点 1:屏幕没有锁住 2:NFC功能已经在设置中打开 当系统检测到一个NFC标签的时候,他会自动去寻找最合适的acti ...
- 停止运行ExecutorService中的线程
while(true){ try { sleep(1000); } catch (InterruptedException e) { // TODO Auto-generated catch bloc ...
- iOS开发-生成随机数
有时候我们需要在程序中生成随机数,但是在Objective-c中并没有提供相应的函数,好在C中提供了rand().srand().random().arc4random()几个函数.那么怎么使用呢?下 ...
- iOS如何获取网络图片(一)
static NSString * baseUrl = @"http://192.168.1.123/images/"; - (UITableViewCell *)tableVie ...
- iOS 学习 - 14.本地联系人
苹果在iOS9的SDK中废除了AddressBookUI.framework的一些功能(是不是这个库都废除了,有待验证),具体和保存联系人相关的几个系统界面如下:联系人选择:AddressBookUI ...
- 6、软件配置工程师要阅读的书籍 - IT软件人员书籍系列文章
软件配置管理工程师的工作也是贯穿整个项目过程的.其主要针对项目中的各种文档.技术源码等等进行归档控制.一般的配置项比如需求说明书,概要设计,详细设计,测试文档,用户手册等,还有源代码管理,数据库文档文 ...
- fillStyle线性渐变
废话小说,沾待马 <!DOCTYPE HTML> <head> <meta charset = "utf-8"> <title>ca ...
- javascript-抽象工厂模式
抽象工厂模式笔记 1.抽象工厂模式创建多个抽象类,创建出的结果是一个类簇(这里是抽象类的集合) 2.抽象工厂中传入的父类是否是抽象工厂方法创建的抽象类进行判断,不是则抛出错误 3.子类通过 ...
- 一个经典实用的iptables shell脚本
PS:这个iptables脚本不错,很实用,根据实际应用改一下就可以自己用.分享出来,供大家来参考.原作者佚名.源代码如下: #!/bin/sh # modprobe ipt_MASQUERADE m ...
- 如何编译ReactNative示例程序Examples
通过示例程序可以看到一些基本组件的使用,对于学习ReactNative是很有帮助的. 编译示例程序需要将整个项目导入到androidStudio中,androidStudio导入项目时选择react- ...