Linux服务器常见运维性能测试(3)CPU测试

  • 常见性能测试软件
    • CPU测试:super_pi (计算圆周率)
    • CPU测试:sysbench(CPU功能测试部分)
      • 下载安装
      • sysbench综合测试功能
      • 执行CPU测试

最近需要测试一批服务器的相关硬件性能,以及在常规环境下的硬件运行稳定情况,需要持续拷机测试稳定性。所以找了一些测试用例。本次测试包括在服务器的高低温下性能记录及压力测试,高低电压下性能记录及压力测试,常规环境下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、

CPU测试:super_pi (计算圆周率)

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进行性能对比(实际上,快很多)


CPU测试:sysbench(CPU功能测试部分)

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综合测试功能

查看帮助文档

sysbench --help
Usage:sysbench [options]... [testname] [command]Commands implemented by most tests: prepare run cleanup helpGeneral 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 driverpgsql - PostgreSQL drivermysql 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 testcpu - CPU performance testmemory - 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]... commandGeneral 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测试

常用参数
–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 timePrime numbers limit: 10000Initializing worker threads...Threads started!CPU speed:events per second:   836.83         //  CPU速度General statistics:total time:                          60.0004s  //运行时间60stotal number of events:              50212      //60s内共执行50212次eventLatency (ms):min:                                    1.18   //最小耗时1.18msavg:                                    1.19    //平均耗时1.19msmax:                                    2.76    //最大耗时2.76ms95th percentile:                        1.21    //95%在1.21ms内完成sum:                                59975.10  Threads fairness:events (avg/stddev):           50212.0000/0.00execution 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 timePrime numbers limit: 10000Initializing worker threads...Threads started!CPU speed:events per second:  3329.87         //CPU速度General statistics:total time:                          60.0012s     //运行时间60stotal number of events:              199802            //60s内所有线程共执行199802次eventLatency (ms):min:                                    1.18  //最小耗时1.18msavg:                                    2.40    //平均耗时2.40msmax:                                   67.19    //最大耗时67.19ms95th percentile:                       11.24   //95%在11.24ms内完成sum:                               479692.58Threads fairness:events (avg/stddev):           24975.2500/87.36execution time (avg/stddev):   59.9616/0.01

Linux服务器常见运维性能测试(3)CPU测试super_pi、sysbench相关推荐

  1. Linux服务器常见运维性能测试(1)综合跑分unixbench、superbench

    Linux服务器常见运维性能测试及压力测试拷机稳定性系列(1)综合跑分unixbench.superbench 常见性能测试软件 综合测试:1.UnixBench 测试项 安装及使用 综合测试:2.s ...

  2. 老司机实战Windows Server Docker:4 单节点Windows Docker服务器简单运维(下)

    上篇中,我们主要介绍了使用docker-compose对Windows Docker单服务器进行远程管理,编译和部署镜像,并且设置容器的自动启动.但是,还有一些重要的问题没有解决,这些问题不解决,就完 ...

  3. Linux 系统日常运维九大技能和运维网络知识总结

    一.Linux 系统日常运维九大技能 1.安装部署 方式:U盘,光盘和网络安装 其中网络安装已经成为了目前批量部署的首选方式:主要工具有Cobbler和PXE+kickstart 可以参考如下链接内容 ...

  4. [10] Linux系统日常运维

    [10] Linux系统日常运维 10.1 使用w查看系统负载 [root@Temence ~]# w19:28:05 up 45 days, 9:20, 1 user, load average: ...

  5. 【学习总结】Apsara Clouder云计算技能认证:云服务器基础运维与管理+思维导图

    [学习总结]Apsara Clouder云计算技能认证:云服务器基础运维与管理 课程目标 3个理由拥抱云服务器 什么是云服务器? 使用云服务器的好处? 理由一:简单易用 理由二:高效稳定 理由三:成本 ...

  6. 银河麒麟操作系统常见运维问题

    目录 银河麒麟  常见运维问题 1 安装问题 1) 高级安装ARM版本系统,新建分区sda1必须是/boot分区,sda2是根分区? 2) 用光盘安装或者U盘安装时,无法进入安装界面问题 3) 麒麟系 ...

  7. grafana的+按钮_基于 Prometheus、Grafana 的 EMQ X 物联网 MQTT 服务器可视化运维监控...

    Prometheus 是由 SoundCloud 开源监控告警解决方案,支持多维 数据模型(时序由 metric 名字和 k/v 的 labels 构成),具备灵活的查询语句(PromQL),支持多种 ...

  8. 服务器运维事项,云服务器的运维工作要注意的事项

    从字面意思来看,云服务器的运维指的是对云服务器的运营和维护. 运维,是以技术为依托.通过技术软件来实现服务器稳定安全工作的服务. 在日常的运维工作中,云服务器的配置以及技术需求,决定了运维需要技术人员 ...

  9. Linux线上运维经验分享与故障排除技巧-高俊峰-专题视频课程

    Linux线上运维经验分享与故障排除技巧-743人已学习 课程介绍         主要介绍Linux线上服务器的运维经验和实战操作过程,并介绍常见的系统故障排查思路与问题解决技巧. 课程收益     ...

最新文章

  1. 9.1 图像处理的基本概念(图像读入、图像信息查询、图像显示和图像存储)
  2. 计算机游戏88关,天天象棋88关怎么过 闯关模式第88关图文攻略
  3. Android 6.0 权限管理最佳实践
  4. 毕业即失业?你到底在焦虑什么
  5. XEIM|XEIM企业即时通讯
  6. 【面试】判断一棵二叉树是否为二叉排序树
  7. DDK build的时候C2220警告当错误处理
  8. 多线程-线程间通信-多生产者多消费者示例
  9. Bootstarp daterangepicker 日期控件
  10. 算法的优缺点_逻辑回归算法的优缺点
  11. C语言计算器代码(带有报告)
  12. 淘宝短视频原创检测,重复检测算法原理分析
  13. java在线ide_程序猿专用十大在线编译器(IDE)整理
  14. DSL是什么意思?Mbps是什么意思?
  15. 敏捷史话(十三):我被 Facebook 解雇了——Kent Beck
  16. 清华大学计算机杨弋,[转载]专注与兴趣是成功的阶梯(访杨弋)
  17. 春节不打烊,这份安全应急指南请收好!
  18. 赛元科技EasyCodeCube的使用——Keil环境的配置
  19. Eclipse+ GNU ARM Eclipse Plug-in+ Sourcery G++ Lite Edition for ARM+OPENCD+Jlink的开源开发环境。
  20. CEOI 2020, Day 2 A,B题解 CF1403A CF1403B

热门文章

  1. iPhone与iWatch连接、控制、数据传递(Swift)
  2. 使用迅捷画图绘制流程图操作方法介绍
  3. flex 画流程图_分享一款简单流程图制作软件,教你快速绘制流程图
  4. 健身房会员管理系统有哪些特点
  5. mysql中%3cwhere%3e_MySQL EXPLAIN详解
  6. 马尔可夫链预测模型的应用——以个人图书借阅为例(改进2.0版)
  7. 来讲一讲php的单例模式及应用场景
  8. 从源码编译安装软件经验+技巧
  9. 图信号非参数假设检验:一种生成代替图信号的谱方法——A Spectral Method for Generating Surrogate Graph Signals
  10. cmd搭建vue前端项目详细过程