sysbench对postgresql
一、sysbench安装
PostgreSQL 11 tpcc 测试(103万tpmC on ECS) - use sysbench-tpcc by Percona-Lab=>参考
1)下载解压
yum install gcc gcc-c++ automake make libtool mysql-community-devel mysql-devel
yum -y install make automake libtool pkgconfig libaio-devel
wget https://github.com/akopytov/sysbench/archive/1.0.zip -O "sysbench-1.0.zip"
git clone https://github.com/akopytov/sysbench
unzip sysbench-1.0.zip
cd sysbench-1.0
(2)安装依赖
yum install automake libtool –y
yum -y install postgresql-devel
(3)安装
安装之前,确保位于之前解压的sysbench目录中。
./autogen.sh
./configure
./configure --prefix=/var/lib/pgsql/sysbench --with-pgsql --without-mysql --with-pgsql-includes=/usr/pgsql-11/include --with-pgsql-libs=/usr/pgsql-11/lib make -j 128 make install 例:export LD_LIBRARY_PATH=/usr/local/mysql/include #这里换成机器中mysql路径下的include
(4)安装成功
sysbench —version
注:find / -name sysbench
find / -name "oltp*.lua"
sysbench --help
sysbench prepare for postgresql
sysbench \ --db-driver=pgsql \ --pgsql-host=127.0.0.1 \ --pgsql-port=5432 \ --pgsql-user=postgres \ --pgsql-password=postgres \ --pgsql-db=postgres \ --oltp-table-size=10000 \ --rand-init=on \ --threads=10 \ --time=120 \ --events=0 \ --report-interval=10 \ --percentile=99 \ /usr/share/sysbench/tests/include/oltp_legacy/oltp.lua \ prepare
简单说明下:
# --oltp-table-size=10000 测试表的记录数。默认是10000
# --threads=10 表示发起 10 个并发连接
# --time=120 表示执行120秒
# --events=0 表示总请求数为 0,因为上面已经定义了总执行时长,所以总请求数可以设定为 0;也可以只设定总请求数,不设定最大执行时长
# --report-interval=10 表示每10秒输出一次测试进度报告
# --percentile=99 表示设定采样比例,默认是 95%,即丢弃1%的长请求,在剩余的99%里取最大值
sysbench run for postgresql
sysbench \ --db-driver=pgsql \ --pgsql-host=127.0.0.1 \ --pgsql-port=5432 \ --pgsql-user=postgres \ --pgsql-password=postgres \ --pgsql-db=postgres \ --oltp-table-size=10000 \ --threads=10 \ --time=120 \ --events=0 \ --report-interval=10 \ --percentile=99 \ /usr/share/sysbench/tests/include/oltp_legacy/oltp.lua \ run
测试结果如下:
sysbench cleanup for postgresql
sysbench \ --db-driver=pgsql \ --pgsql-host=127.0.0.1 \ --pgsql-port=5432 \ --pgsql-user=postgres \ --pgsql-password=postgres \ --pgsql-db=postgres \ --oltp-table-size=10000 \ --threads=10 \ --time=120 \ --events=0 \ --report-interval=10 \ --percentile=99 \ /usr/share/sysbench/tests/include/oltp_legacy/oltp.lua \ cleanup
eg:
执行默认oltp测试用例
sysbench oltp_common --pgsql-host=ip --pgsql-port=5433 --pgsql-user=postgres --pgsql-password=admin_123 --pgsql-db=postgres --table-size=100000000 prepare
生成数据
oltp_common #生成库的脚本
prepare #运行的命令
--oltp_tables_count=10 用来指定生成多少张表
sysbench oltp_read_only(oltp_write_only) --pgsql-host=ip --pgsql-port=5433 --pgsql-user=postgres --pgsql-password=admin_123 --pgsql-db=postgres --table-size=100000000 --time=10 --threads=8 run
--测试postgresql ./sysbench --test=oltp --oltp-table-size=10000 --pgsql-host=127.0.0.1 --pgsql-port=5432 --pgsql-user=postgres --pgsql-password=123456 --pgsql-db=postgres --db-driver=pgsql prepare
./sysbench --max-requests=0 --max-time=60 --num-threads=16 --test=oltp --db-driver=pgsql --pgsql-host=127.0.0.1 --pgsql-port=5432 --pgsql-user=postgres --pgsql-password=123456 --pgsql-db=postgres --oltp-test-mode=simple --oltp-reconnect-mode=session run
./sysbench --test=oltp --db-driver=pgsql --pgsql-host=127.0.0.1 --pgsql-port=5432 --pgsql-user=postgres --pgsql-password=123456 --pgsql-db=postgres cleanup
磁盘IO
sysbench --file-fsync-all --file-num=100 --file-total-size=10G --file-test-mode=seqwr fileio run
内存
sysbench --memory-total-size=50G memory run