cd /sysbench-0.4.12-1.1
./autogen.sh
./configure --with-mysql-includes=/usr/local/mysql/include --with-mysql-libs=/usr/local/mysql/lib && make
vim /etc/profile
//在最后添加上
export LD_LIBRARY_PATH=/usr/local/mysql/lib
//保存文件后,执行source
source /etc/profile
create database sbtest;
* 创建表及测试
数据(可使用sysbench自带lua文件来测试
)
./bin/sysbench --test=tests/db/oltp.lua \
--mysql-host=10.187.96.53 --mysql-port=3306 --mysql-user=root --mysql-password=root \
--mysql-db=sbtest --oltp-tables-count=10 --oltp-table-size=10000000 \
--report-interval=10 --oltp-dist-type=uniform --rand-init=on --max-requests=0 \
--oltp-test-mode=nontrx --oltp-nontrx-mode=select \
--oltp-read-only=on --oltp-skip-trx=on \
--max-time=180 --num-threads=12 \
prepare
注意:最后的prepare代表准备数据,同时可选项还有run(执行压力测试)、cleanup(清除数据)
--mysql-host MySQL所在地址
--mysql-port 端口号
--mysql-user 用户名
--mysql-password 密码
--mysql-db 测试所使用的DB(需提前创建好)
--oltp-tables-count 创建表的数量(脚本会自动创建该数量的表在指定DB下)
--oltp-table-size 单个表的数据量
--report-interval 隔多久输出报告
--oltp-dist-type 指定随机取样类型,可选值有 uniform(均匀分布), Gaussian(高斯分布), special(空间分布)。默认是special
--oltp-test-mode 执行模式,这里是非事务式的。可选值有simple,complex,nontrx。默认是complex
--oltp-nontrx-mode 可选值有select(默认), update_key, update_nokey, insert, delete,代表非事务式模式下使用的测试sql类型
--oltp-read-only 表示不止产生只读SQL,也就是使用oltp.lua时会采用读写混合模式。默认 off,如果设置为on,则不会产生update,delete,insert的sql
--oltp-skip-trx=[on|off]:省略begin/commit语句。默认是off
--max-requests=0:压力测试产生请求的总数,如果以下面的max-time来记,这个值设为0
--max-time=120:压力测试的持续时间,这里是2分钟。
--num-threads=12: 并发线程数,可以理解为模拟的客户端并发连接数
./bin/sysbench --test=tests/db/oltp.lua \
--mysql-host=10.187.96.53 --mysql-port=3306 --mysql-user=root --mysql-password=root \
--mysql-db=sbtest --oltp-tables-count=10 --oltp-table-size=10000000 \
--report-interval=10 --oltp-dist-type=uniform --rand-init=on --max-requests=0 \
--oltp-test-mode=nontrx --oltp-nontrx-mode=select \
--oltp-read-only=on --oltp-skip-trx=on \
--max-time=180 --num-threads=12 \
run >> test-read/out.log
./bin/sysbench --test=tests/db/update_index.lua \
--mysql-host=10.187.96.53 --mysql-port=3306 --mysql-user=root --mysql-password=root \
--mysql-db=sbtest --oltp-tables-count=10 --oltp-table-size=10000000 \
--report-interval=10 --oltp-dist-type=uniform --rand-init=on --max-requests=0 \
--oltp-test-mode=nontrx --oltp-nontrx-mode=select \
--oltp-read-only=off --oltp-skip-trx=on \
--max-time=180 --num-threads=12 \
run >> test-update/out.log
./bin/sysbench --test=tests/db/oltp.lua \
--mysql-host=10.187.96.53 --mysql-port=3306 --mysql-user=root --mysql-password=root \
--mysql-db=sbtest --oltp-tables-count=10 --oltp-table-size=10000000 \
--report-interval=10 --oltp-dist-type=uniform --rand-init=on --max-requests=0 \
--oltp-test-mode=nontrx --oltp-nontrx-mode=select \
--oltp-read-only=off --oltp-skip-trx=on \
--max-time=180 --num-threads=12 \
run >> test-all/out.log