一.安装
./autogen.sh
./configure --with-mysql-includes=/usr/local/mysql/include --with-mysql-libs=/usr/local/mysql/lib
make
make install
ls -l /usr/local/mysql/lib/libmysqlclient.so.20*
ln -s /usr/local/mysql/lib/libmysqlclient.so.20 /usr/lib/
vi /etc/ld.so.conf
export LD_LIBRARY_PATH=/usr/local/mysql/lib
ldconfig
二.压力测试
1.查看帮助
sysbench --help
--mysql-host IP
--mysql-port 端口号
--mysql-db 希望链接的数据库
--mysql-user 用户名
--mysql-password 密码
--table_size 每张表初始化的数据数量
--tables 初始化表的数量
--threads 启动的线程(链接数据库的连接数,并发数)
--time 运行时间
--report-interval 运行期间日志,单位为秒
2.准备测试数据
cd /usr/local/share/sysbench
sysbench oltp_read_write.lua --mysql-host=109.115.12.40 --mysql-port=3306 --mysql-db=wwj --mysql-user=root --mysql-password=root --table_size=50000 --tables=10 --threads=50 --time=120 --report-interval=10 prepare
点击(此处)折叠或打开
- sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3)
- Initializing worker threads...
- Creating table 'sbtest6'...
- Creating table 'sbtest5'...
- Creating table 'sbtest2'...
- Creating table 'sbtest9'...
- Creating table 'sbtest3'...
- Creating table 'sbtest10'...
- Creating table 'sbtest4'...
- Creating table 'sbtest8'...
- Creating table 'sbtest1'...
- Creating table 'sbtest7'...
- Inserting 50000 records into 'sbtest3'
- Inserting 50000 records into 'sbtest4'
- Inserting 50000 records into 'sbtest6'
- Inserting 50000 records into 'sbtest8'
- Inserting 50000 records into 'sbtest10'
- Inserting 50000 records into 'sbtest5'
- Inserting 50000 records into 'sbtest2'
- Inserting 50000 records into 'sbtest1'
- Inserting 50000 records into 'sbtest7'
- Inserting 50000 records into 'sbtest9'
- Creating a secondary index on 'sbtest6'...
- Creating a secondary index on 'sbtest4'...
- Creating a secondary index on 'sbtest3'...
- Creating a secondary index on 'sbtest2'...
- Creating a secondary index on 'sbtest8'...
- Creating a secondary index on 'sbtest10'...
- Creating a secondary index on 'sbtest9'...
- Creating a secondary index on 'sbtest7'...
- Creating a secondary index on 'sbtest1'...
- Creating a secondary index on 'sbtest5'...
3.进行压力测试
sysbench oltp_read_write.lua --mysql-host=109.115.12.40 --mysql-port=3306 --mysql-db=wwj --mysql-user=root --mysql-password=root --table_size=50000 --tables=10 --threads=50 --time=120 --report-interval=10 run
点击(此处)折叠或打开
- sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3)
-
- Running the test with following options:
- Number of threads: 50
- Report intermediate results every 10 second(s)
- Initializing random number generator from current time
-
- Initializing worker threads...
-
- Threads started!
- [ 10s ] thds: 50 tps: 155.35 qps: 3120.70 (r/w/o: 2183.67/621.42/315.61) lat (ms,95%): 657.93 err/s: 0.00 reconn/s: 0.00
- [ 20s ] thds: 50 tps: 177.91 qps: 3638.51 (r/w/o: 2552.04/730.54/355.92) lat (ms,95%): 458.96 err/s: 0.00 reconn/s: 0.00
- [ 30s ] thds: 50 tps: 183.40 qps: 3612.40 (r/w/o: 2530.63/714.98/366.79) lat (ms,95%): 397.39 err/s: 0.00 reconn/s: 0.00
- [ 40s ] thds: 50 tps: 178.81 qps: 3617.02 (r/w/o: 2530.69/728.92/357.41) lat (ms,95%): 450.77 err/s: 0.00 reconn/s: 0.00
- [ 50s ] thds: 50 tps: 186.90 qps: 3730.97 (r/w/o: 2620.78/736.19/374.00) lat (ms,95%): 376.49 err/s: 0.00 reconn/s: 0.00
- [ 60s ] thds: 50 tps: 175.20 qps: 3514.82 (r/w/o: 2456.41/708.00/350.40) lat (ms,95%): 493.24 err/s: 0.00 reconn/s: 0.00
- [ 70s ] thds: 50 tps: 181.20 qps: 3622.46 (r/w/o: 2533.97/726.19/362.30) lat (ms,95%): 450.77 err/s: 0.00 reconn/s: 0.00
- [ 80s ] thds: 50 tps: 182.80 qps: 3650.66 (r/w/o: 2553.14/732.21/365.31) lat (ms,95%): 411.96 err/s: 0.00 reconn/s: 0.00
- [ 90s ] thds: 50 tps: 174.50 qps: 3497.29 (r/w/o: 2452.29/695.60/349.40) lat (ms,95%): 458.96 err/s: 0.00 reconn/s: 0.00
- [ 100s ] thds: 50 tps: 176.60 qps: 3500.17 (r/w/o: 2449.15/697.81/353.21) lat (ms,95%): 484.44 err/s: 0.00 reconn/s: 0.00
- [ 110s ] thds: 50 tps: 183.27 qps: 3691.17 (r/w/o: 2590.33/734.29/366.55) lat (ms,95%): 427.07 err/s: 0.00 reconn/s: 0.00
- [ 120s ] thds: 50 tps: 192.22 qps: 3839.88 (r/w/o: 2688.36/767.18/384.34) lat (ms,95%): 356.70 err/s: 0.00 reconn/s: 0.00
- SQL statistics:
- queries performed:
- read: 301448 #读总数
- write: 86128。 #写总数
- other: 43064。 #其他操作
- total: 430640。 #总操作数
- transactions: 21532 (179.11 per sec.)。 #tps每秒事务数
- queries: 430640 (3582.15 per sec.)。
- ignored errors: 0 (0.00 per sec.)
- reconnects: 0 (0.00 per sec.)
- Throughput:
- events/s (eps): 179.1074。
- time elapsed: 120.2184s。
- total number of events: 21532
-
- Latency (ms):
- min: 22.17
- avg: 278.93
- max: 2276.44
- 95th percentile: 450.77
- sum: 6005874.20
-
- Threads fairness:
- events (avg/stddev): 430.6400/8.04
- execution time (avg/stddev): 120.1175/0.03
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/15412087/viewspace-2153307/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/15412087/viewspace-2153307/