赞
踩
最近需要测试一批服务器的相关硬件性能,以及在常规环境下的硬件运行稳定情况,需要持续拷机测试稳定性。所以找了一些测试用例。本次测试包括在服务器的高低温下性能记录及压力测试,高低电压下性能记录及压力测试,常规环境下CPU满载稳定运行的功率记录。
这个系列是根据这次测试项目的相关测试总结,关于各种常见性能测试及拷机软件的整理。
本章为系列3,主要介绍
系列往期:
Linux服务器常见运维性能测试(1)综合跑分unixbench、superbench
Linux服务器常见运维性能测试(2)内存测试mbw、stream
综合测试:UnixBench(综合跑分),superbench(快速脚本)
内存测试:mbw(内存带宽测试),stream(读写响应测试)
CPU测试:super_pi(计算圆周率)、sysbench(CPU功能测试部分)
网络测试:netperf
IO测试:FIO、iometer
辅助监测:sensors、top、
super_pi(π)一般用于进行压力测试,但同时也可以通过计算π所用时间评估CPU算力,参考CPU性能。其常用于硬件发烧友中对超频后的CPU进行压力测试,因其只用到基础的浮点运算,而不涉及其他的系统库环境,所以,很适合用于排查CPU物理问题。当系统出现不明原因的死机、缓慢、自动重启等故障,我们可用其协助分析是否CPU不稳定导致的。
官方下载地址:https://superpi.ilbello.com/
解压后直接运行即可
tar -jxvf super_pi.tar.bz2
./super_pi 20 #20为测试计算到小数点后的位数
该程序在 SMP 环境中,只能让 CPU 满载运行,所以,对于多 CPU 的环境,可同时用多个程序并发运行。super_pi同样也可以用于拷机测试稳定性,在运行期间CPU满载运行,可以持续关注设备运行稳定性和温度情况。
补充说明※
1、命令运行中使用的参数m,是指位数,表示要算2的多少次方位,如通常要算小数点后1M位(2^20次方);
2、m最大到25次方,若设置再大的值,会自动缩小到该值
例子:
Specified M(=30) is too large. M is set to 25.
Start of PI calculation up to 33554432 decimal digits
3、因算法不同,该程序不能用于和Windows平台上的Super PI进行性能对比(实际上,快很多)
sysbench是一个模块化的、跨平台、多线程基准测试工具,主要用于评估测试各种不同系统参数下的数据库负载情况。其可以作为综合性能测试工具,它主要包括以下几种方式的测试:磁盘io性能、数据库性能、内存分配及传输速度等。
它主要包括以下几种方式的测试:
CPU运算性能
file I/O performance (磁盘IO性能)
scheduler performance (调度程序性能)
memory allocation and transfer speed (内存分配及传输速度)
POSIX threads implementation performance (POSIX线程性能)
database server performance (OLTP benchmark) (数据库服务器性能,OLTP基准测试)
sysbench作为综合性能测试工具有很多可以测试使用的功能,我们这次测试主要用其测试CPU性能。
下载地址: https://github.com/akopytov/sysbench/archive/1.0.zip
解压安装: 解压得到sysbench-1.0文件夹,进入文件夹执行安装程序
./autogen.sh
如果报错:automake 1.10.x (aclocal) wasn't found, exiting 需要补充安装依赖包
# 安装依赖包
yum install automake libtool -y
./configure --without-mysql #由于我们使用sysbench只做CPU测试,不压mysql,所以放弃依赖mysql
make #最后执行汇编安装
make install #安装完毕
查看版本安装成功
查看帮助文档
sysbench --help Usage: sysbench [options]... [testname] [command] Commands implemented by most tests: prepare run cleanup help General options: --threads=N number of threads to use [1],创建测试线程的数目。默认为1. --events=N limit for total number of events [0],请求的最大数目,0代表不限制。 --time=N limit for total execution time in seconds [10],最大执行时间,单位是s。默认是10s --forced-shutdown=STRING number of seconds to wait after the --time limit before forcing shutdown, or 'off' to disable [off],超过max-time强制中断。默认是off。 --thread-stack-size=SIZE size of stack per thread [64K],每个线程的堆栈大小。默认是64K。 --rate=N average transactions rate. 0 for unlimited rate [0] --report-interval=N periodically report intermediate statistics with a specified interval in seconds. 0 disables intermediate reports [0],指定每多少秒在屏幕上输出一次结果 --report-checkpoints=[LIST,...] dump full statistics and reset all counters at specified points in time. The argument is a list of comma-separated values representing the amount of time in seconds elapsed from start of test when report checkpoint(s) must be performed. Report checkpoints are off by default. [] --debug[=on|off] print more debugging info [off],是否显示更多的调试信息。默认是off。 --validate[=on|off] perform validation checks where possible [off],#在可能情况下执行验证检查。默认是off。 --help[=on|off] print help and exit [off],#帮助信息 --version[=on|off] print version and exit [off],#版本信息 --config-file=FILENAME File containing command line options --tx-rate=N deprecated alias for --rate [0] --max-requests=N deprecated alias for --events [0] --max-time=N deprecated alias for --time [0] --num-threads=N deprecated alias for --threads [1] Pseudo-Random Numbers Generator options: --rand-type=STRING random numbers distribution {uniform,gaussian,special,pareto} [special] --rand-spec-iter=N number of iterations used for numbers generation [12] --rand-spec-pct=N percentage of values to be treated as 'special' (for special distribution) [1] --rand-spec-res=N percentage of 'special' values to use (for special distribution) [75] --rand-seed=N seed for random number generator. When 0, the current time is used as a RNG seed. [0] --rand-pareto-h=N parameter h for pareto distribution [0.2] Log options: --verbosity=N verbosity level {5 - debug, 0 - only critical messages} [3],日志级别,默认为3,5=debug,0=只包含重要信息 --percentile=N percentile to calculate in latency statistics (1-100). Use the special value of 0 to disable percentile calculations [95] --histogram[=on|off] print latency histogram in report [off] General database options: --db-driver=STRING specifies database driver to use ('help' to get list of available drivers) [mysql] --db-ps-mode=STRING prepared statements usage mode {auto, disable} [auto] --db-debug[=on|off] print database-specific debug information [off] Compiled-in database drivers: mysql - MySQL driver pgsql - PostgreSQL driver mysql options: --mysql-host=[LIST,...] MySQL server host [localhost] --mysql-port=[LIST,...] MySQL server port [3306] --mysql-socket=[LIST,...] MySQL socket --mysql-user=STRING MySQL user [sbtest] --mysql-password=STRING MySQL password [] --mysql-db=STRING MySQL database name [sbtest] --mysql-ssl[=on|off] use SSL connections, if available in the client library [off] --mysql-ssl-cipher=STRING use specific cipher for SSL connections [] --mysql-compression[=on|off] use compression, if available in the client library [off] --mysql-debug[=on|off] trace all client library calls [off] --mysql-ignore-errors=[LIST,...] list of errors to ignore, or "all" [1213,1020,1205] --mysql-dry-run[=on|off] Dry run, pretend that all MySQL client API calls are successful without executing them [off] pgsql options: --pgsql-host=STRING PostgreSQL server host [localhost] --pgsql-port=N PostgreSQL server port [5432] --pgsql-user=STRING PostgreSQL user [sbtest] --pgsql-password=STRING PostgreSQL password [] --pgsql-db=STRING PostgreSQL database name [sbtest] Compiled-in tests:#测试项目 fileio - File I/O test cpu - CPU performance test memory - Memory functions speed test,#内存 threads - Threads subsystem performance test,#线程 mutex - Mutex performance test#互斥性能测试 See 'sysbench <testname> help' for a list of options for each test.
测试CPU的帮助文档
#sysbench --test=cpu help
--cpu-max-prime=N 最大质数发生器数量。默认是10000
测试IO的帮助文档
# sysbench --test=fileio help WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options. sysbench 1.0.17 (using system LuaJIT 2.0.4) fileio options: --file-num=N number of files to create [128],创建测试文件的数量。默认是128 --file-block-size=N block size to use in all IO operations [16384],测试时文件块的大小。默认是16384(16K) --file-total-size=SIZE total size of files to create [2G],测试文件的总大小。默认是2G --file-test-mode=STRING 文件测试模式{seqwr(顺序写), seqrewr(顺序读写), seqrd(顺序读), rndrd(随机读), rndwr(随机写), rndrw(随机读写)} --file-io-mode=STRING 文件操作模式{sync(同步),async(异步),fastmmap(快速map映射),slowmmap(慢map映射)}。默认是sync --file-async-backlog=N number of asynchronous operatons to queue per thread [128] --file-extra-flags=[LIST,...] 使用额外的标志来打开文件{sync,dsync,direct} 。默认为空 --file-fsync-freq=N 执行fsync()的频率。(0 – 不使用fsync())。默认是100 --file-fsync-all[=on|off] 每执行完一次写操作就执行一次fsync。默认是off --file-fsync-end[=on|off] 在测试结束时才执行fsync。默认是on --file-fsync-mode=STRING 使用哪种方法进行同步{fsync, fdatasync}。默认是fsync --file-merged-requests=N 如果可以,合并最多的IO请求数(0 – 表示不合并)。默认是0 --file-rw-ratio=N 测试时的读写比例,默认时为1.5,即可3:2。
测试内存的帮助文档
# sysbench --test=memory help
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
sysbench 1.0.17 (using system LuaJIT 2.0.4)
memory options:
--memory-block-size=SIZE 测试时内存块大小。默认是1K
--memory-total-size=SIZE 传输数据的总大小。默认是100G
--memory-scope=STRING 内存访问范围{global,local}。默认是global
--memory-hugetlb=[on|off] 从HugeTLB池内存分配。默认是off
--memory-oper=STRING 内存操作类型。{read, write, none} 默认是write
--memory-access-mode=STRING存储器存取方式{seq,rnd} 默认是seq
测试线程的帮助文档
# sysbench threads help
sysbench 1.0.17 (using system LuaJIT 2.0.4)
threads options:
--thread-yields=N number of yields to do per request [1000],每个请求产生多少个线程。默认是1000
--thread-locks=N number of locks per thread [8],每个线程的锁的数量。默认是8
sysben基本命令格式
sysbench [general-options]... --test=<test-name> [test-options]... command General options: #通用选项 --num-threads=N number of threads to use [1] #创建测试线程的数目。默认为1. --max-requests=N limit for total number of requests [10000] #请求的最大数目。默认为10000,0代表不限制。 --max-time=N limit for total execution time in seconds [0] #最大执行时间,单位是s。默认是0,不限制。 --forced-shutdown=STRING amount of time to wait after --max-time before forcing shutdown [off] #超过max-time强制中断。默认是off。 --thread-stack-size=SIZE size of stack per thread [32K] #每个线程的堆栈大小。默认是32K。 --init-rng=[on|off] initialize random number generator [off] #在测试开始时是否初始化随机数发生器。默认是off。 --test=STRING test to run #指定测试类型。 fileio cpu memory threads mutex --debug=[on|off] print more debugging info [off] #是否显示更多的调试信息。默认是off。 --validate=[on|off] perform validation checks where possible [off] #在可能情况下执行验证检查。默认是off。 --help=[on|off] print help and exit #帮助信息。 --version=[on|off] print version and exit #版本信息。 --report-interval --指定每多少秒在屏幕上输出一次结果 --日志选项 --verbosity=N --日志级别,默认为3,5=debug,0=只包含重要信息 Compiled-in tests: #测试项目 fileio - File I/O test #IO cpu - CPU performance test #CPU memory - Memory functions speed test #内存 threads - Threads subsystem performance test #线程 mutex - Mutex performance test #互斥性能测试 oltp - OLTP test # 数据库,事务处理
常用参数
–cpu-max-prime: 素数生成数量的上限
–threads: 线程数
–time: 运行时长,单位秒
–events: event上限次数
执行测试:
测试场景1:默认开启一个线程
sysbench cpu --time=60 run
[root@localhost ~]# sysbench cpu --time=60 run sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2) Running the test with following options: Number of threads: 1 Initializing random number generator from current time Prime numbers limit: 10000 Initializing worker threads... Threads started! CPU speed: events per second: 836.83 // CPU速度 General statistics: total time: 60.0004s //运行时间60s total number of events: 50212 //60s内共执行50212次event Latency (ms): min: 1.18 //最小耗时1.18ms avg: 1.19 //平均耗时1.19ms max: 2.76 //最大耗时2.76ms 95th percentile: 1.21 //95%在1.21ms内完成 sum: 59975.10 Threads fairness: events (avg/stddev): 50212.0000/0.00 execution time (avg/stddev): 59.9751/0.00
测试场景2:开启8个线程
sysbench cpu --time=60 --threads=8 run
[root@localhost ~]# sysbench cpu --time=60 --threads=8 run sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2) Running the test with following options: Number of threads: 8 Initializing random number generator from current time Prime numbers limit: 10000 Initializing worker threads... Threads started! CPU speed: events per second: 3329.87 //CPU速度 General statistics: total time: 60.0012s //运行时间60s total number of events: 199802 //60s内所有线程共执行199802次event Latency (ms): min: 1.18 //最小耗时1.18ms avg: 2.40 //平均耗时2.40ms max: 67.19 //最大耗时67.19ms 95th percentile: 11.24 //95%在11.24ms内完成 sum: 479692.58 Threads fairness: events (avg/stddev): 24975.2500/87.36 execution time (avg/stddev): 59.9616/0.01
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。