sysbench安装部署for mysql

 

下载地址:

https://github.com/akopytov/sysbench/tree/1.0.20

 

1.解压
unzip sysbench-1.0.zip
mv sysbench-1.0 /opt/


2.执行脚本
[root@localhost sysbench-1.0]# ./autogen.sh

3.编译
./configure --prefix=/usr/local/sysbencd_1.0 --with-mysql-includes=/opt/mysql5730/include --with-mysql-libs=/opt/mysql5730/lib
make && make install

4.使用
/opt/mysql5730/bin/mysql -h localhost -uroot -pmysql

/usr/local/sysbencd_1.0/bin/sysbench --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password='mysql' --test=/opt/sysbench-1.0/tests/include/oltp_legacy/oltp.lua --oltp_tables_count=10 --oltp-table-size=1000 --rand-init=on prepare

/usr/local/sysbencd_1.0/bin/sysbench: error while loading shared libraries: libmysqlclient.so.20: cannot open shared object file: No such file or directory

解决办法:
加入环境变量
LD_LIBRARY_PATH=/opt/mysql5730/lib:$LD_LIBRARY_PATH

创建10个表,每个表数据库1000
[root@localhost ~]# /usr/local/sysbencd_1.0/bin/sysbench --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password='mysql' --test=/opt/sysbench-1.0/tests/include/oltp_legacy/oltp.lua --oltp_tables_count=10 --oltp-table-size=1000 --rand-init=on prepare
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)

FATAL: unable to connect to MySQL server on host '127.0.0.1', port 3306, aborting...
FATAL: error 1049: Unknown database 'sbtest'
FATAL: `prepare' function failed: /opt/sysbench-1.0/tests/include/oltp_legacy/common.lua:111: Failed to connect to the database
[root@localhost ~]#

解决办法:
create database sbtest;



/usr/local/sysbencd_1.0/bin/sysbench --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password='mysql' --test=/opt/sysbench-1.0/tests/include/oltp_legacy/oltp.lua --oltp_tables_count=10 --oltp-table-size=1000 --rand-init=on prepare
/usr/local/sysbencd_1.0/bin/sysbench --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password='mysql' --test=/opt/sysbench-1.0/tests/include/oltp_legacy/oltp.lua --oltp_tables_count=10 --oltp-table-size=1000 --num-threads=8 --oltp-read-only=off --report-interval=10 --rand-type=uniform --max-time=120 --max-requests=0 --percentile=99 run >> /tmp/sysbench_oltp.log
# --num-threads=8 表示发起 8个并发连接
# --oltp-read-only=off 表示不要进行只读测试,也就是会采用读写混合模式测试
# --report-interval=10 表示每10秒输出一次测试进度报告
# --rand-type=uniform 表示随机类型为固定模式,其他几个可选随机模式:uniform(固定),gaussian(高斯),special(特定的),pareto(帕累托)
# --max-time=120 表示最大执行时长为 120秒
# --max-requests=0 表示总请求数为 0,因为上面已经定义了总执行时长,所以总请求数可以设定为 0;也可以只设定总请求数,不设定最大执行时长
# --percentile=99 表示设定采样比例,默认是 95%,即丢弃1%的长请求,在剩余的99%里取最大值


--测试mysql
/usr/local/sysbencd_1.0/bin/sysbench --test=/opt/sysbench-1.0/tests/include/oltp_legacy/oltp.lua --oltp-table-size=10000 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=mysql --mysql-db=db_test --db-driver=mysql prepare
/usr/local/sysbencd_1.0/bin/sysbench --test=/opt/sysbench-1.0/tests/include/oltp_legacy/oltp.lua --max-requests=0 --max-time=60 --num-threads=16 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=mysql --mysql-db=db_test --db-driver=mysql --oltp-reconnect-mode=session --oltp-test-mode=simple run
/usr/local/sysbencd_1.0/bin/sysbench --test=/opt/sysbench-1.0/tests/include/oltp_legacy/oltp.lua --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=mysql --mysql-db=db_test --db-driver=mysql cleanup

 

测试例子2

 

##准备数据
/usr/local/sysbencd_1.0/bin/sysbench --db-driver=mysql --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=mysql --mysql-db=db_test --table_size=10000 --tables=10 --events=0 --time=120 oltp_read_write prepare

##运行workload
/usr/local/sysbencd_1.0/bin/sysbench --mysql-ignore-errors="all" --db-driver=mysql --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=mysql --mysql-db=db_test --table_size=10000 --tables=10 --events=0 --time=120   --threads=1024 --percentile=95 --report-interval=1 oltp_read_write run

##清理
/usr/local/sysbencd_1.0/bin/sysbench --db-driver=mysql  --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=mysql --mysql-db=db_test --table_size=10000 --tables=10 --events=0 --time=120   --threads=1024 --percentile=95  oltp_read_write cleanup

 

posted @ 2020-12-23 13:40  slnngk  阅读(460)  评论(0编辑  收藏  举报