sysbench 环境安装,压测mysql
源码路径:https://github.com/akopytov/sysbench
版本
linux 6.8
sysbench 0.5
mysql 5.6.29
1、安装pip略
2、pip 安装bzr
pip install bzr
3、下载sysbench
cd /tmp bzr branch lp:sysbench
4、安装依赖,否则报错
yum -y install m4 autoconf automake libtool 例如:libtoolize 1.4+ wasn't found, exiting
5、安装sysbench
./autogen.sh ./configure --prefix=/usr/local/sysbench -with-mysql-includes=/usr/local/mysql/include --with-mysql-libs=/usr/local/mysql/lib make make install #复制lua脚本至安装目录上去 cp -a sysbench/tests/db /usr/local/sysbench/ #设置环境变量 echo "export PATH=\$PATH:/usr/local/sysbench/bin/" >/etc/profile.d/sysbench.sh source /etc/profile.d/sysbench.sh
6、创建数据库sbtest
CREATE DATABASE `sbtest` /*!40100 DEFAULT CHARACTER SET utf8 */
7、初始化测试数据
sysbench --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=xxxxxx \
--test=/usr/local/sysbench/db/oltp.lua --oltp_tables_count=10 --oltp-table-size=100000 --rand-init=on prepare
8、压测mysql
sysbench --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root \
--mysql-password=xxxxxx --test=/usr/local/sysbench/db/oltp.lua --oltp_tables_count=10 \
--oltp-table-size=10000000 --num-threads=8 --oltp-read-only=off \
--report-interval=10 --rand-type=uniform --max-time=3600 \
--max-requests=0 --percentile=99 run
9、清除测试数据
sysbench --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=xxxxxx \
--test=/usr/local/sysbench/db/oltp.lua --oltp_tables_count=10 --oltp-table-size=100000 --rand-init=on cleanup