forked from Percona-QA/percona-qa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pxc6-bench.sh
executable file
·478 lines (397 loc) · 16.4 KB
/
pxc6-bench.sh
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
#!/bin/bash -ue
# Author: Raghavendra Prabhu
set +e
echo "Killing existing mysqld"
pgrep -f mysqld
pkill -f mysqld
sleep 10
pgrep mysqld || pkill -9 -f mysqld
set -e
sleep 5
LPATH=${SPATH:-/usr/share/doc/sysbench/tests/db}
IST_RUN=0
# For local run - User Configurable Variables
if [ -z ${SDURATION} ]; then
SDURATION=150
fi
if [ -z ${DUALTEST} ]; then
DUALTEST=1
fi
if [ -z ${SST_METHOD} ]; then
SST_METHOD=rsync
fi
if [ -z ${STEST} ]; then
STEST=oltp
fi
if [ -z ${TSIZE} ]; then
TSIZE=250
fi
if [ -z ${NUMT} ]; then
NUMT=8
fi
if [ -z ${TCOUNT} ]; then
TCOUNT=50
fi
if [ -z ${AUTOINC} ]; then
AUTOINC=off
fi
SBENCH="sysbench"
XB_VER=2.2.1
WORKDIR=$1
ROOT_FS=$WORKDIR
sst_method=${SST_METHOD:-xtrabackup}
cd $WORKDIR
if [[ $sst_method == xtrabackup ]];then
TAR=`ls -1ct percona-xtrabackup*.tar.gz | head -n1`
#BBASE="$(basename $TAR .tar.gz)"
tar -xf $TAR
BBASE="percona-xtrabackup-${XB_VER}-Linux-x86_64"
export PATH="$ROOT_FS/$BBASE/bin:$PATH"
fi
count=$(ls -1ct Percona-XtraDB-Cluster*.tar.gz | wc -l)
if [[ $count -gt 1 ]];then
for dirs in `ls -1ct Percona-XtraDB-Cluster*.tar.gz | tail -n +2`;do
rm -rf $dirs
done
fi
find . -maxdepth 1 -type d -name 'Percona-XtraDB-Cluster*' -exec rm -rf {} \+
echo "Removing older core files, if any"
rm -f ${ROOT_FS}/**/*core*
echo "Removing older directories"
find . -maxdepth 1 -type d -mtime +10 -exec rm -rf {} \+
echo "Removing their symlinks"
find . -maxdepth 1 -type l -mtime +10 -delete
TAR=`ls -1ct Percona-XtraDB-Cluster*.tar.gz | head -n1`
#BASE="$(basename $TAR .tar.gz)"
BASE="$(tar tf $TAR | head -1 | tr -d '/')"
tar -xf $TAR
# Keep (PS & QA) builds & results for ~40 days (~1/day)
BUILD_WIPE=$[ ${BUILD_NUMBER} - 40 ]
if [ -d ${BUILD_WIPE} ]; then rm -Rf ${BUILD_WIPE}; fi
# For Sysbench
if [[ "x${Host}" == "xubuntu-trusty-64bit" ]];then
export CFLAGS="-Wl,--no-undefined -lasan"
fi
if [[ ! -e `which sysbench` ]];then
echo "Sysbench not found"
exit 1
fi
echo "Note: Using sysbench at $(which sysbench)"
# Parameter of parameterized build
if [[ -n $SDURATION ]];then
export SYSBENCH_DURATION=$SDURATION
else
export SYSBENCH_DURATION=300
fi
WORKDIR="${ROOT_FS}/$BUILD_NUMBER"
mkdir -p $WORKDIR/logs
# User settings
SENDMAIL="/usr/sbin/sendmail"
cleanup(){
tar cvzf $ROOT_FS/results-${BUILD_NUMBER}.tar.gz $WORKDIR/logs || true
}
trap cleanup EXIT KILL
prepare()
{
local sock=$1
local log=$2
echo "Sysbench Run: Prepare stage"
$SBENCH --test=$LPATH/parallel_prepare.lua --report-interval=10 --oltp-auto-inc=$AUTOINC --mysql-engine-trx=yes --mysql-table-engine=innodb \
--oltp-table-size=$TSIZE --oltp_tables_count=$TCOUNT --mysql-db=test --mysql-user=root --num-threads=$NUMT \
--db-driver=mysql --mysql-socket=$sock prepare 2>&1 | tee $log
# $MYSQL_BASEDIR/bin/mysql -S $sock -u root -e "create database testdb;" || true
}
ver_and_row(){
local sock=$1
$MYSQL_BASEDIR/bin/mysql -S $sock -u root -e "show global variables like 'version';"
$MYSQL_BASEDIR/bin/mysql -S $sock -u root -e "select count(*) from $STABLE;"
# $MYSQL_BASEDIR/bin/mysql -S $sock -u root -e "select count(*) from $STABLE;"
}
rw_full()
{
local sock=$1
local log=$2
echo "Sysbench Run: OLTP RW testing"
$SBENCH --mysql-table-engine=innodb --num-threads=$NUMT --report-interval=10 --oltp-auto-inc=$AUTOINC --max-time=$SYSBENCH_DURATION --max-requests=1870000000 \
--test=$SDIR/$STEST.lua --init-rng=on --oltp_index_updates=10 --oltp_non_index_updates=10 --oltp_distinct_ranges=15 --oltp_order_ranges=15 --oltp_tables_count=$TCOUNT --mysql-db=test \
--mysql-user=root --db-driver=mysql --mysql-socket=$sock run 2>&1 | tee $log
}
oltp_ddl()
{
local sock=$1
local log=$2
if [[ ! -e ${SDIR}/oltp_ddl.lua ]];then
if [[ ! -e ${ROOT_FS}/sysbench/sysbench/tests/db/oltp_ddl.lua ]];then
pushd ${ROOT_FS}
git clone -n https://github.com/Percona-QA/sysbench.git --depth 1
cd sysbench
git checkout HEAD sysbench/tests/db/oltp_ddl.lua
SDIR=${ROOT_FS}/sysbench/sysbench/tests/db/
cd $SDIR
ln -s ${LPATH}/* .
popd
else
pushd ${ROOT_FS}
SDIR=${ROOT_FS}/sysbench/sysbench/tests/db/
cd sysbench
git checkout HEAD sysbench/tests/db/oltp_ddl.lua
cd $SDIR
if [[ ! -e ${ROOT_FS}/sysbench/sysbench/tests/db/common.lua ]];then
ln -s ${LPATH}/* .
fi
fi
fi
echo "Sysbench Run: OLTP DDL testing"
$SBENCH --mysql-table-engine=innodb --num-threads=$NUMT --report-interval=10 --oltp-auto-inc=$AUTOINC --max-time=$SYSBENCH_DURATION --max-requests=1870000000 \
--test=$SDIR/oltp_ddl.lua --init-rng=on --oltp_index_updates=10 --oltp_non_index_updates=10 --oltp_distinct_ranges=15 --oltp_order_ranges=15 --oltp_tables_count=$TCOUNT --mysql-db=test \
--mysql-user=root --db-driver=mysql --mysql-socket=$sock run 2>&1 | tee $log
}
clean_up()
{
local sock=$1
local log=$2
echo "Sysbench Run: Cleanup"
$SBENCH --test=$LPATH/parallel_prepare.lua \
--oltp_tables_count=$TCOUNT --mysql-db=test --mysql-user=root \
--db-driver=mysql --mysql-socket=$sock cleanup 2>&1 | tee $log
}
WORKDIR="${ROOT_FS}/$BUILD_NUMBER"
mkdir -p $WORKDIR
MYSQL_BASEDIR="${ROOT_FS}/$BASE"
export MYSQL_VARDIR="$WORKDIR/mysqldir"
mkdir -p $MYSQL_VARDIR
SDIR="$LPATH"
SRESULTS="$WORKDIR/sresults"
mkdir -p $SRESULTS
echo "Workdir: $WORKDIR"
echo "Basedir: $MYSQL_BASEDIR"
ADDR="127.0.0.1"
RPORT=$(( RANDOM%21 + 10 ))
RBASE1="$(( RPORT*1000 ))"
#lsof -i tcp:$RBASE1 | awk 'NR!=1 {print $2}' | xargs kill -9 2>/dev/null
echo "Setting RBASE to $RBASE1"
RADDR1="$ADDR:$(( RBASE1 + 7 ))"
LADDR1="$ADDR:$(( RBASE1 + 8 ))"
RBASE2="$(( RBASE1 + 100 ))"
#lsof -i tcp:$RBASE2 | awk 'NR!=1 {print $2}' | xargs kill -9 2>/dev/null
RADDR2="$ADDR:$(( RBASE2 + 7 ))"
LADDR2="$ADDR:$(( RBASE2 + 8 ))"
SUSER=root
SPASS=
node1="${MYSQL_VARDIR}/node1"
mkdir -p $node1
node2="${MYSQL_VARDIR}/node2"
mkdir -p $node2
sysbench_run()
{
echo "Starting PXC node1"
pushd ${MYSQL_BASEDIR}/mysql-test/
set +e
perl mysql-test-run.pl \
--start-and-exit \
--port-base=$RBASE1 \
--nowarnings \
--vardir=$node1 \
--mysqld=--skip-performance-schema \
--mysqld=--innodb_file_per_table $1 \
--mysqld=--wsrep-slave-threads=2 \
--mysqld=--innodb_autoinc_lock_mode=2 \
--mysqld=--innodb_locks_unsafe_for_binlog=1 \
--mysqld=--wsrep-provider=${MYSQL_BASEDIR}/lib/libgalera_smm.so \
--mysqld=--wsrep_cluster_address=gcomm:// \
--mysqld=--wsrep_sst_receive_address=$RADDR1 \
--mysqld=--wsrep_node_incoming_address=$ADDR \
--mysqld=--wsrep_provider_options="gmcast.listen_addr=tcp://$LADDR1" \
--mysqld=--wsrep_sst_method=$sst_method \
--mysqld=--wsrep_sst_auth=$SUSER:$SPASS \
--mysqld=--wsrep_node_address=$ADDR \
--mysqld=--innodb_flush_method=O_DIRECT \
--mysqld=--core-file \
--mysqld=--loose-new \
--mysqld=--sql-mode=no_engine_substitution \
--mysqld=--loose-innodb \
--mysqld=--secure-file-priv= \
--mysqld=--loose-innodb-status-file=1 \
--mysqld=--skip-name-resolve \
--mysqld=--socket=$node1/socket.sock \
--mysqld=--log-error=$WORKDIR/logs/node1.err \
--mysqld=--log-output=none \
1st
set -e
popd
sleep 10
# Sysbench Runs
## Prepare/setup
echo "Sysbench Run: Prepare stage"
if [[ -n ${BUILTIN_SYSBENCH:-} ]];then
/usr/bin/sysbench --test=oltp --oltp-auto-inc=off --mysql-engine-trx=yes --mysql-table-engine=innodb \
--oltp-table-size=100000 --mysql-db=test --mysql-user=root \
--db-driver=mysql --mysql-socket=$node1/socket.sock prepare \
> $SRESULTS/sysbench_prepare.txt
else
prepare $node1/socket.sock $WORKDIR/logs/sysbench_prepare.txt
fi
$MYSQL_BASEDIR/bin/mysql -S $node1/socket.sock -u root -e "create database testdb;" || true
if [[ -n ${DUALTEST:-} ]];then
pushd ${MYSQL_BASEDIR}/mysql-test/
export MYSQLD_BOOTSTRAP_CMD=
set +e
perl mysql-test-run.pl \
--start-and-exit \
--port-base=$RBASE2 \
--nowarnings \
--vardir=$node2 \
--mysqld=--skip-performance-schema \
--mysqld=--innodb_file_per_table $1 \
--mysqld=--wsrep-slave-threads=2 \
--mysqld=--innodb_autoinc_lock_mode=2 \
--mysqld=--innodb_locks_unsafe_for_binlog=1 \
--mysqld=--wsrep-provider=${MYSQL_BASEDIR}/lib/libgalera_smm.so \
--mysqld=--wsrep_cluster_address=gcomm://$LADDR1 \
--mysqld=--wsrep_sst_receive_address=$RADDR2 \
--mysqld=--wsrep_node_incoming_address=$ADDR \
--mysqld=--wsrep_provider_options="gmcast.listen_addr=tcp://$LADDR2" \
--mysqld=--wsrep_sst_method=$sst_method \
--mysqld=--wsrep_sst_auth=$SUSER:$SPASS \
--mysqld=--wsrep_node_address=$ADDR \
--mysqld=--innodb_flush_method=O_DIRECT \
--mysqld=--core-file \
--mysqld=--loose-new \
--mysqld=--sql-mode=no_engine_substitution \
--mysqld=--loose-innodb \
--mysqld=--secure-file-priv= \
--mysqld=--loose-innodb-status-file=1 \
--mysqld=--skip-name-resolve \
--mysqld=--log-error=$WORKDIR/logs/node2.err \
--mysqld=--socket=$node2/socket.sock \
--mysqld=--log-output=none \
1st
set -e
popd
fi
echo "Sleeping for 10s"
sleep 10
if [[ -z ${BUILTIN_SYSBENCH:-} ]];then
STABLE="test.sbtest1"
else
STABLE="test.sbtest"
fi
if [[ -n ${DUALTEST:-} ]];then
echo "Before RW testing"
ver_and_row $node1/socket.sock
ver_and_row $node2/socket.sock
fi
if [[ ! -e $SDIR/${STEST}.lua ]];then
pushd /tmp
rm $STEST.lua || true
wget -O $STEST.lua https://github.com/Percona-QA/sysbench/tree/0.5/sysbench/tests/db/${STEST}.lua
SDIR=/tmp/
popd
fi
set -x
if [[ -n ${DUALTEST:-} ]];then
## OLTP RW Run
echo "Sysbench Run: OLTP RW testing"
if [[ -n ${BUILTIN_SYSBENCH:-} ]];then
/usr/bin/sysbench --num-threads=16 --oltp-auto-inc=off --max-time=$SYSBENCH_DURATION --max-requests=1870000000 \
--test=oltp --oltp-table-size=100000 --mysql-db=test \
--mysql-user=root --db-driver=mysql --mysql-socket=$node2/socket.sock \
run > $SRESULTS/sysbench_rw_run.txt
else
if [ ${IST_RUN} -eq 1 ]; then
${MYSQL_BASEDIR}/bin/mysqladmin -uroot -S$node2/socket.sock shutdown > /dev/null 2>&1
sleep 5
rw_full "$node1/socket.sock" $WORKDIR/logs/sysbench_rw_ist_run.txt
${MYSQL_BASEDIR}/bin/mysqld --defaults-group-suffix=.1 --defaults-file=$node2/my.cnf --log-output=file --loose-debug-sync-timeout=600 --default-storage-engine=MyISAM --default-tmp-storage-engine=MyISAM --skip-performance-schema --innodb_file_per_table --binlog-format=ROW --wsrep-slave-threads=2 --innodb_autoinc_lock_mode=2 --innodb_locks_unsafe_for_binlog=1 --wsrep-provider=${MYSQL_BASEDIR}/lib/libgalera_smm.so --wsrep_cluster_address=gcomm://$LADDR1 --wsrep_sst_receive_address=$RADDR2 --wsrep_node_incoming_address=$ADDR --wsrep_provider_options=gmcast.listen_addr=tcp://$LADDR2 --wsrep_sst_method=$sst_method --wsrep_sst_auth=$SUSER:$SPASS --wsrep_node_address=$ADDR --innodb_flush_method=O_DIRECT --core-file --loose-new --sql-mode=no_engine_substitution --loose-innodb --secure-file-priv= --loose-innodb-status-file=1 --skip-name-resolve --log-error=$WORKDIR/logs/node2.err --socket=$node2/socket.sock --log-output=none --core-file > $WORKDIR/logs/node2.err 2>&1 &
MPID="$!"
while true ; do
sleep 10
if egrep -qi "Synchronized with group, ready for connections" $WORKDIR/logs/node2.err ; then
break
fi
if [ "${MPID}" == "" ]; then
echoit "Error! server not started.. Terminating!"
egrep -i "ERROR|ASSERTION" $WORKDIR/logs/node2.err
exit 1
fi
done
echo "Table row count after IST run"
ver_and_row $node1/socket.sock
ver_and_row $node2/socket.sock
clean_up $node1/socket.sock $WORKDIR/logs/sysbench_cleanup.txt
else
echo "Table row count after SST run"
rw_full "$node1/socket.sock,$node2/socket.sock" $WORKDIR/logs/sysbench_rw_run.txt
ver_and_row $node1/socket.sock
ver_and_row $node2/socket.sock
oltp_ddl $node1/socket.sock $WORKDIR/logs/sysbench_ddl.txt
clean_up $node1/socket.sock $WORKDIR/logs/sysbench_cleanup.txt
fi
fi
if [[ -n ${BUILTIN_SYSBENCH:-} ]];then
echo "Sleeping for 5s"
sleep 5
/usr/bin/sysbench --num-threads=16 --oltp-auto-inc=off --max-time=$SYSBENCH_DURATION --max-requests=1870000000 \
--test=oltp --oltp-table-size=100000 --mysql-db=test \
--mysql-user=root --db-driver=mysql --mysql-socket=$node1/socket.sock \
run > $SRESULTS/sysbench_rw_run-1.txt
fi
else
## OLTP RW Run
echo "Sysbench Run: OLTP RW testing"
if [[ -n ${BUILTIN_SYSBENCH:-} ]];then
/usr/bin/sysbench --num-threads=16 --oltp-auto-inc=off --max-time=$SYSBENCH_DURATION --max-requests=1870000000 \
--test=oltp --oltp-table-size=100000 --mysql-db=test \
--mysql-user=root --db-driver=mysql --mysql-socket=$node1/socket.sock \
run > $SRESULTS/sysbench_rw_run.txt
else
if [ ${IST_RUN} -eq 1 ]; then
${MYSQL_BASEDIR}/bin/mysqladmin -uroot -S$node2/socket.sock shutdown > /dev/null 2>&1
sleep 5
rw_full "$node1/socket.sock" $WORKDIR/logs/sysbench_rw_ist_run.txt
${MYSQL_BASEDIR}/bin/mysqld --defaults-group-suffix=.1 --defaults-file=$node2/my.cnf --log-output=file --loose-debug-sync-timeout=600 --default-storage-engine=MyISAM --default-tmp-storage-engine=MyISAM --skip-performance-schema --innodb_file_per_table --binlog-format=ROW --wsrep-slave-threads=2 --innodb_autoinc_lock_mode=2 --innodb_locks_unsafe_for_binlog=1 --wsrep-provider=${MYSQL_BASEDIR}/lib/libgalera_smm.so --wsrep_cluster_address=gcomm://$LADDR1 --wsrep_sst_receive_address=$RADDR2 --wsrep_node_incoming_address=$ADDR --wsrep_provider_options=gmcast.listen_addr=tcp://$LADDR2 --wsrep_sst_method=$sst_method --wsrep_sst_auth=$SUSER:$SPASS --wsrep_node_address=$ADDR --innodb_flush_method=O_DIRECT --core-file --loose-new --sql-mode=no_engine_substitution --loose-innodb --secure-file-priv= --loose-innodb-status-file=1 --skip-name-resolve --log-error=$WORKDIR/logs/node2.err --socket=$node2/socket.sock --log-output=none --core-file > $WORKDIR/logs/node2.err 2>&1 &
MPID="$!"
while true ; do
sleep 10
if egrep -qi "Synchronized with group, ready for connections" $WORKDIR/logs/node2.err ; then
break
fi
if [ "${MPID}" == "" ]; then
echoit "Error! server not started.. Terminating!"
egrep -i "ERROR|ASSERTION" $WORKDIR/logs/node2.err
exit 1
fi
done
echo "Table row count after IST run"
ver_and_row $node1/socket.sock
ver_and_row $node2/socket.sock
clean_up $node1/socket.sock $WORKDIR/logs/sysbench_cleanup.txt
else
echo "Table row count after SST run"
rw_full "$node1/socket.sock" $WORKDIR/logs/sysbench_rw_run.txt
ver_and_row $node1/socket.sock
ver_and_row $node2/socket.sock
oltp_ddl $node1/socket.sock $WORKDIR/logs/sysbench_ddl.txt
clean_up $node1/socket.sock $WORKDIR/logs/sysbench_cleanup.txt
fi
fi
fi
set +x
$MYSQL_BASEDIR/bin/mysqladmin --socket=$node1/socket.sock -u root shutdown
$MYSQL_BASEDIR/bin/mysqladmin --socket=$node2/socket.sock -u root shutdown
}
## sysbench run with binlog
sysbench_run --mysqld=--binlog-format=ROW
mv $node1 ${MYSQL_VARDIR}/with_binlog_node1
mv $node2 ${MYSQL_VARDIR}/with_binlog_node2
mkdir -p $node1
mkdir -p $node2
## sysbench run without binlog
sysbench_run --skip-log-bin
mv $node1 ${MYSQL_VARDIR}/without_binlog_node1
mv $node2 ${MYSQL_VARDIR}/without_binlog_node2
mkdir -p $node1
mkdir -p $node2
##sysbench run for IST test
IST_RUN=1
sysbench_run --mysqld=--binlog-format=ROW