1.数据准备
sysbench --test=oltp \
--mysql-host=192.168.1.11 \
--mysql-port=3306 \
--mysql-user=root \
--mysql-password=rootroot \
--mysql-db=sbtest \
--mysql-table-engine=innodb \
--mysql-engine-trx=yes \
--mysql-ssl=no \
--oltp-num-tables=10 \
--oltp-table-size=100000 \
--db-driver=mysql \
--oltp-table-name=mytest_1 \
--oltp-read-only=off \
--report-interval=10 \
prepare
2.只写测试
sysbench --test=oltp \
--mysql-host=192.168.1.11 \
--mysql-port=3306 \
--mysql-user=root \
--mysql-password=rootroot \
--mysql-db=sbtest \
--mysql-table-engine=innodb \
--mysql-engine-trx=yes \
--mysql-ssl=no \
--oltp-num-tables=10 \
--oltp-table-size=100000 \
--db-driver=mysql \
--oltp-table-name=mytest_1 \
--oltp-read-only=off \
--report-interval=10 \
--max-requests=0 \
--oltp-test-mode=complex \
--max-time=120 \
run >/root/mytest_writeonly.log
3.查看生成数据
[root@es4 gnuplot-5.2.0]# tail -100f /root/mytest_writeonly.log
sysbench 0.4.12.10: multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 1
Report intermediate results every 10 second(s)
Random number generator seed is 0 and will be ignored
Doing OLTP test.
Running mixed OLTP test
Using Special distribution (12 iterations, 1 pct of values are returned in 75 pct cases)
Using "BEGIN" for starting transactions
Using auto_inc on the id column
Using 10 test tables
Threads started!
[ 10s] Intermediate results: 1 threads, tps: 175.790271, reads/s: 2461.063799, writes/s: 703.161085 response time: 6.819905ms (95%)
[ 20s] Intermediate results: 1 threads, tps: 182.703999, reads/s: 2557.855984, writes/s: 730.815995 response time: 5.974723ms (95%)
[ 30s] Intermediate results: 1 threads, tps: 181.000028, reads/s: 2534.000390, writes/s: 724.000111 response time: 5.912453ms (95%)
[ 40s] Intermediate results: 1 threads, tps: 175.100605, reads/s: 2451.408466, writes/s: 700.402419 response time: 6.158116ms (95%)
[ 50s] Intermediate results: 1 threads, tps: 183.099423, reads/s: 2563.391925, writes/s: 732.397693 response time: 5.974723ms (95%)
[ 60s] Intermediate results: 1 threads, tps: 181.203326, reads/s: 2536.846560, writes/s: 724.813303 response time: 5.849081ms (95%)
[ 70s] Intermediate results: 1 threads, tps: 172.697586, reads/s: 2417.766201, writes/s: 690.790343 response time: 6.848546ms (95%)
[ 80s] Intermediate results: 1 threads, tps: 183.902353, reads/s: 2574.632938, writes/s: 735.609411 response time: 6.017801ms (95%)
[ 90s] Intermediate results: 1 threads, tps: 180.200115, reads/s: 2522.801613, writes/s: 720.800461 response time: 6.169187ms (95%)
[ 100s] Intermediate results: 1 threads, tps: 175.196253, reads/s: 2452.747537, writes/s: 700.785010 response time: 6.371887ms (95%)
[ 110s] Intermediate results: 1 threads, tps: 185.098366, reads/s: 2591.377128, writes/s: 740.393465 response time: 5.884204ms (95%)
[ 120s] Intermediate results: 1 threads, tps: 180.198817, reads/s: 2522.783442, writes/s: 720.795269 response time: 5.940838ms (95%)
Time limit exceeded, exiting...
Done.
OLTP test statistics:
queries performed:
read: 301882
write: 86252
other: 43126
total: 431260
transactions: 21563 (179.68 per sec.)
deadlocks: 0 (0.00 per sec.)
read/write requests: 388134 (3234.29 per sec.)
other operations: 43126 (359.37 per sec.)
General statistics:
total time: 120.0058s
total number of events: 21563
total time taken by event execution: 119.8598
response time:
min: 4.71ms
avg: 5.56ms
max: 91.44ms
approx. 95 percentile: 6.07ms
Threads fairness:
events (avg/stddev): 21563.0000/0.00
execution time (avg/stddev): 119.8598/0.00
--只写:179/s 个事务。
--读写:3234/s 个。
4.清理数据
sysbench --test=oltp \
--mysql-host=192.168.1.11 \
--mysql-port=3306 \
--mysql-user=root \
--mysql-password=rootroot \
--mysql-db=sbtest \
--mysql-table-engine=innodb \
--mysql-ssl=no \
--oltp-table-name=mytest_1 \
--oltp-num-tables=10 \
cleanup