环境准备

 

测试环境

操作系统

centos7.8

Cpu

 Intel(R) Xeon(R) E5-2670 (32核)

内存

32G

磁盘

500G

数据库版本

DM8 单机

 

 

a. 初始化数据库

b. 前台方式启动数据库服务

c. 设置数据库的参数

d. 重启数据库服务

e. 扩展表空间以及日志

说明:扩展roll表空间文件及日志文件,保证测试过程中不刷检查点。

alter tablespace "ROLL" resize datafile 'ROLL.DBF' to 20000;

alter tablespace "MAIN" resize datafile 'MAIN.DBF' to 20000;

alter database resize logfile 'DAMENG01.log' to 50000;

alter database resize logfile 'DAMENG02.log' to 50000;

 测试工具

链接:https://pan.baidu.com/s/1zf5lhfNfbslezxWUvz1Hdw

提取码:1432

unzip sysbench-master-dm.zip -d /opt/sysbench-master

cd /opt/sysbench-master/

unzip sysbench-master-dpi-20200604-src.zip

cd sysbench-master-dpi/src/lua/

chmod +x sysbench

./sysbench --db-driver=dm --dm-db=192.168.10.72:5236 --dm-user=SYSDBA --dm-password=SYSDBA --table_size=25000 --tables=5 --events=0 --time=600 oltp_read_only prepare

sysbench压测mysql sysbench压测达梦_sysbench压测mysql

cd ../../

chmod +x autogen.sh

检查和安装gcc和libtool包

rpm -qa|grep gcc

yum -y install gcc

yum -y install automake libtool

./autogen.sh

检查数据库是否启动

ps -ef|grep dmdba

检查参数

echo $DM_HOME

sysbench压测mysql sysbench压测达梦_数据库_02

如果没有配置,添加配置

export DM_HOME=/dm8

sysbench压测mysql sysbench压测达梦_数据_03

chmod +x configure

./configure --without-mysql

make

cd src

mv sysbench ./lua/sysbenchnew

cd lua

sysbench压测mysql sysbench压测达梦_数据_04

 数据准备与执行

说明:因为sysbench需要dm数据库驱动,因此在执行此工具的机器上必须本地安装dm数据库,不启动服务都可以,sysbench主要是要调用dm数据库安装目录bin下的一个os动态库,不过给出的包已经带有所需的动态库,在/sysbench-master/src/lib64下,安装部署好dm数据库后,把sysbench解压到相关目录下:目录结构最好为/opt/sysbench-master

案例:

a. 数据准备

./sysbench oltp_read_write.lua --tables=25 --table-size=250000

--db-driver=dm --dm-db=localhost:5236 --dm-user=SYSDBA

--dm-password=SYSDBA001 --auto-inc=1 --threads=64 --time=180

--report-interval=10 prepare

n --table-size=250000 表示每个测试表填充数据量为 250000

n --tables=25表示25张表

n --threads=64 表示发起64个并发连接

n --report-interval=10 表示每10秒输出一次测试进度报告

n --time=180 表示最大执行时长为180秒

b. 上一步prepare执行完毕后,执行如下脚本进行测试:

./sysbench oltp_read_write.lua --tables=25 --table-size=250000

--db-driver=dm --dm-db=localhost:5236 --dm-user=SYSDBA

--dm-password=SYSDBA001 --auto-inc=1 --threads=64 --time=180

--report-interval=10 run

c. 上一步run执行完毕后,执行如下脚本进行清楚数据:

./sysbench oltp_read_write.lua --tables=25 --table-size=250000

--db-driver=dm --dm-db=localhost:5236 --dm-user=SYSDBA

--dm-password=SYSDBA001 --auto-inc=1 --threads=64 --time=180

--report-interval=10 cleanup

切记,每一次测试都是一个闭环: prepare---run---cleanup,不然会报错,必须严格按照这三步来进行

执行测试1:纯读

##准备数据

./sysbenchnew --db-driver=dm --dm-db=192.168.10.72:5236 --dm-user=SYSDBA --dm-password=SYSDBA --table_size=25000 --tables=25 --events=0 --time=600 oltp_read_only prepare

##运行workload

./sysbenchnew --db-driver=dm --dm-db=192.168.10.72:5236 --dm-user=SYSDBA --dm-password=SYSDBA --table_size=25000 --tables=25 --events=0 --time=600 --threads=32 --percentile=95 --range-selects=0 --skip-trx=1 --report-interval=1 oltp_read_only run

sysbench压测mysql sysbench压测达梦_数据_05

##清理

./sysbenchnew --db-driver=dm --dm-db=192.168.10.72:5236 --dm-user=SYSDBA --dm-password=SYSDBA --table_size=25000 --tables=25 --events=0 --time=600 --threads=32 --percentile=95 --range-selects=0 oltp_read_only cleanup

 

 

测试点2:纯写:

##准备数据

./sysbenchnew --db-driver=dm --dm-db=192.168.10.72:5236 --dm-user=SYSDBA --dm-password=SYSDBA --table_size=25000 --tables=25--events=0 --time=600 oltp_write_only prepare

##运行workload

./sysbenchnew --db-driver=dm --dm-db=192.168.10.72:5236 --dm-user=SYSDBA --dm-password=SYSDBA --table_size=25000 --tables=25 --events=0 --time=600 --threads=32 --percentile=95 --report-interval=1 oltp_write_only run

sysbench压测mysql sysbench压测达梦_数据_06

##清理

./sysbenchnew --db-driver=dm --dm-db=192.168.10.72:5236 --dm-user=SYSDBA --dm-password=SYSDBA --table_size=25000 --tables=25 --events=0 --time=600 --threads=32 --percentile=95 oltp_write_only cleanup

 

 

测试点3:读写

##准备数据

./sysbenchnew --db-driver=dm --dm-db=192.168.10.72:5236 --dm-user=SYSDBA --dm-password=SYSDBA --table_size=250000 --tables=25 --events=0 --time=600 oltp_read_write prepare

##运行workload

./sysbenchnew --db-driver=dm --dm-db=192.168.10.72:5236 --dm-user=SYSDBA --dm-password=SYSDBA --table_size=250000 --tables=25 --events=0 --time=600 --threads=32 --percentile=95 --report-interval=1 oltp_read_write run

sysbench压测mysql sysbench压测达梦_数据_07

##清理

./sysbenchnew --db-driver=dm --dm-db=192.168.10.72:5236 --dm-user=SYSDBA --dm-password=SYSDBA --table_size=250000 --tables=25 --events=0 --time=600 --threads=32 --percentile=95 oltp_read_write cleanup

 

 

我们一般关注的指标主要有:

  • response time avg:平均响应时间(后面的95%的大小可以通过–percentile=98的方式去更改)。
  • transactions:精确的说是这一项后面的TPS,但如果使用了–skip-trx=on,这项事务数为0,需要用total number of events去除以总时间,得到tps(其实还可以分为读tps和写tps)。
  • queries:用它除以总时间,得到吞吐量QPS。

 

sysbench压测mysql sysbench压测达梦_sysbench压测mysql_08

 

 

 

附录:服务器基准的IO能力测试

dd 测试磁盘写入速度

dd if=/dev/zero of=aaa bs=32k count=4k oflag=dsync

sysbench压测mysql sysbench压测达梦_数据_09

sysbench压测mysql sysbench压测达梦_数据_10

读取速率

dd if=aaa of=/dev/null iflag=dsync

sysbench压测mysql sysbench压测达梦_数据库_11

fio测试:

fio -filename=/dev/sdb -direct=1 -iodepth 1 -thread -rw=randrw -ioengine=psync -bs=32k -size=50G -numjobs=32 -runtime=100 -group_reporting -name=mytest

sysbench压测mysql sysbench压测达梦_lua_12

说明:

1) 注意cd到data文件目录下进行测试。

2) 请不要调整测试参数

3) Fio测试时,请注意记录IOPS和吞吐量(两个指标都很重要)

读写分离配置建议:

上述命令测试,建议可以提供:32k随机读写时IOPS保持在3k以上,吞吐量在80MBPS以上服务器。

 

网速测试

yum -y install git

git clone https://github.com/sivel/speedtest-cli.git

cd speedtest-cli/

./speedtest.py