数据库创建用户密码数据库,字段值均为 benchmark。
安装sysbench,执行命令。
测试结果:
#u-ubuntu-vm
export MYSQL_HOST=192.168.1.10
# 准备数据
sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=$MYSQL_HOST --mysql-port=16033 --mysql-user=benchmark --mysql-password=benchmark --mysql-db=benchmark --tables=20 --table_size=1000000 oltp_read_write --db-ps-mode=disable prepare
# 读写
sysbench --db-driver=mysql --time=30 --threads=10 --report-interval=1 --mysql-host=$MYSQL_HOST --mysql-port=16033 --mysql-user=benchmark --mysql-password=benchmark --mysql-db=benchmark --tables=20 --table_size=1000000 oltp_read_write --db-ps-mode=disable run
# 只读
sysbench --db-driver=mysql --time=30 --threads=10 --report-interval=1 --mysql-host=$MYSQL_HOST --mysql-port=16033 --mysql-user=benchmark --mysql-password=benchmark --mysql-db=benchmark --tables=20 --table_size=1000000 oltp_read_only --db-ps-mode=disable run
SQL statistics:
queries performed:
read: 61530
write: 17580
other: 8790
total: 87900
transactions: 4395 (146.23 per sec.)
queries: 87900 (2924.61 per sec.)
ignored errors: 0 (0.00 per sec.)
reconnects: 0 (0.00 per sec.)
General statistics:
total time: 30.0540s
total number of events: 4395
Latency (ms):
min: 14.80
avg: 68.31
max: 403.70
95th percentile: 150.29
sum: 300219.90
Threads fairness:
events (avg/stddev): 439.5000/7.17
execution time (avg/stddev): 30.0220/0.02
Clipped from: https://segmentfault.com/a/1190000038731788