Tool Name: mysqlha_sysbench.sh
Tool use: For MySQL stress testing (2 functions: Fill data && test data)
Tool Parameters:
Options
-P port to test
-D DB name to test
-h host to be tested
-S Fill && test table data volume, default 100w
-c Number of fill && test tables, default 1
-T prepare and run, prepare is manufacturing data run is start test, default run
-O on and off, on is read-write mixed mode off is readonly mode, default on
-B Concurrency Number default 1
-Y test time, fill without the default 1800# half an hour
-N Test number tests for example 128 threads run 3 times
Tool Example:
Example:usage make (populate data) data:mysqlha_sysbench.sh-p Port-D db-h Ip-t Prepare
Example:usage Test (test data) data:mysqlha_sysbench.sh-p Port-D db-h ip-b concurrency number-y test time-n number of times
Precautions:
1) Permissions issue use MyAdmin account, pay attention to authorization
2) Local Sysbench path must be installed in/usr/local/xywy/sysbench/bin/
Tool execution Results:
650) this.width=650; "class=" Confluence-embedded-image "src=" http://wiki.op.xywy.com/download/attachments/ 14256024/image2016-9-2%2011%3a0%3a3.png?version=1&modificationdate=1472785499000&api=v2 "alt=" Image2016-9-2%2011%3a0%3a3.png?version=1 "/>
#!/bin/bash
# Author: [Email protected]
# date:2016-09-02
# Helpfunc shows the Help info
function Helpfunc () {
Echo
echo "Please check your input!!!!"
echo "Options:"
echo "-P test Port"
echo "-D databases Name"
echo "-H test Host"
echo "-s table size, default 100w"
echo "-C test Table number, default 1"
echo "-T prepare and run, prepare is manufacturing data run is start test, default Run"
echo "-O on and off, on is read-write mixed mode off is readonly mode, default on"
echo "-B concurrency number default 1"
echo "-y Test time in seconds default 1800# half Hour"
echo "-N Test Number"
echo "Example:usage make data:mysqlha_sysbench.sh-p-d-h-T"
echo "Example:usage test data:mysqlha_sysbench.sh-p-d-h-b-y"
}
############################################
. /etc/dbbin/sh_lib/config.sh "/etc/dbbin/conf/mysql.cfg"
User= "MyAdmin";
password= ' GetConfig "MySQL" $user '
Bfs=1
Option= "On"
time=1800
Number=1
If [$#-lt 1];
Then
Helpfunc
Exit 1
Else
P) port= $OPTARG;;
D) db= $OPTARG;;
H) host= $OPTARG;;
S) size= $OPTARG;;
C) count= $OPTARG;;
T) type= $OPTARG;;
O) option= $OPTARG;;
B) bfs= $OPTARG;;
Y) time= $OPTARG;;
N) number= $OPTARG;;
*) Helpfunc; Exit 1;;;
Esac
Done
Fi
Date= ' Date ' +%y-%m-%d "'
function Test_data () {
If ["$type" = = "Prepare"];then
/usr/local/xywy/sysbench/bin/sysbench--test=/usr/local/xywy/sysbench/db/oltp.lua--oltp-table-size= "$size"-- Oltp-table-name=tt--mysql-db= $db--mysql-port= $port--mysql-host= $host--mysql-user= $user--mysql-password=$ Password--oltp_tables_count= $count--oltp-test-mode=complex--rand-type=uniform--rand-init=on--report-interval= Ten--percentile=99 prepare >>/data/logs/sysbench_oltp$date.log
If [$?-ne 0]; Then
echo "Insert Data failure!"
Exit-1
Else
echo "Insert $count data is sucess"
Fi
elif ["$type" = = "Run"];then
For I in $ (seq 1 $number)
Do
/usr/local/xywy/sysbench/bin/sysbench--test=/usr/local/xywy/sysbench/db/oltp.lua--oltp-table-size= $size-- mysql-db= $db--mysql-port= $port--mysql-host= $host--mysql-user= $user--mysql-password= $password--oltp_tables_ count= $count--oltp-read-only= $option--oltp-test-mode=complex--rand-type=uniform--rand-init=on--num-threads=$ BFS--max-time= $time--max-requests=0--report-interval=10--percentile=99 run >>/data/logs/sysbench_oltp$ Date.log
If [$?-ne 0]; Then
echo "Test failure!"
Exit-1
Else
Log= ' Cat/data/logs/sysbench_oltp$date.log|grep transactions:-B 10|grep $bfs-a10 '
echo "Concurrent for $BFS of the results is $log"
Fi
Done
Else
Helpfunc
Fi
}
Test_data
This article is from the "10937712" blog, please be sure to keep this source http://10947712.blog.51cto.com/10937712/1845560
MySQL Stress test Tool