1.下载
https://github.com/akopytov/sysbench
我下载的是zip包
2.安装
unzip sysbench-master.zip
./autogen.sh
./configure && make && make install #mysql在默认安装路径
./configure --prefix=/usr/local/sysbench/ --with-mysql --with-mysql-includes=/usr/local/mysql/include --with-mysql-libs=/usr/local/mysql/lib #这个是用于指定mysql安装的路径
#有的同学可能会遇到mysql_config executable not found。这好像是环境变量的问题。
使用sysbench --version 验证安装是否成功。
3.使用
使用oltp_read_write.lua
创建4张表,每张表100000记录
sysbench /usr/local/share/sysbench/oltp_read_write.lua --mysql-host=150.0.32.236 --mysql-port=3306 --mysql-user=test --mysql-password=test --mysql-db=db1 --tables=4 --table_size=100000 --mysql_storage_engine=Innodb prepare
sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3)
并发4个进程,运行10分钟,预热20秒
sysbench /usr/local/share/sysbench/oltp_read_write.lua --mysql-host=150.0.32.236 --mysql-port=3306 --mysql-user=test --mysql-password=test --mysql-db=db1 --tables=4 --table_size=100000 --mysql_storage_engine=Innodb --threads=4 --time=600 --warmup-time=20 --report-interval=10 run