Sysbench 0.5
使用Sysbench 0.5客户端登录MySQL数据库服务器并进行压力测试,可以通过执行脚本或执行命令两种方式进行测试。
执行脚本方式
- 下载脚本并存放至“/home”目录。
1 2
cd /home/ wget https://mirrors.huaweicloud.com/kunpeng/archive/kunpeng_solution/database/scripts/sysbench-0.5-script.zip --no-check-certificate
也可以通过浏览器下载脚本,并上传至“/home”目录。下载地址:https://mirrors.huaweicloud.com/kunpeng/archive/kunpeng_solution/database/scripts/sysbench-0.5-script.zip
- 解压并修改脚本。
- 解压脚本。
1
unzip sysbench-0.5-script.zip
- 进入脚本目录。
1
cd /home/sysbench-0.5-script
- 修改runall.sh脚本的参数。参考表1并根据实际情况设置参数值。
1
vi runall.sh
- 依次修改以下9个模型的脚本参数。另外,还需要修改如下参数:
- 线程并发数设置为64,128,256,512。
- 每个并发执行的时间设置为120秒,TIME=${TIME:-120}。
- run和$CMD的前面分别添加--forced-shutdown=1。
1
--forced-shutdown=1
打开9个模型脚本的命令如下。
1 2 3 4 5 6 7 8 9
vi test_oltp_distinct.sh vi test_oltp_index.sh vi test_oltp_nonindex.sh vi test_oltp_order.sh vi test_oltp_point.sh vi test_oltp_simple.sh vi test_oltp_sum.sh vi test_oltp_delete.sh vi test_oltp_mix.sh
- 解压脚本。
- 执行模型脚本。
在执行写场景(INDEX、NONINDEX、DELETE)之前,如果数据库没重启,需要先执行1次OLTP MIX场景的脚本以进行预热。
- 方式一:分别执行单个模型的脚本。绑核和参数值请根据实际情况设置。
- 修改脚本权限以获得文件执行权限。
1 2
cd /home/sysbench-0.5-script chmod 777 *
- 执行模型脚本。
OLTP DISTINCT读场景
1
numactl -C 80-127 ./test_oltp_distinct.sh -h 192.168.221.156 -P 3306 -u root -p 123456 -D sysbench -C 100 -S 1000000 -t 512 -c run
OLTP INDEX写场景
1
numactl -C 80-127 ./test_oltp_index.sh -h 192.168.221.156 -P 3306 -u root -p 123456 -D sysbench -C 100 -S 1000000 -t 512 -c run
OLTP NONINDEX写场景
1
numactl -C 80-127 ./test_oltp_nonindex.sh -h 192.168.221.156 -P 3306 -u root -p 123456 -D sysbench -C 100 -S 1000000 -t 512 -c run
OLTP ORDER读场景
1
numactl -C 80-127 ./test_oltp_order.sh -h 192.168.221.156 -P 3306 -u root -p 123456 -D sysbench -C 100 -S 1000000 -t 512 -c run
OLTP POINT读场景
1
numactl -C 80-127 ./test_oltp_point.sh -h 192.168.221.156 -P 3306 -u root -p 123456 -D sysbench -C 100 -S 1000000 -t 512 -c run
OLTP SIMPLE读场景
1
numactl -C 80-127 ./test_oltp_simple.sh -h 192.168.221.156 -P 3306 -u root -p 123456 -D sysbench -C 100 -S 1000000 -t 512 -c run
OLTP SUM读场景
1
numactl -C 80-127 ./test_oltp_sum.sh -h 192.168.221.156 -P 3306 -u root -p 123456 -D sysbench -C 100 -S 1000000 -t 512 -c run
OLTP DELETE写场景
1
numactl -C 80-127 ./test_oltp_delete.sh -h 192.168.221.156 -P 3306 -u root -p 123456 -D sysbench -C 100 -S 1000000 -t 512 -c run
OLTP MIX混合场景
1
numactl -C 80-127 ./test_oltp_mix.sh -h 192.168.221.156 -P 3306 -u root -p 123456 -D sysbench -C 100 -S 1000000 -t 512 -c run
- 修改脚本权限以获得文件执行权限。
- 方式二:全量执行脚本。
1 2 3
cd /home/sysbench-0.5-script chmod 777 * sh runall.sh > result-arm.txt
执行模型脚本完成后,测试结果将保存于result-arm.txt文件中。
- 方式一:分别执行单个模型的脚本。绑核和参数值请根据实际情况设置。
模型 |
命令 |
---|---|
OLTP DISTINCT |
/home/sysbench-0.5/sysbench/sysbench --test=/home/sysbench-0.5/sysbench/tests/db/oltp.lua --db-driver=mysql --debug=off --mysql-db=sysbench --mysql-password=123456 --oltp-tables-count=100 --oltp-distinct-ranges=1 --oltp-index-updates=0 --oltp-non-index-updates=0 --oltp-order-ranges=0 --oltp-point-selects=0 --oltp-simple-ranges=0 --oltp-sum-ranges=0 --oltp_delete_inserts=0 --oltp-table-size=1000000 --num-threads=512 --max-requests=0 --max-time=60 --oltp-auto-inc=off --mysql-engine-trx=yes --oltp-test-mod=complex --mysql-host=192.168.222.120 --mysql-port=3306 --mysql-user=root --oltp-user-delay-min=10 --oltp-user-delay-max=100 --report-interval=10 --forced-shutdown=1 run |
OLTP INDEX |
/home/sysbench-0.5/sysbench/sysbench --test=/home/sysbench-0.5/sysbench/tests/db/oltp.lua --db-driver=mysql --debug=off --mysql-db=sysbench --mysql-password=123456 --oltp-tables-count=100 --oltp-distinct-ranges=0 --oltp-index-updates=1 --oltp-non-index-updates=0 --oltp-order-ranges=0 --oltp-point-selects=0 --oltp-simple-ranges=0 --oltp-sum-ranges=0 --oltp_delete_inserts=0 --oltp-table-size=1000000 --num-threads=512 --max-requests=0 --max-time=60 --oltp-auto-inc=off --mysql-engine-trx=yes --oltp-test-mod=complex --mysql-host=192.168.222.120 --mysql-port=3306 --mysql-user=root --oltp-user-delay-min=10 --oltp-user-delay-max=100 --report-interval=10 --forced-shutdown=1 run |
OLTP NONINDEX |
/home/sysbench-0.5/sysbench/sysbench --test=/home/sysbench-0.5/sysbench/tests/db/oltp.lua --db-driver=mysql --debug=off --mysql-db=sysbench --mysql-password=123456 --oltp-tables-count=100 --oltp-distinct-ranges=0 --oltp-index-updates=0 --oltp-non-index-updates=1 --oltp-order-ranges=0 --oltp-point-selects=0 --oltp-simple-ranges=0 --oltp-sum-ranges=0 --oltp_delete_inserts=0 --oltp-table-size=1000000 --num-threads=512 --max-requests=0 --max-time=60 --oltp-auto-inc=off --mysql-engine-trx=yes --oltp-test-mod=complex --mysql-host=192.168.222.120 --mysql-port=3306 --mysql-user=root --oltp-user-delay-min=10 --oltp-user-delay-max=100 --report-interval=10 --forced-shutdown=1 run |
OLTP ORDER |
/home/sysbench-0.5/sysbench/sysbench --test=/home/sysbench-0.5/sysbench/tests/db/oltp.lua --db-driver=mysql --debug=off --mysql-db=sysbench --mysql-password=123456 --oltp-tables-count=100 --oltp-distinct-ranges=0 --oltp-index-updates=0 --oltp-non-index-updates=0 --oltp-order-ranges=1 --oltp-point-selects=0 --oltp-simple-ranges=0 --oltp-sum-ranges=0 --oltp_delete_inserts=0 --oltp-table-size=1000000 --num-threads=512 --max-requests=0 --max-time=60 --oltp-auto-inc=off --mysql-engine-trx=yes --oltp-test-mod=complex --mysql-host=192.168.222.120 --mysql-port=3306 --mysql-user=root --oltp-user-delay-min=10 --oltp-user-delay-max=100 --report-interval=10 --forced-shutdown=1 run |
OLTP POINT |
/home/sysbench-0.5/sysbench/sysbench --test=/home/sysbench-0.5/sysbench/tests/db/oltp.lua --db-driver=mysql --debug=off --mysql-db=sysbench --mysql-password=123456 --oltp-tables-count=100 --oltp-distinct-ranges=0 --oltp-index-updates=0 --oltp-non-index-updates=0 --oltp-order-ranges=0 --oltp-point-selects=1 --oltp-simple-ranges=0 --oltp-sum-ranges=0 --oltp_delete_inserts=0 --oltp-table-size=1000000 --num-threads=512 --max-requests=0 --max-time=60 --oltp-auto-inc=off --mysql-engine-trx=yes --oltp-test-mod=complex --mysql-host=192.168.222.120 --mysql-port=3306 --mysql-user=root --oltp-user-delay-min=10 --oltp-user-delay-max=100 --report-interval=10 --forced-shutdown=1 run |
OLTP SIMPLE |
/home/sysbench-0.5/sysbench/sysbench --test=/home/sysbench-0.5/sysbench/tests/db/oltp.lua --db-driver=mysql --debug=off --mysql-db=sysbench --mysql-password=123456 --oltp-tables-count=100 --oltp-distinct-ranges=0 --oltp-index-updates=0 --oltp-non-index-updates=0 --oltp-order-ranges=0 --oltp-point-selects=0 --oltp-simple-ranges=1 --oltp-sum-ranges=0 --oltp_delete_inserts=0 --oltp-table-size=1000000 --num-threads=512 --max-requests=0 --max-time=60 --oltp-auto-inc=off --mysql-engine-trx=yes --oltp-test-mod=complex --mysql-host=192.168.222.120 --mysql-port=3306 --mysql-user=root --oltp-user-delay-min=10 --oltp-user-delay-max=100 --report-interval=10 --forced-shutdown=1 run |
OLTP SUM |
/home/sysbench-0.5/sysbench/sysbench --test=/home/sysbench-0.5/sysbench/tests/db/oltp.lua --db-driver=mysql --debug=off --mysql-db=sysbench --mysql-password=123456 --oltp-tables-count=100 --oltp-distinct-ranges=0 --oltp-index-updates=0 --oltp-non-index-updates=0 --oltp-order-ranges=0 --oltp-point-selects=0 --oltp-simple-ranges=0 --oltp-sum-ranges=1 --oltp_delete_inserts=0 --oltp-table-size=1000000 --num-threads=512 --max-requests=0 --max-time=60 --oltp-auto-inc=off --mysql-engine-trx=yes --oltp-test-mod=complex --mysql-host=192.168.222.120 --mysql-port=3306 --mysql-user=root --oltp-user-delay-min=10 --oltp-user-delay-max=100 --report-interval=10 --forced-shutdown=1 run |
OLTP DELETE |
/home/sysbench-0.5/sysbench/sysbench --test=/home/sysbench-0.5/sysbench/tests/db/oltp.lua --db-driver=mysql --debug=off --mysql-db=sysbench --mysql-password=123456 --oltp-tables-count=100 --oltp-distinct-ranges=0 --oltp-index-updates=0 --oltp-non-index-updates=0 --oltp-order-ranges=0 --oltp-point-selects=0 --oltp-simple-ranges=0 --oltp-sum-ranges=0 --oltp_delete_inserts=1 --oltp-table-size=1000000 --num-threads=512 --max-requests=0 --max-time=60 --oltp-auto-inc=off --mysql-engine-trx=yes --oltp-test-mod=complex --mysql-host=192.168.222.120 --mysql-port=3306 --mysql-user=root --oltp-user-delay-min=10 --oltp-user-delay-max=100 --report-interval=10 --forced-shutdown=1 run |
OLTP MIX |
/home/sysbench-0.5/sysbench/sysbench --test=/home/sysbench-0.5/sysbench/tests/db/oltp.lua --db-driver=mysql --debug=off --mysql-db=sysbench --mysql-password=123456 --oltp-tables-count=100 --oltp-table-size=1000000 --num-threads=512 --max-requests=0 --max-time=60 --oltp-auto-inc=off --mysql-engine-trx=yes --oltp-test-mod=complex --mysql-host=192.168.222.120 --mysql-port=3306 --mysql-user=root --oltp-user-delay-min=10 --oltp-user-delay-max=100 --report-interval=10 --forced-shutdown=1 run |
参数 |
参数说明 |
---|---|
--mysql-db |
这里加载数据的库和测试的库保持一致,否则会出现连接不到mysql server的报错。 |
--num-threads |
表示线程数。如果提示Too many connections,可以适当把值调小。 |
--test: |
用于指定测试模型。 |
--oltp-tables-count: |
用于设置生成表的数量。 |
--oltp-table-size: |
用于指定每个生成表的大小。 |
--num-threads: |
用于指定测试的线程数。 |
--mysql-password: |
用于指定登录MySQL服务器的用户密码。 |
--mysql-user: |
用于指定登录MySQL服务器的用户。 |
--mysql-port: |
用于指定登录MySQL服务器的端口号。 |
--mysql-host: |
用于指定MySQL服务器的IP地址。 |
--max-time |
用于指定测试执行的时间,单位为秒。 |