一、安装sysbench
1.下载sysbench
wget https://codeload.github.com/akopytov/sysbench/tar.gz/1.0.17 && mv 1.0.17 sysbench-1.0.17.tar.gz
tar -xzvf /root/sysbench-1.0.17.tar.gz -C /root/ && cd /root/sysbench-1.0.17
2.安装依赖包:
yum -y install make automake libtool pkgconfig libaio-devel
yum -y install mariadb-devel openssl-devel
yum -y install postgresql-devel
3.编译sysbench
chmod 755 -R /root/sysbench-1.0.17/
./autogen.sh
./configure --with-pgsql
make -j 128
make install
4.查看版本信息
sysbench --version
5.目录说明:
编译完成sysbench目录:/usr/local/share/sysbench
压测对应sql脚本所在目录:/usr/local/share/sysbench/tests/include/oltp_legacy
二、sysbench压测postgresql
1.vastbase下创建数据库:
create user sysbench identified by 'sysbench@123';
grant all privileges to sysbench;
create database sysbench with LC_COLLATE='C' LC_CTYPE='C' owner sysbench;
2.准备创建表和数据:
sysbench --db-driver=pgsql --time=1 --threads=10 --report-interval=5 --pgsql-host=10.0.0.151 --pgsql-port=26000 --pgsql-user=sysbench --pgsql-password=sysbench@123 --pgsql-db=sysbench --tables=1 --table_size=10 oltp_read_write --db-ps-mode=disable prepare
image.png
3.测试数据库的只读性能,使用的是oltp_read_only模式:
sysbench --db-driver=pgsql --time=10 --threads=10 --report-interval=1 --pgsql-host=10.0.0.151 --pgsql-port=26000 --pgsql-user=sysbench --pgsql-password=sysbench@123 --pgsql-db=sysbench --tables=1 --table_size=10 oltp_read_only --db-ps-mode=disable run
image.png
image.png
网友评论