Skip to content

Commit

Permalink
Merge pull request #43 from hoatle/bugs/#41-mysqlha-backup
Browse files Browse the repository at this point in the history
@ #41 | fix mysqlha scale=3
  • Loading branch information
hoatle authored Sep 6, 2022
2 parents 9074aa7 + 25a8131 commit 1be6fb9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions charts/mysqlha/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: mysqlha
version: 0.4.1-alpha.2
version: 0.4.1-alpha.3
apiVersion: v1
appVersion: 5.7.13
appVersion: 5.7.36
description: MySQL cluster with a single master and zero or more slave replicas
keywords:
- mysql
Expand Down
14 changes: 7 additions & 7 deletions charts/mysqlha/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,10 @@ spec:
if [[ -s xtrabackup_slave_info ]]; then
# XtraBackup already generated a partial "CHANGE MASTER TO" query
# because we're cloning from an existing slave.
# the file has semicolum character, eg: CHANGE MASTER TO MASTER_LOG_FILE='mysqlha-0-bin.000003', MASTER_LOG_POS=790;
# so we need to remove that ; character
cp xtrabackup_slave_info change_master_to.sql.in
sed -i 's/;$//' change_master_to.sql.in
elif [[ -s xtrabackup_binlog_info ]]; then
# We're cloning directly from master. Parse binlog position.
[[ $(cat xtrabackup_binlog_info) =~ ^(.*?)[[:space:]]+(.*?)$ ]] || exit 1
Expand All @@ -211,18 +214,15 @@ spec:
# Check if we need to complete a clone by starting replication.
if [[ -s change_master_to.sql.in ]]; then
# In case of container restart, attempt this at-most-once.
cp change_master_to.sql.in change_master_to.sql.orig
cat > change_master_to.sql.orig <<EOF
mysql -h 127.0.0.1 --verbose<<EOF
STOP SLAVE IO_THREAD;
$(<change_master_to.sql.orig),
MASTER_HOST='{{ template "fullname" . }}-0.{{ template "fullname" . }}',
MASTER_USER='${MYSQL_REPLICATION_USER}',
MASTER_PASSWORD='${MYSQL_REPLICATION_PASSWORD}',
MASTER_CONNECT_RETRY=10
EOF
mysql -h 127.0.0.1 --verbose<<EOF
STOP SLAVE IO_THREAD;
$(<change_master_to.sql.orig);
MASTER_CONNECT_RETRY=10;
START SLAVE;
EOF
fi
Expand Down

0 comments on commit 1be6fb9

Please sign in to comment.