MySQL 数据库 Sysbench压力测试

环境

OS: centos7.x
DB: mysql 5.7.x
IP: 192.168.94.20

sysbench安装

1. 安装阿里云 yum 源

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

2. 安装sysbench工具

yum -y install sysbench

3. 查看版本

sysbench --version

mysql数据库测试

1. MySQL初始化 (创建测试用户和测试库)

create database sysbench;
create user 'sysbench'@'%' identified by 'sysbench';
grant all on sysbench.* to 'sysbench'@'%';

2.测试MySQL数据库
1. 准备

sysbench /usr/share/sysbench/tests/include/oltp_legacy/oltp.lua --db-driver=mysql --mysql-host=192.168.94.20 --mysql-port=3306 --mysql-db=sysbench --mysql-table-engine=innodb --mysql-user=sysbench --mysql-password=sysbench --oltp-tables-count=8 --oltp-table-size=100000 prepare

2. 测试

sysbench /usr/share/sysbench/tests/include/oltp_legacy/oltp.lua --db-driver=mysql --mysql-host=192.168.94.20 --mysql-port=3306 --mysql-db=sysbench --mysql-table-engine=innodb --mysql-user=sysbench --mysql-password=sysbench --oltp-tables-count=8 --oltp-table-size=100000 --threads=12 --oltp-dist-type=uniform --rand-init=on --events=0 --oltp-test-mode=nontrx --oltp-nontrx-mode=select --oltp-read-only=on --oltp-skip-trx=on --time=600 --report-interval=5 run

3.清理

sysbench /usr/share/sysbench/tests/include/oltp_legacy/oltp.lua --db-driver=mysql --mysql-host=192.168.94.20 --mysql-port=3306 --mysql-db=sysbench --mysql-table-engine=innodb --mysql-user=sysbench --mysql-password=sysbench cleanup

proxySQL 测试

1.登陆proxysql测试

mysql -uproxysql -pproxysql -h192.168.94.22 -P6033

准备

sysbench /usr/share/sysbench/tests/include/oltp_legacy/oltp.lua --db-driver=mysql --mysql-host=192.168.94.22 --mysql-port=6033 --mysql-db=sysbench --mysql-table-engine=innodb --mysql-user=proxysql --mysql-password=proxysql --oltp-tables-count=8 --oltp-table-size=100000 prepare

qps测试

sysbench /usr/share/sysbench/tests/include/oltp_legacy/oltp.lua --db-driver=mysql --mysql-host=192.168.94.22 --mysql-port=6033 --mysql-db=sysbench --mysql-table-engine=innodb --mysql-user=proxysql --mysql-password=proxysql --oltp-tables-count=8 --oltp-table-size=100000 --threads=50 --oltp-dist-type=uniform --rand-init=on --events=0 --oltp-test-mode=nontrx --oltp-nontrx-mode=select --oltp-read-only=on --oltp-skip-trx=on --time=60 --report-interval=5 run

dml测试

sysbench /usr/share/sysbench/tests/include/oltp_legacy/oltp.lua --db-driver=mysql --mysql-host=192.168.94.22 --mysql-port=6033 --mysql-db=sysbench --mysql-table-engine=innodb --mysql-user=proxysql --mysql-password=proxysql --oltp-tables-count=8 --oltp-table-size=100000 --threads=50 --oltp-dist-type=uniform --rand-init=on --events=0 --oltp-read-only=off --time=60 --report-interval=5 run

清理测试数据

sysbench /usr/share/sysbench/tests/include/oltp_legacy/oltp.lua --db-driver=mysql --mysql-host=192.168.94.22 --mysql-port=6033 --mysql-db=sysbench --mysql-table-engine=innodb --mysql-user=proxysql --mysql-password=proxysql cleanup

posted @ 2020-03-31 15:22  杨哥哥  阅读(575)  评论(0)    收藏  举报