性能测试(CPU、内存、IO)
~~~~~~CPU~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~CPU指标为运算处理能力一、cat /ptoc/cpuinfo
1、直接查看逻辑CPU的个数,执行:cat /proc/cpuinfo |grep 'physical id' |sort |uniq结果:记录2、直接查看CPU的型号,执行:cat /proc/cpuinfo |grep 'model name' |sort |uniq结果:记录3、单个CPU的内核数,执行:cat /proc/cpuinfo |grep 'cpu cores' |sort |uniq结果:记录4、总的CPU线程数,执行:cat /proc/cpuinfo |grep 'processor'结果:记录二、使用Super PI
是利用CPU的浮点运算能力来计算出π(圆周率),所以目前普遍被超频玩家用做测试系统稳定性和测试CPU计算完后特定位数圆周率所需的时间。wget http://superpi.ilbello.com/pi/super_pi.tar.bz2tar -jxvf super_pi.tar.bz2./super_pi 2020为位数。表示要算2的多少次方位,如通常要算小数点后1M位。结果:
root@localhost.example. ~# ./super_pi 20 Version 2.0 of the super_pi for Linux OS Fortran source program was translated into C program with version 19981204 of f2c, then generated C source program was optimized manually. pgcc 3.2-3 with compile option of "-fast -tp px -Mbuiltin -Minline=size:1000 -Mnoframe -Mnobounds -Mcache_align -Mdalign -Mnoreentrant" was used for the compilation. ------ Started super_pi run : Tue May 16 10:47:18 CST 2017 Start of PI calculation up to 1048576 decimal digits End of initialization. Time= 0.200 Sec. I= 1 L= 0 Time= 0.498 Sec. I= 2 L= 0 Time= 0.539 Sec. I= 3 L= 1 Time= 0.536 Sec. I= 4 L= 2 Time= 0.535 Sec. I= 5 L= 5 Time= 0.532 Sec. I= 6 L= 10 Time= 0.537 Sec. I= 7 L= 21 Time= 0.529 Sec. I= 8 L= 43 Time= 0.542 Sec. I= 9 L= 87 Time= 0.532 Sec. I=10 L= 174 Time= 0.582 Sec. I=11 L= 349 Time= 0.974 Sec. I=12 L= 698 Time= 1.379 Sec. I=13 L= 1396 Time= 1.094 Sec. I=14 L= 2794 Time= 1.353 Sec. I=15 L= 5588 Time= 0.955 Sec. I=16 L= 11176 Time= 1.408 Sec. I=17 L= 22353 Time= 1.067 Sec. I=18 L= 44707 Time= 1.242 Sec. I=19 L= 89415 Time= 0.901 Sec. End of main loop End of calculation. Time= 17.033 Sec. End of data output. Time= 0.070 Sec. Total calculation(I/O) time= 17.103( 0.521) Sec. ------ Ended super_pi run : Tue May 16 10:47:36 CST 2017~~~~~~CPU~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~内存~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
内存指标为稳定性free -m (主要是看内存大小、交换空间、高速缓存)结果:记录memtest不但可以彻底的检测出内存的稳定度,还可同时测试记忆的储存与检索数据的能力,让你可以确实掌控到目前你机器上正在使用的内存到底可不可信赖。
wget http://pyropus.ca/software/memtester/old-versions/memtester-4.3.0.tar.gz
tar -xzvf memtester-4.3.0.tar.gzcd memtester-4.3.0make && make install例:./memtester 2048 52048表示测试的内存大小,单位是M,1表示次数。如果2048不接受的,把它缩小就可以了。先运行一次,如果没有问题就把次数增加即可。监控:vmstat、top都可以看到结果:
root@localhost.example. ~/memtester-4.3.0# ./memtester 1024 1memtester version 4.3.0 (64-bit)Copyright (C) 2001-2012 Charles Cazabon.Licensed under the GNU General Public License version 2 (only).pagesize is 4096
pagesizemask is 0xfffffffffffff000want 1024MB (1073741824 bytes)got 1024MB (1073741824 bytes), trying mlock ...locked.Loop 1/1: Stuck Address : ok Random Value : ok Compare XOR : ok Compare SUB : ok Compare MUL : ok Compare DIV : ok Compare OR : ok Compare AND : ok Sequential Increment: ok Solid Bits : ok Block Sequential : ok Checkerboard : ok Bit Spread : ok Bit Flip : ok Walking Ones : ok Walking Zeroes : ok 8-bit Writes : ok 16-bit Writes : okDone.
~~~~~~内存~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~IO~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
一、简介测试IOPS,推荐使用fio(官网地址:http://freshmeat.net/projects/fio/)fio命令说明:filename=/dev/sdb1 #测试文件名称,通常选择需要测试的盘的data目录direct=1 #测试过程绕过机器自带的buffer。使测试结果更真实rw=randwrite #测试随机写的I/Orw=randrw #测试随机写和读的I/Obs=16k #单次io的块文件大小为16kbsrange=512-2048 #同上,提定数据块的大小范围size=5G #本次的测试文件大小为5g,以每次4k的io进行测试numjobs=30 #本次的测试线程为30个runtime=1000 #测试时间1000秒,如果不写则一直将5g文件分4k每次写完为止ioengine=psync #io引擎使用psync方式rwmixwrite=30 #在混合读写的模式下,写占30%group_reporting #关于显示结果的,汇总每个进程的信息lockmem=1G #只使用1g内存进行测试zero_buffers #用0初始化系统buffernrfiles=8 #每个进程生成文件的数量测试结果,主要关注bw和iops结果bw:磁盘的吞吐量,这个是顺序读写考察的重点iops:磁盘的每秒读写次数,这个是随机读写考察的重点二、安装
wget http://brick.kernel.dk/snaps/fio-2.0.7.tar.gzyum install libaio-develtar -zxvf fio-2.0.7.tar.gzcd fio-2.0.7makemake install三、测试步骤(举例5种方式)
随机读:fio -filename=/dev/sdb1 -direct=1 -iodepth 1 -thread -rw=randread -ioengine=psync -bs=16k -size=200G -numjobs=10 -runtime=1000 -group_reporting -name=mytest顺序读:
fio -filename=/dev/sdb1 -direct=1 -iodepth 1 -thread -rw=read -ioengine=psync -bs=16k -size=200G -numjobs=30 -runtime=1000 -group_reporting -name=mytest随机写:
fio -filename=/dev/sdb1 -direct=1 -iodepth 1 -thread -rw=randwrite -ioengine=psync -bs=16k -size=200G -numjobs=30 -runtime=1000 -group_reporting -name=mytest顺序写:fio -filename=/dev/sdb1 -direct=1 -iodepth 1 -thread -rw=write -ioengine=psync -bs=16k -size=200G -numjobs=30 -runtime=1000 -group_reporting -name=mytest混合随机读写:fio -filename=/dev/sdb1 -direct=1 -iodepth 1 -thread -rw=randrw -rwmixread=70 -ioengine=psync -bs=16k -size=200G -numjobs=30 -runtime=100 -group_reporting -name=mytest -ioscheduler=noop下列:AWS-美东机房c5.large机型IO测试
~~~~~~IO~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~