一、工具介紹
Scriptable database and system performance benchmark
安裝詳見:https://www.cnblogs.com/phpfeng/p/9246213.html
具體使用:https://blog.csdn.net/ma15732625261/article/details/81355269
源碼地址: https://github.com/akopytov/sysbench#versioning
二、工具使用
第一步: 創建表
sysbench --threads=100 --report-interval=3 --max-requests=0 --time=300 /usr/share/sysbench/tests/include/oltp_legacy/insert.lua --mysql-table-engine=innodb --oltp-table-size=100 --oltp-tables-count=1 --rand-int=on --mysql-host=****** --mysql-port=3306 --mysql-user=**** --mysql-password=****** --mysql-db=******* --db-driver=mysql prepare
第二步:運行
sysbench --threads=800 --report-interval=3 --max-requests=0 --time=180000 /usr/share/sysbench/tests/include/oltp_legacy/insert.lua --mysql-table-engine=innodb --oltp-table-size=20000000 --oltp-tables-count=1 --rand-int=on --mysql-host=****** --mysql-port=3306 --mysql-user=******* --mysql-password=******* --mysql-db=******* --db-driver=mysql run
第三步:清理
sysbench --threads=100 --report-interval=3 --max-requests=0 --time=300 /usr/share/sysbench/tests/include/oltp_legacy/insert.lua --mysql-table-engine=innodb --oltp-table-size=800000 --oltp-tables-count=1 --rand-int=on --mysql-host=******* --mysql-port=3306 --mysql-user=****** --mysql-password=******* --mysql-db=***** --db-driver=mysql cleanup
三、使用過程中的坑
1、sysbench 自帶了很多lua測試腳本,滿足一般的測試場景,所以選擇合適的測試腳本很重要
2、在選擇腳本前,明確測試需求很重要,不如要測試mysql 寫性能,就選OLTP下的insert.lua 腳本,並通過其他監控查看磁盤等性能數據