1.安装
yum install epel-release
yum install sysbench
2.测试
2.1测试cpu
[root@192-168-125-231 ~]# sysbench --test=cpu --cpu-max-prime=3000 run
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)
Running the test with following options:
Number of threads: 1
Initializing random number generator from current time
Prime numbers limit: 3000
Initializing worker threads...
Threads started!
CPU speed:
events per second: 6729.13
General statistics:
total time: 10.0002s
total number of events: 67306
Latency (ms):
min: 0.14
avg: 0.15
max: 12.64
95th percentile: 0.15
sum: 9984.03
Threads fairness:
events (avg/stddev): 67306.0000/0.00
execution time (avg/stddev): 9.9840/0.00
2.2 测试线程
[root@192-168-125-231 ~]# sysbench --test=threads --num-threads=500 --thread-yields=100 --thread-locks=4 run
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
WARNING: --num-threads is deprecated, use --threads instead
sysbench 1.0.17 (using system LuaJIT 2.0.4)
Running the test with following options:
Number of threads: 500
Initializing random number generator from current time
Initializing worker threads...
Threads started!
General statistics:
total time: 10.1044s
total number of events: 55605
Latency (ms):
min: 0.14
avg: 90.33
max: 1128.22
95th percentile: 390.30
sum: 5022606.12
Threads fairness:
events (avg/stddev): 111.2100/28.18
execution time (avg/stddev): 10.0452/0.04
2.3 测试IO
--file-total-size 总的文件大小
生成需要的测试文件,完成后会在当前目录下生成很多小文件。
sysbench --test=fileio --num-threads=16 --file-total-size=2G --file-test-mode=rndrw prepare
2.3清理测试时生成的文件
[root@192-168-125-231 lys]# sysbench --test=fileio --num-threads=20 --file-total-size=2G --file-test-mode=rndrw cleanup
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
WARNING: --num-threads is deprecated, use --threads instead
sysbench 1.0.17 (using system LuaJIT 2.0.4)
Removing test files...
2.4 测试内存
[root@192-168-125-231 lys]# sysbench --test=memory --memory-block-size=8k --memory-total-size=1G run
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)
Running the test with following options:
Number of threads: 1
Initializing random number generator from current time
Running memory speed test with the following options:
block size: 8KiB
total size: 1024MiB
operation: write
scope: global
Initializing worker threads...
Threads started!
Total operations: 131072 (1477287.77 per second)
1024.00 MiB transferred (11541.31 MiB/sec)
General statistics:
total time: 0.0869s
total number of events: 131072
Latency (ms):
min: 0.00
avg: 0.00
max: 0.17
95th percentile: 0.00
sum: 66.11
Threads fairness:
events (avg/stddev): 131072.0000/0.00
execution time (avg/stddev): 0.0661/0.00
测试mutex
[root@192-168-125-231 lys]# sysbench --test=mutex --num-threads=100 --mutex-num=1000 --mutex-locks=100000 --mutex-loops=10000 run
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
WARNING: --num-threads is deprecated, use --threads instead
sysbench 1.0.17 (using system LuaJIT 2.0.4)
Running the test with following options:
Number of threads: 100
Initializing random number generator from current time
Initializing worker threads...
Threads started!
General statistics:
total time: 37.6005s
total number of events: 100
Latency (ms):
min: 36087.99
avg: 37003.16
max: 37517.95
95th percentile: 37144.33
sum: 3700315.95
Threads fairness:
events (avg/stddev): 1.0000/0.00
execution time (avg/stddev): 37.0032/0.30
测试OLTP
1,prepare阶段,生成需要的测试表
sysbench --test=oltp --mysql-table-engine=innodb --mysql-host=10.0.0.8 --mysql-db=testsysbench --oltp-table-size=500000 --mysql-user=root --mysql-password=Lad123456 prepare
2,run阶段
sysbench --num-threads=16 --test=oltp --mysql-table-engine=innodb --mysql-host=192.168.x.x --mysql-db=test --oltp-table-size=500000 --mysql-user=root --mysql-password=123456 run
3,清理测试时生成的测试表
sysbench --num-threads=16 --test=oltp --mysql-table-engine=innodb --mysql-host=192.168.x.x --mysql-db=test --oltp-table-size=500000 --mysql-user=root --mysql-password=123456 cleanup
7)测试表信息:
sysbench--num-threads=4 --test=oltp--oltp-reconnect-mode=random--mysql-table-engine=innodb --mysql-host=192.168.200.201 --mysql-db=rep_test --oltp-table-size=500000--mysql-user=zjy --mysql-password=1234#