sysbench支持以下几种测试模式: 1、CPU运算性能 2、磁盘IO性能 3、调度程序性能 4、内存分配及传输速度 5、POSIX线程性能 6、数据库性能(OLTP基准测试) 目前sysbench主要支持 mysql,drizzle,pgsql,oracle 等几种数据库。
项目地址https://launchpad.net/sysbench
--test=tests/db/oltp.lua --oltp_tables_count=10 --oltp-table-size=5000000 --rand-init=on prepare
关于这几个参数的解释:在上面初始化数据参数的基础上,再增加一些参数,即可开始进行测试了:
此次测试启动了256个线程,10个测试表,每个表中灌入500W条数据,测试时间1个小时
./sysbench --mysql-host=localhost --mysql-port=3306 --mysql-user=root --mysql-password=yourpassword --test=tests/db/oltp.lua --oltp_tables_count=10 --oltp-table-size=5000000 --num-threads=256 --oltp-read-only=off --report-interval=10 --rand-type=uniform --max-time=3600 --max-requests=1000000 --percentile=99 run >> ./log/sysbench_oltpX_256_20160403.log
sysbench 0.5: multi-threaded system evaluation benchmark Running the test with following options: Number of threads: 256 Report intermediate results every 10 second(s) Random number generator seed is 0 and will be ignored -- 线程启动 Threads started! -- 每10秒钟报告一次测试结果,tps、每秒读、每秒写、99%以上的响应时长统计 [ 10s] threads: 256, tps: 524.19, reads/s: 7697.05, writes/s: 2143.56, response time: 1879.46ms (99%) [ 20s] threads: 256, tps: 96.50, reads/s: 1351.01, writes/s: 373.30, response time: 9853.49ms (99%) [ 30s] threads: 256, tps: 235.50, reads/s: 3297.01, writes/s: 946.90, response time: 2150.47ms (99%) [ 40s] threads: 256, tps: 115.50, reads/s: 1617.00, writes/s: 491.40, response time: 4562.75ms (99%) [ 50s] threads: 256, tps: 262.10, reads/s: 3669.41, writes/s: 1016.10, response time: 2049.90ms (99%) [ 60s] threads: 256, tps: 121.50, reads/s: 1701.00, writes/s: 499.10, response time: 3666.03ms (99%) [ 70s] threads: 256, tps: 201.40, reads/s: 2735.10, writes/s: 769.50, response time: 3867.82ms (99%) [ 80s] threads: 256, tps: 204.70, reads/s: 2950.29, writes/s: 838.10, response time: 2724.99ms (99%) [ 90s] threads: 256, tps: 118.40, reads/s: 1657.61, writes/s: 490.00, response time: 3835.53ms (99%) OLTP test statistics: queries performed: read: 8823206 -- 读总数 write: 2520916 -- 写总数 other: 1260458 -- 其他操作总数(SELECT、INSERT、UPDATE、DELETE之外的操作,例如COMMIT等) total: 12604580 -- 全部总数 transactions: 630229 (174.94 per sec.) -- 总事务数(每秒事务数) deadlocks: 0 (0.00 per sec.) -- 发生死锁总数 read/write requests: 11344122 (3148.86 per sec.) -- 读写总数(每秒读写次数) other operations: 1260458 (349.87 per sec.) -- 其他操作总数(每秒其他操作次数) General statistics: -- 一些统计结果 total time: 3602.6152s -- 总耗时 total number of events: 630229 -- 共发生多少事务数 total time taken by event execution: 921887.7227s -- 所有事务耗时相加(不考虑并行因素) response time: -- 响应时间 min: 6.52ms -- 最小耗时 avg: 1462.78ms -- 平均耗时 max: 9918.51ms -- 最长耗时 approx. 99 percentile: 3265.01ms -- 超过99%平均耗时 Threads fairness: -- 线程的稳定性 events (avg/stddev): 2461.8320/34.60 -- 事件(平均值/偏差) execution time (avg/stddev): 3601.1239/0.63 -- 执行时间(平均值/偏差)
General recommendations: Run OPTIMIZE TABLE to defragment tables for better performance MySQL started within last 24 hours - recommendations may be inaccurate Reduce your overall MySQL memory footprint for system stability Enable the slow query log to troubleshoot bad queries Reduce or eliminate unclosed connections and network issues Variables to adjust: *** MySQL's maximum memory usage is dangerously high *** *** Add RAM before increasing MySQL buffer variables *** query_cache_type (=0) innodb_buffer_pool_size (>= 33G) if possible. innodb_buffer_pool_instances(=27)
innodb_buffer_pool_instances = 27 innodb_buffer_pool_size = 3600M