sysbench 测试工具的安装与使用
  TEZNKK3IfmPf 7天前 14 0
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

2.5 测试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

2.6 测试mysql

drop database if exists db01;
create database db01;

这意味着准备步骤将创建 16 个表,每个表包含 10,000 个规则,
“thread”选项指定要在 sysbench 中使用的客户端线程或 MySQL 连接的数量。客户端的线程数也会对可以使用的服务器线程数产生影响。
“rate” 参数指定 sysbench 事务的到达速率,作为真正满足基准测试引起的负载的一种方式。如果事务可以继续进行,它们就会排队,这又是这种设置中通常使用的东西。
report-interval参数指定 sysbench 打印统计信息的频率。通常,这设置为1,就像在我们的示例中一样,该示例使sysbench每秒打印出一行。

sysbench \
--db-driver=mysql \
--mysql-user=user0001 \
--mysql_password=User0001! \
--mysql-db=db01 \
--mysql-host=172.17.0.2 \
--mysql-port=3306 \
--tables=16 \
--table-size=10000 \
--threads=4 \
--time=10 \
--events=0 \
--report-interval=1 \
--rate=40 \
/usr/share/sysbench/oltp_read_write.lua run

执行结果

[root@781c38071bbd sysbench]# sysbench \
> --db-driver=mysql \
> --mysql-user=user0001 \
> --mysql_password=User0001! \
> --mysql-db=db01 \
> --mysql-host=172.17.0.2 \
> --mysql-port=3306 \
> --tables=16 \
> --table-size=10000 \
> --threads=4 \
> --time=10 \
> --events=0 \
> --report-interval=1 \
> --rate=40 \
> /usr/share/sysbench/oltp_read_write.lua run
sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)

Running the test with following options:
Number of threads: 4
Target transaction rate: 40/sec
Report intermediate results every 1 second(s)
Initializing random number generator from current time


Initializing worker threads...

Threads started!

[ 1s ] thds: 4 tps: 39.89 qps: 797.86 (r/w/o: 558.50/159.57/79.79) lat (ms,95%): 36.24 err/s: 0.00 reconn/s: 0.00
[ 1s ] queue length: 0, concurrency: 1
[ 2s ] thds: 4 tps: 41.03 qps: 853.59 (r/w/o: 601.42/168.12/84.06) lat (ms,95%): 21.89 err/s: 0.00 reconn/s: 0.00
[ 2s ] queue length: 0, concurrency: 2
[ 3s ] thds: 4 tps: 45.00 qps: 866.97 (r/w/o: 602.98/175.99/88.00) lat (ms,95%): 33.72 err/s: 0.00 reconn/s: 0.00
[ 3s ] queue length: 0, concurrency: 1
[ 4s ] thds: 4 tps: 47.01 qps: 940.16 (r/w/o: 658.11/188.03/94.02) lat (ms,95%): 31.94 err/s: 0.00 reconn/s: 0.00
[ 4s ] queue length: 0, concurrency: 0
[ 5s ] thds: 4 tps: 46.99 qps: 958.87 (r/w/o: 671.91/191.97/94.99) lat (ms,95%): 55.82 err/s: 0.00 reconn/s: 0.00
[ 5s ] queue length: 0, concurrency: 1
[ 6s ] thds: 4 tps: 39.00 qps: 761.00 (r/w/o: 532.00/152.00/77.00) lat (ms,95%): 37.56 err/s: 0.00 reconn/s: 0.00
[ 6s ] queue length: 0, concurrency: 0
[ 7s ] thds: 4 tps: 48.00 qps: 960.01 (r/w/o: 672.01/192.00/96.00) lat (ms,95%): 29.72 err/s: 0.00 reconn/s: 0.00
[ 7s ] queue length: 0, concurrency: 1
[ 8s ] thds: 4 tps: 48.01 qps: 960.14 (r/w/o: 672.10/192.03/96.01) lat (ms,95%): 24.38 err/s: 0.00 reconn/s: 0.00
[ 8s ] queue length: 0, concurrency: 0
[ 9s ] thds: 4 tps: 35.00 qps: 700.01 (r/w/o: 490.01/140.00/70.00) lat (ms,95%): 16.41 err/s: 0.00 reconn/s: 0.00
[ 9s ] queue length: 0, concurrency: 0
[ 10s ] thds: 4 tps: 42.00 qps: 840.01 (r/w/o: 588.00/168.00/84.00) lat (ms,95%): 24.38 err/s: 0.00 reconn/s: 0.00
[ 10s ] queue length: 0, concurrency: 0
SQL statistics:
queries performed:
read: 6048
write: 1728
other: 864
total: 8640
transactions: 432 (42.99 per sec.)
queries: 8640 (859.88 per sec.)
ignored errors: 0 (0.00 per sec.)
reconnects: 0 (0.00 per sec.)

General statistics:
total time: 10.0462s
total number of events: 432

Latency (ms):
min: 9.25
avg: 17.08
max: 81.39
95th percentile: 33.12
sum: 7377.49

Threads fairness:
events (avg/stddev): 108.0000/0.00
execution time (avg/stddev): 1.8444/0.03

测试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#
【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 7天前 0

暂无评论

推荐阅读
  TEZNKK3IfmPf   21天前   19   0   0 mysql
  TEZNKK3IfmPf   2024年05月17日   38   0   0 sqlmysql
  TEZNKK3IfmPf   2024年05月17日   40   0   0 查询mysql索引
  TEZNKK3IfmPf   2024年05月17日   42   0   0 jsonmysql
  TEZNKK3IfmPf   2024年05月17日   40   0   0 mysqlphp
TEZNKK3IfmPf