Linux 性能测试工具 sysbench 的安装与简单使用
一 背景
sysbench是一款开源的多线程性能测试工具,可以执行CPU/内存/线程/IO/数据库等方面的性能测试。
sysbench 支持以下几种测试模式 :
- 1、CPU运算性能
- 2、内存分配及传输速度
- 3、磁盘IO性能
- 4、POSIX线程性能
- 5、互斥性测试
- 6、数据库性能(OLTP基准测试)。目前sysbench主要支持 MySQL,PostgreSQL 等几种数据库。
二 实验环境
2.1 操作系统
[gysl@gysl-DevOps ~]$ cat /etc/centos-release
CentOS Linux release 7.6.1810 (Core)
2.2 其他配置
安装EPEL,安装方法之前的文章有介绍。
三 安装
安装命令如下:
[gysl@gysl-DevOps ~]$ sudo yum -y install sysbench
四 简单使用过程
4.1 查看软件版本
[gysl@gysl-DevOps ~]$ sysbench --version
sysbench 1.0.9
4.2 查看系统帮助
[gysl@gysl-DevOps ~]$ sysbench --help
See 'sysbench --test=<name> help' for a list of options for each test. #查看每个测试项目的更多选项列表
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]
--time=N limit for total execution time in seconds [10]
--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] #每个线程的堆栈大小。默认是32K。
--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]
--validate[=on|off] perform validation checks where possible [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] #请求的最大数目。默认为10000,0代表不限制。
--max-time=N deprecated alias for --time [0] #最大执行时间,单位是s。默认是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]
--percentile=N percent