磁盘的读写性能压力测试

前言

顺序读写 (吞吐量bw,常用单位为MB/s):文件在硬盘上存储位置是连续的。
适用场景:大文件拷贝(比如视频音乐)。
4K随机读写 (IOPS,常用单位为次):在硬盘上随机位置读写数据,每次4KB。
适用场景:操作系统运行、软件运行、数据库。

测试准备

测试硬盘性能时,建议直接测试裸数据盘(如 /dev/vdb)。
测试文件系统性能时,推荐指定具体文件测试(如 /data/file)。
数据盘的大小要大于指定size的大小,否则会报错.

1.查看是否已经安装FIO

fio
-bash: fio: command not found //未安装
fio-2.2.5 //已经安装

2.如果没有安装,则需要安装FIO.

wget http://brick.kernel.dk/snaps/fio-2.2.5.tar.gz 
yum install libaio-devel
tar -zxvf fio-2.2.5.tar.gz
cd fio-2.2.5
make
make install

开始测试

一.裸盘测试

1.fdisk -l 查看你的磁盘名称型号,一般磁盘都是在/dev下,叫sdb,或者vdb
/dev/vda 是系统盘,有21.5G
有一个系统盘分区是vda1,/dev/vda1 约20G
有一个数据盘 /dev/vdb 42.9G
在这里插入图片描述
2.测试裸盘不需要分区,不需要格式化,不需要挂载,直接利用fio,配合测试脚本进行测试即可.

二.测试文件系统

测试文件系统,一定要注意,测试文件系统容易导致文件系统损坏.所以我们采用dd命令创建一个大文件,读写这个大文件.测试方式和测试裸盘一样.只是filename为这个文件的路径.
首先要分区,格式化,挂载.
如何用dd创建大文件,查看我上一篇文章.

查看硬盘信息:fdisk -l

[root@i-5jauz4g8hoduu9wv8tpuz5ns3 ~]# fdisk -l

Disk /dev/vda: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0008d73a

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048    41943039    20970496   83  Linux

Disk /dev/vdb: 42.9 GB, 42949672960 bytes, 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

磁盘分区

[root@i-5jauz4g8hoduu9wv8tpuz5ns3 ~]# fdisk /dev/vdb                                                      
Welcome to fdisk (util-linux 2.23.2).                                                                     
                                                                                                          
Changes will remain in memory only, until you decide to write them.                                       
Be careful before using the write command.                                                                
                                                                                                          
Device does not contain a recognized partition table                                                      
Building a new DOS disklabel with disk identifier 0x57a611b9.                                             
                                                                                                          
Command (m for help): n                                                                                   
Partition type:                                                                                           
   p   primary (0 primary, 0 extended, 4 free)                                                            
   e   extended                                                                                           
Select (default p):                                                                                       
Using default response p                                                                 
  • 1
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值