一、安裝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
壓測對應(yīng)sql腳本所在目錄:/usr/local/share/sysbench/tests/include/oltp_legacy
二、sysbench壓測postgresql
1.vastbase下創(chuàng)建數(shù)據(jù)庫:
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.準備創(chuàng)建表和數(shù)據(jù):
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.測試數(shù)據(jù)庫的只讀性能,使用的是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