Sysbench 1.0.15安裝及使用

Sysbench是一款開源的多線程性能測試工具,可以執行CPU/內存/線程/IO/數據庫等方面的性能測試,數據庫目前支持MySQL/Oracle/PostgreSQL。

一、安裝:

Github地址:
https://github.com/akopytov/sysbench

RHEL/CentOS:

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

sudo yum -y install sysbench

Sysbench可以測試如下:

•   oltp_*.lua: a collection of OLTP-like database benchmarks(腳本默認放在/usr/share/sysbench/)
•   fileio: a filesystem-level benchmark
•   cpu: a simple CPU benchmark
•   memory: a memory access benchmark
•   threads: a thread-based scheduler benchmark
•   mutex: a POSIX mutex benchmark

二、相關信息:

1、通用選項:

General options:            # 通用選項
  --threads=N               要使用的線程數,默認 1 個 [1]
  --events=N                最大允許的事件個數,默認爲[0]
  --time=N                  最大的總執行時間,以秒爲單位默認爲[10]
  --thread-stack-size=SIZE     每個線程的堆棧大小,默認爲[64K]
  --rate=N                   指定數量多少事件(事務)平均每秒鐘應該執行的所有線程。0(默認)意味着無限的速率,即事件儘快執行
  --report-interval=N          以秒爲單位定期報告具有指定間隔的中間統計信息, 0 禁用中間報告,默認爲0
  --debug[=on|off]             打印更多 debug 信息 [off]
  --validate[=on|off]            儘可能執行驗證檢查 [off]
  --help[=on|off]               顯示幫助信息並退出 [off]
  --version[=on|off]             顯示版本信息並退出 [off]
  --config-file=FILENAME        包含命令行選項的文件
  --tables=N                   表數量(數據庫測試)
  --table-size=N                   表大小
  --tx-rate=N                   廢棄,改用 --rate [0]
  --max-requests=N             廢棄,改用 --events [0]
  --max-time=N                 廢棄,改用 --time [0]
  --num-threads=N              廢棄,改用 --threads [1]

2、數據庫專用選項:

mysql options:              # MySQL 數據庫專用選項
  --mysql-host=[LIST,...]          MySQL server host [localhost]
  --mysql-port=[LIST,...]          MySQL server port [3306]
  --mysql-socket=[LIST,...]        MySQL socket
  --mysql-user=STRING              
  --mysql-password=STRING         
  --mysql-db=STRING               
  --mysql-ssl[=on|off]             
  --mysql-ssl-cipher=STRING       
  --mysql-compression[=on|off]     
  --mysql-debug[=on|off]          
  --mysql-ignore-errors=[LIST,...] 
  --mysql-dry-run[=on|off]         

pgsql options:              # PostgreSQL 數據庫專用選項
  --pgsql-host=STRING     
  --pgsql-port=N          
  --pgsql-user=STRING     
  --pgsql-password=STRING 
  --pgsql-db=STRING       

3、腳本:

默認放在/usr/share/sysbench/,有如下腳本

bulk_insert.lua;
oltp_delete.lua;
oltp_point_select.lua;
oltp_read_write.lua;
oltp_update_non_index.lua;
select_random_points.lua;
oltp_common.lua;
oltp_insert.lua;
oltp_read_only.lua;
oltp_update_index.lua;
oltp_write_only.lua;
select_random_ranges.lua

三、測試:

這裏僅做數據庫測試,其他測試可以是用sysbench –help,sysbench cpu help等查看相應參數。

流程:1、建測試表及數據;2、進行測試;3清除數據。(1、prepare;2、run;3、cleanup)

1、 建測試表及數據:
線程,數據表大小及數量及其他參數按需求修改即可
sysbench oltp_read_write.lua --time=60 --mysql-host=192.168.100.127 --mysql-port=3506 --mysql-user=test --mysql-password=123456 --mysql-db=pcms --table-size=10000 --tables=2 --threads=2 prepare

2、 測試數據:
sysbench oltp_read_write.lua --time=60 --mysql-host=192.168.100.127 --mysql-port=3506 --mysql-user=test --mysql-password=123456 --mysql-db=pcms --table-size=10000 --tables=2 --threads=2 run

3、 清洗數據:
sysbench oltp_read_write.lua --time=60 --mysql-host=192.168.100.127 --mysql-port=3506 --mysql-user=test --mysql-password=123456 --mysql-db=pcms --table-size=10000 --tables=2 --threads=2 cleanup
(直接刪除測試表當然也可以~)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章