File: setup_replication_gtid.sh

package info (click to toggle)
mariadb 1%3A11.8.2-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 765,428 kB
  • sloc: ansic: 2,382,827; cpp: 1,803,532; asm: 378,315; perl: 63,176; sh: 46,496; pascal: 40,776; java: 39,363; yacc: 20,428; python: 19,506; sql: 17,864; xml: 12,463; ruby: 8,544; makefile: 6,059; cs: 5,855; ada: 1,700; lex: 1,193; javascript: 1,039; objc: 80; tcl: 73; awk: 46; php: 22
file content (22 lines) | stat: -rwxr-xr-x 811 bytes parent folder | download | duplicates (6)
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