請根據實際信息,替換數據庫、連接IP與用戶密碼。
1、導入數據。
(1)使用mysql命令登錄數據庫,并創建測試數據庫 “loadtest” 。
mysql -u root -P 3306 -h -p -e "create database loadtest"
(2)使用sysbench命令導入測試背景數據到 “loadtest” 數據庫。
sysbench
--test=/usr/local/share/sysbench/tests/include/oltp_legacy/oltp.lua
--db-driver=mysql --mysql-db=loadtest --mysql-user=root
--mysql-password= --mysql-port=3306 --mysql-host= --oltp-tables-count=64 --oltp-table-size=10000000 --num-threads=20 prepare
2、壓測數據。
ysbench
--test=/usr/local/share/sysbench/tests/include/oltp_legacy/oltp.lua
--db-driver=mysql --mysql-db=loadtest --mysql-user=root
--mysql-password= --mysql-port=3306 --mysql-host=--oltp-tables-count=64
--oltp-table-size=10000000 --max-time=3600 --max-requests=0
--num-threads=200 --report-interval=3 --forced-shutdown=1 run
3、清理數據。
sysbench
--test=/usr/local/share/sysbench/tests/include/oltp_legacy/oltp.lua
--db-driver=mysql --mysql-db=loadtest --mysql-user=root
--mysql-password= --mysql-port=3306 --mysql-host= --oltp-tables-count=64 --oltp-table-size=10000000--max-time=3600 --max-requests=0 --num-threads=200 cleanup