sysbench 使用指北

sysbench
是一個模塊化、跨平臺、多線程基準測試工具,主要用於測試各類不一樣系統參數下的數據庫負載狀況。
主要包括如下幾種方式的測試:CPU性能、磁盤IO性能,線程調度性能。內存分配以及傳輸速度和數據庫性能。
下面主要使用它用來測試數據庫。mysql

sysbench github地址:https://github.com/akopytov/sysbench
sysbench安裝:git

curl -s https://packagecloud.io/install/repositories/akopytov/sysbench/script.rpm.sh | sudo bash
sudo yum -y install sysbench

源碼安裝:github

Building and Installing From Source
yum -y install make automake libtool pkgconfig libaio-devel
# For MySQL support, replace with mysql-devel on RHEL/CentOS 5
yum -y install mariadb-devel openssl-devel
# For PostgreSQL support
yum -y install postgresql-devel

 ./autogen.sh
# Add --with-pgsql to build with PostgreSQL support
./configure
make -j
make install

sysbench測試過程
lua腳本位置(指定測試用例)sql

find / -name oltp.lua
/usr/share/sysbench/tests/include/oltp_legacy

一、數據準備階段數據庫

# sysbench  /usr/share/sysbench/tests/include/oltp_legacy/oltp.lua --mysql-table-engine=innodb --table_size=100000 --threads=20 --oltp-tables-count=3  --mysql-db=test --mysql-user=root --mysql-host=localhost --mysql-password=MyNewPass4! prepare

二、數據測試階段bash

# sysbench /usr/share/sysbench/tests/include/oltp_legacy/oltp.lua --mysql-table-engine=innodb --oltp-table-size=1000000 --oltp-tables-count=3 --mysql-db=test --mysql-user=root --mysql-host=localhost --mysql-password=MyNewPass4! --time=60 --max-requests=0 --threads=8 --report-interval=10 run

--threads=8     //線程數爲8
--time=60       //測試時間爲60s
--report-interval=10  //報告打印週期爲10s,每10s打印一次
--oltp-read-only=off  //非只讀操做測試多線程

三、數據清理階段curl

# sysbench /usr/share/sysbench/tests/include/oltp_legacy/oltp.lua --mysql-table-engine=innodb --oltp-tables-count=3 --oltp-table-size=1000000 --mysql-db=test --mysql-user=root --mysql-host=localhost --mysql-password=MyNewPass4! cleanup

下次再仔細分析下測試結果。ide

相關文章
相關標籤/搜索