forked from markstanton/sysbench-runner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-multiconfig
executable file
·142 lines (122 loc) · 3.54 KB
/
run-multiconfig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/bin/bash
set -u
usage()
{
cat << EOF
usage: $0 options
WARNING: Do not run this script on a working MySQL server. It will stop & start the service and put
put lots of load on the server.
WARNING: The -c (clean) option deletes binary logs and InnoDB logs and may result in data loss.
This script runs through a directory containing one or more mysqld config files. For each file it
goes through the following steps:
- stops the server,
- deletes the ib_logs and binlogs
- restarts the server with the config file passed to --defaults-file
- runs ./run-sysbench
Once complete it shuts down MySQL and aggregates the sysbench results in a CSV file.
OPTIONS:
-H remote host. sets remote options.
-i MySQL pid file (required)
-d Config directory [./conf]
-s MySQL socket [/tmp/mysql.sock]
-u MySQL username [root]
-p MySQL password
-w ReadWrite mode (on/off) [on]
-o Timeout for each sysbench run [60]
-r Directory to print results to [./results]
-t List of thread counts to iterate [4 8 16 32 64 128 256]
-c Delete binlogs and ib_logfiles when complete (on/off) [off]
EOF
}
pid=
dir=/tmp/conf
socket=/tmp/mysql.sock
user=root
password=$(egrep ^password /root/.my.cnf | head -1 | cut -f2 -d=)
readwrite=on
timeout=60
resultsdir=./results
threads="8,16,32,64,128"
clean=off
params=
while getopts H:i:d:h:s:u:p:w:o:r:t:c: name
do
case $name in
H) hostname="$OPTARG";;
i) pid="$OPTARG";;
d) dir="$OPTARG";;
s) socket="$OPTARG"
params="$params -s $socket";;
u) user="$OPTARG"
params="$params -u $user";;
p) password="$OPTARG"
params="$params -p $password";;
w) readwrite="$OPTARG"
params="$params -w $readwrite";;
o) timeout="$OPTARG"
params="$params -o $timeout";;
r) resultsdir="$OPTARG"
params="$params -r $resultsdir";;
t) threads="$OPTARG"
params="$params -t $threads";;
c) clean="$OPTARG";;
?) usage
exit;;
esac
done
if [[ -z $pid ]]
then
usage
exit 1
fi
if [ -n "$hostname" ]
then
# remote settings
skiprestart=1
clean=off
fi
# Have we got any config files to process?
for f in $(find $dir -t file -iname "*.cnf"); do
# Stop mysql if running
if [ -e $pid ]; then
printf "#### Shutting down MySQL \n"
sudo kill $(sudo cat $pid)
while [ -e $pid ]; do
printf "#### Waiting for MySQL to end. \n"
sleep 2
done
printf "#### MySQL ended. \n"
fi
# Fire up MySQL with this config and then give it some time to warm up
printf "#### Starting MySQL with $f \n"
sudo mysqld_safe --defaults-file=$dir/$f &
while [ ! -e $pid ]; do
printf "#### Waiting for MySQL to start. \n"
sleep 2
done
printf "#### MySQL started. \n"
# Run sysbench passing through some params
printf "Running run-sysbench with $params \n"
./run-sysbench $params
done
# Aggregate the results into a results.csv file
./aggregate-results -r $resultsdir > $resultsdir/results.csv
# Stop mysql if running
if [ -e $pid ]; then
printf "#### Shutting down MySQL \n"
sudo kill $(sudo cat $pid)
while [ -e $pid ]; do
printf "#### Waiting for MySQL to end. \n"
sleep 2
done
printf "#### MySQL ended. \n"
if [ "$clean" == "on" ]; then
# Delete the bin log and innodb logs so they can be recreated
sudo rm -f $(cat $dir/$f | grep innodb_log_group_home_dir | \
sed -e 's/innodb_log_group_home_dir//' -e 's/ //g' \
-e 's/=//')/ib_*
sudo rm -f $(cat $dir/$f | grep log-bin | sed \
-e 's/log-bin//' -e 's/ //g' -e 's/=//')*
fi
fi
exit 1