summaryrefslogtreecommitdiff
path: root/storage/rocksdb/mysql-test/rocksdb_hotbackup/include/setup_replication_gtid.sh
blob: 3c95068a488a30b2896656b7d8e300600338603d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash

set -e

binlog_line=($(grep -o "Last binlog file position [0-9]*, file name .*\.[0-9]*" ${MYSQLTEST_VARDIR}/log/mysqld.2.err | tail -1))
binlog_pos=${binlog_line[4]%?}
binlog_file=${binlog_line[7]}

sql="show gtid_executed in '$binlog_file' from $binlog_pos"
result=($($MYSQL --defaults-group-suffix=.1 -e "$sql"))
gtid_executed=${result[1]}

sql="reset master;"
sql="$sql reset slave;"
sql="$sql change master to master_host='127.0.0.1', master_port=${MASTER_MYPORT}, master_user='root', master_auto_position=1, master_connect_retry=1;"
sql="$sql set global gtid_purged='$gtid_executed';"
sql="$sql start slave;"
sql="$sql stop slave;"
sql="$sql change master to master_auto_position=0;"
sql="$sql start slave;"
$MYSQL --defaults-group-suffix=.2 -e "$sql"
echo "$sql" > ${MYSQL_TMP_DIR}/gtid_stmt