summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/wsrep_sst_common.sh42
-rw-r--r--scripts/wsrep_sst_mysqldump.sh45
-rw-r--r--scripts/wsrep_sst_rsync.sh17
-rw-r--r--scripts/wsrep_sst_xtrabackup-v2.sh297
-rw-r--r--scripts/wsrep_sst_xtrabackup.sh20
5 files changed, 269 insertions, 152 deletions
diff --git a/scripts/wsrep_sst_common.sh b/scripts/wsrep_sst_common.sh
index 78060f70ca5..fb8289d06df 100644
--- a/scripts/wsrep_sst_common.sh
+++ b/scripts/wsrep_sst_common.sh
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2014 Codership Oy
+# Copyright (C) 2012-2015 Codership Oy
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -20,22 +20,20 @@ set -u
WSREP_SST_OPT_BYPASS=0
WSREP_SST_OPT_BINLOG=""
+WSREP_SST_OPT_CONF_SUFFIX=""
WSREP_SST_OPT_DATA=""
-WSREP_SST_OPT_AUTH=""
+WSREP_SST_OPT_AUTH=${WSREP_SST_OPT_AUTH:-}
+WSREP_SST_OPT_USER=${WSREP_SST_OPT_USER:-}
+WSREP_SST_OPT_PSWD=${WSREP_SST_OPT_PSWD:-}
WSREP_SST_OPT_DEFAULT=""
WSREP_SST_OPT_EXTRA_DEFAULT=""
-
while [ $# -gt 0 ]; do
case "$1" in
'--address')
readonly WSREP_SST_OPT_ADDR="$2"
shift
;;
- '--auth')
- WSREP_SST_OPT_AUTH="$2"
- shift
- ;;
'--bypass')
WSREP_SST_OPT_BYPASS=1
;;
@@ -50,6 +48,9 @@ case "$1" in
'--defaults-extra-file')
readonly WSREP_SST_OPT_EXTRA_DEFAULT="$1=$2"
shift
+ '--defaults-group-suffix')
+ WSREP_SST_OPT_CONF_SUFFIX="$2"
+ shift
;;
'--host')
readonly WSREP_SST_OPT_HOST="$2"
@@ -104,6 +105,7 @@ shift
done
readonly WSREP_SST_OPT_BYPASS
readonly WSREP_SST_OPT_BINLOG
+readonly WSREP_SST_OPT_CONF_SUFFIX
# try to use my_print_defaults, mysql and mysqldump that come with the sources
# (for MTR suite)
@@ -133,13 +135,30 @@ fi
readonly WSREP_SST_OPT_CONF="$WSREP_SST_OPT_DEFAULT $WSREP_SST_OPT_EXTRA_DEFAULT"
MY_PRINT_DEFAULTS="$MY_PRINT_DEFAULTS $WSREP_SST_OPT_CONF"
+wsrep_auth_not_set()
+{
+ [ -z "$WSREP_SST_OPT_AUTH" -o "$WSREP_SST_OPT_AUTH" = "(null)" ]
+}
-# State Snapshot Transfer authentication password was displayed in the ps output. Bug fixed #1200727.
-if $MY_PRINT_DEFAULTS sst | grep -q "wsrep_sst_auth";then
- if [ -z "$WSREP_SST_OPT_AUTH" -o "$WSREP_SST_OPT_AUTH" = "(null)" ];then
- WSREP_SST_OPT_AUTH=$($MY_PRINT_DEFAULTS sst | grep -- "--wsrep_sst_auth" | cut -d= -f2)
+# For Bug:1200727
+if $MY_PRINT_DEFAULTS sst | grep -q "wsrep_sst_auth"
+then
+ if wsrep_auth_not_set
+ then
+ WSREP_SST_OPT_AUTH=$($MY_PRINT_DEFAULTS sst | grep -- "--wsrep_sst_auth" | cut -d= -f2)
fi
fi
+readonly WSREP_SST_OPT_AUTH
+
+# Splitting AUTH into potential user:password pair
+if ! wsrep_auth_not_set
+then
+ readonly AUTH_VEC=(${WSREP_SST_OPT_AUTH//:/ })
+ WSREP_SST_OPT_USER="${AUTH_VEC[0]:-}"
+ WSREP_SST_OPT_PSWD="${AUTH_VEC[1]:-}"
+fi
+readonly WSREP_SST_OPT_USER
+readonly WSREP_SST_OPT_PSWD
if [ -n "${WSREP_SST_OPT_DATA:-}" ]
then
@@ -148,7 +167,6 @@ else
SST_PROGRESS_FILE=""
fi
-
wsrep_log()
{
# echo everything to stderr so that it gets into common error log
diff --git a/scripts/wsrep_sst_mysqldump.sh b/scripts/wsrep_sst_mysqldump.sh
index a05e42f31b3..21c4bf62130 100644
--- a/scripts/wsrep_sst_mysqldump.sh
+++ b/scripts/wsrep_sst_mysqldump.sh
@@ -1,5 +1,5 @@
-#!/bin/bash -e
-# Copyright (C) 2009 Codership Oy
+#!/bin/bash -ue
+# Copyright (C) 2009-2015 Codership Oy
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -41,7 +41,6 @@ local_ip()
return 1
}
-if test -z "$WSREP_SST_OPT_USER"; then wsrep_log_error "USER cannot be nil"; exit $EINVAL; fi
if test -z "$WSREP_SST_OPT_HOST"; then wsrep_log_error "HOST cannot be nil"; exit $EINVAL; fi
if test -z "$WSREP_SST_OPT_PORT"; then wsrep_log_error "PORT cannot be nil"; exit $EINVAL; fi
if test -z "$WSREP_SST_OPT_LPORT"; then wsrep_log_error "LPORT cannot be nil"; exit $EINVAL; fi
@@ -64,13 +63,29 @@ then
exit $EINVAL
fi
-# For Bug:1293798
-if [ -z "$WSREP_SST_OPT_PSWD" -a -n "$WSREP_SST_OPT_AUTH" ]; then
- WSREP_SST_OPT_USER=$(echo $WSREP_SST_OPT_AUTH | cut -d: -f1)
- WSREP_SST_OPT_PSWD=$(echo $WSREP_SST_OPT_AUTH | cut -d: -f2)
-fi
-AUTH="-u$WSREP_SST_OPT_USER"
-if test -n "$WSREP_SST_OPT_PSWD"; then AUTH="$AUTH -p$WSREP_SST_OPT_PSWD"; fi
+[ -n "$WSREP_SST_OPT_USER" ] && AUTH="-u$WSREP_SST_OPT_USER" || AUTH=
+
+# Refs https://github.com/codership/mysql-wsrep/issues/141
+# Passing password in MYSQL_PWD environment variable is considered
+# "extremely insecure" by MySQL Guidelines for Password Security
+# (https://dev.mysql.com/doc/refman/5.6/en/password-security-user.html)
+# that is even less secure than passing it on a command line! It is doubtful:
+# the whole command line is easily observable by any unprivileged user via ps,
+# whereas (at least on Linux) unprivileged user can't see process environment
+# that he does not own. So while it may be not secure in the NSA sense of the
+# word, it is arguably more secure than passing password on the command line.
+[ -n "$WSREP_SST_OPT_PSWD" ] && export MYSQL_PWD="$WSREP_SST_OPT_PSWD"
+
+# Refs https://github.com/codership/mysql-wsrep/issues/141
+# Passing password in MYSQL_PWD environment variable is considered
+# "extremely insecure" by MySQL Guidelines for Password Security
+# (https://dev.mysql.com/doc/refman/5.6/en/password-security-user.html)
+# that is even less secure than passing it on a command line! It is doubtful:
+# the whole command line is easily observable by any unprivileged user via ps,
+# whereas (at least on Linux) unprivileged user can't see process environment
+# that he does not own. So while it may be not secure in the NSA sense of the
+# word, it is arguably more secure than passing password on the command line.
+[ -n "$WSREP_SST_OPT_PSWD" ] && export MYSQL_PWD="$WSREP_SST_OPT_PSWD"
STOP_WSREP="SET wsrep_on=OFF;"
@@ -147,15 +162,15 @@ fi
MYSQLDUMP="$MYSQLDUMP $AUTH -S$WSREP_SST_OPT_SOCKET \
--add-drop-database --add-drop-table --skip-add-locks --create-options \
--disable-keys --extended-insert --skip-lock-tables --quick --set-charset \
---skip-comments --flush-privileges --all-databases"
+--skip-comments --flush-privileges --all-databases --events"
# need to disable logging when loading the dump
# reason is that dump contains ALTER TABLE for log tables, and
# this causes an error if logging is enabled
-GENERAL_LOG_OPT=`$MYSQL --skip-column-names -e"$STOP_WSREP SELECT @@GENERAL_LOG"`
-SLOW_LOG_OPT=`$MYSQL --skip-column-names -e"$STOP_WSREP SELECT @@SLOW_QUERY_LOG"`
-$MYSQL -e"$STOP_WSREP SET GLOBAL GENERAL_LOG=OFF"
-$MYSQL -e"$STOP_WSREP SET GLOBAL SLOW_QUERY_LOG=OFF"
+GENERAL_LOG_OPT=`$MYSQL --skip-column-names -e "$STOP_WSREP SELECT @@GENERAL_LOG"`
+SLOW_LOG_OPT=`$MYSQL --skip-column-names -e "$STOP_WSREP SELECT @@SLOW_QUERY_LOG"`
+$MYSQL -e "$STOP_WSREP SET GLOBAL GENERAL_LOG=OFF"
+$MYSQL -e "$STOP_WSREP SET GLOBAL SLOW_QUERY_LOG=OFF"
# commands to restore log settings
RESTORE_GENERAL_LOG="SET GLOBAL GENERAL_LOG=$GENERAL_LOG_OPT;"
diff --git a/scripts/wsrep_sst_rsync.sh b/scripts/wsrep_sst_rsync.sh
index ee63fe04fe7..a93ab940593 100644
--- a/scripts/wsrep_sst_rsync.sh
+++ b/scripts/wsrep_sst_rsync.sh
@@ -18,8 +18,10 @@
# This is a reference script for rsync-based state snapshot tansfer
-RSYNC_PID=
-RSYNC_CONF=
+RSYNC_PID= # rsync pid file
+RSYNC_CONF= # rsync configuration file
+RSYNC_REAL_PID= # rsync process id
+
OS=$(uname)
[ "$OS" == "Darwin" ] && export -n LD_LIBRARY_PATH
@@ -32,10 +34,12 @@ wsrep_check_programs rsync
cleanup_joiner()
{
- wsrep_log_info "Joiner cleanup."
- local PID=$(cat "$RSYNC_PID" 2>/dev/null || echo 0)
- [ "0" != "$PID" ] && kill $PID && sleep 0.5 && kill -9 $PID >/dev/null 2>&1 \
- || :
+ wsrep_log_info "Joiner cleanup. rsync PID: $RSYNC_REAL_PID"
+ [ "0" != "$RSYNC_REAL_PID" ] && \
+ kill $RSYNC_REAL_PID && \
+ sleep 0.5 && \
+ kill -9 $RSYNC_REAL_PID >/dev/null 2>&1 || \
+ :
rm -rf "$RSYNC_CONF"
rm -rf "$MAGIC_FILE"
rm -rf "$RSYNC_PID"
@@ -45,6 +49,7 @@ cleanup_joiner()
fi
}
+# Check whether rsync process is still running.
check_pid()
{
local pid_file=$1
diff --git a/scripts/wsrep_sst_xtrabackup-v2.sh b/scripts/wsrep_sst_xtrabackup-v2.sh
index bba187ed2f9..68e250d2157 100644
--- a/scripts/wsrep_sst_xtrabackup-v2.sh
+++ b/scripts/wsrep_sst_xtrabackup-v2.sh
@@ -29,6 +29,8 @@ ekeyfile=""
encrypt=0
nproc=1
ecode=0
+ssyslog=""
+ssystag=""
XTRABACKUP_PID=""
SST_PORT=""
REMOTEIP=""
@@ -40,15 +42,15 @@ progress=""
ttime=0
totime=0
lsn=""
-incremental=0
ecmd=""
rlimit=""
# Initially
stagemsg="${WSREP_SST_OPT_ROLE}"
cpat=""
-speciald=0
+speciald=1
ib_home_dir=""
ib_log_dir=""
+ib_undo_dir=""
sfmt="tar"
strmcmd=""
@@ -70,6 +72,11 @@ xtmpdir=""
scomp=""
sdecomp=""
+# Required for backup locks
+# For backup locks it is 1 sent by joiner
+# 5.6.21 PXC and later can't donate to an older joiner
+sst_ver=1
+
if which pv &>/dev/null && pv --help | grep -q FORMAT;then
pvopts+=$pvformat
fi
@@ -77,7 +84,6 @@ pcmd="pv $pvopts"
declare -a RC
INNOBACKUPEX_BIN=innobackupex
-readonly AUTH=(${WSREP_SST_OPT_AUTH//:/ })
DATA="${WSREP_SST_OPT_DATA}"
INFO_FILE="xtrabackup_galera_info"
IST_FILE="xtrabackup_ist"
@@ -169,7 +175,11 @@ get_transfer()
fi
wsrep_log_info "Using netcat as streamer"
if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
- tcmd="nc -dl ${TSST_PORT}"
+ if nc -h | grep -q ncat;then
+ tcmd="nc -l ${TSST_PORT}"
+ else
+ tcmd="nc -dl ${TSST_PORT}"
+ fi
else
tcmd="nc ${REMOTEIP} ${TSST_PORT}"
fi
@@ -253,6 +263,16 @@ get_footprint()
adjust_progress()
{
+
+ if [[ ! -x `which pv` ]];then
+ wsrep_log_error "pv not found in path: $PATH"
+ wsrep_log_error "Disabling all progress/rate-limiting"
+ pcmd=""
+ rlimit=""
+ progress=""
+ return
+ fi
+
if [[ -n $progress && $progress != '1' ]];then
if [[ -e $progress ]];then
pcmd+=" 2>>$progress"
@@ -282,8 +302,7 @@ read_cnf()
progress=$(parse_cnf sst progress "")
rebuild=$(parse_cnf sst rebuild 0)
ttime=$(parse_cnf sst time 0)
- cpat=$(parse_cnf sst cpat '.*galera\.cache$\|.*sst_in_progress$\|.*grastate\.dat$\|.*gvwstate\.dat$\|.*\.err$\|.*\.log$\|.*RPM_UPGRADE_MARKER$\|.*RPM_UPGRADE_HISTORY$')
- incremental=$(parse_cnf sst incremental 0)
+ cpat=$(parse_cnf sst cpat '.*galera\.cache$\|.*sst_in_progress$\|.*\.sst$\|.*gvwstate\.dat$\|.*grastate\.dat$\|.*\.err$\|.*\.log$\|.*RPM_UPGRADE_MARKER$\|.*RPM_UPGRADE_HISTORY$')
ealgo=$(parse_cnf xtrabackup encrypt "")
ekey=$(parse_cnf xtrabackup encrypt-key "")
ekeyfile=$(parse_cnf xtrabackup encrypt-key-file "")
@@ -304,6 +323,20 @@ read_cnf()
iapts=$(parse_cnf sst inno-apply-opts "")
impts=$(parse_cnf sst inno-move-opts "")
stimeout=$(parse_cnf sst sst-initial-timeout 100)
+ ssyslog=$(parse_cnf sst sst-syslog 0)
+ ssystag=$(parse_cnf mysqld_safe syslog-tag "${SST_SYSLOG_TAG:-}")
+ ssystag+="-"
+
+ if [[ $speciald -eq 0 ]];then
+ wsrep_log_error "sst-special-dirs equal to 0 is not supported, falling back to 1"
+ speciald=1
+ fi
+
+ if [[ $ssyslog -ne -1 ]];then
+ if $MY_PRINT_DEFAULTS mysqld_safe | tr '_' '-' | grep -q -- "--syslog";then
+ ssyslog=1
+ fi
+ fi
}
get_stream()
@@ -347,8 +380,7 @@ cleanup_joiner()
local estatus=$?
if [[ $estatus -ne 0 ]];then
wsrep_log_error "Cleanup after exit with status:$estatus"
- fi
- if [ "${WSREP_SST_OPT_ROLE}" = "joiner" ];then
+ elif [ "${WSREP_SST_OPT_ROLE}" = "joiner" ];then
wsrep_log_info "Removing the sst_in_progress file"
wsrep_cleanup_progress_file
fi
@@ -359,6 +391,23 @@ cleanup_joiner()
if [[ -n ${STATDIR:-} ]];then
[[ -d $STATDIR ]] && rm -rf $STATDIR
fi
+
+ # Final cleanup
+ pgid=$(ps -o pgid= $$ | grep -o '[0-9]*')
+
+ # This means no setsid done in mysqld.
+ # We don't want to kill mysqld here otherwise.
+ if [[ $$ -eq $pgid ]];then
+
+ # This means a signal was delivered to the process.
+ # So, more cleanup.
+ if [[ $estatus -ge 128 ]];then
+ kill -KILL -$$ || true
+ fi
+
+ fi
+
+ exit $estatus
}
check_pid()
@@ -399,6 +448,24 @@ cleanup_donor()
if [[ -n $itmpdir ]];then
[[ -d $itmpdir ]] && rm -rf $itmpdir || true
fi
+
+ # Final cleanup
+ pgid=$(ps -o pgid= $$ | grep -o '[0-9]*')
+
+ # This means no setsid done in mysqld.
+ # We don't want to kill mysqld here otherwise.
+ if [[ $$ -eq $pgid ]];then
+
+ # This means a signal was delivered to the process.
+ # So, more cleanup.
+ if [[ $estatus -ge 128 ]];then
+ kill -KILL -$$ || true
+ fi
+
+ fi
+
+ exit $estatus
+
}
kill_xtrabackup()
@@ -415,6 +482,7 @@ setup_ports()
SST_PORT=$(echo $WSREP_SST_OPT_ADDR | awk -F '[:/]' '{ print $2 }')
REMOTEIP=$(echo $WSREP_SST_OPT_ADDR | awk -F ':' '{ print $1 }')
lsn=$(echo $WSREP_SST_OPT_ADDR | awk -F '[:/]' '{ print $4 }')
+ sst_ver=$(echo $WSREP_SST_OPT_ADDR | awk -F '[:/]' '{ print $5 }')
else
SST_PORT=$(echo ${WSREP_SST_OPT_ADDR} | awk -F ':' '{ print $2 }')
fi
@@ -432,11 +500,7 @@ wait_for_listen()
ss -p state listening "( sport = :$PORT )" | grep -qE 'socat|nc' && break
sleep 0.2
done
- if [[ $incremental -eq 1 ]];then
- echo "ready ${ADDR}/${MODULE}/$lsn"
- else
- echo "ready ${ADDR}/${MODULE}"
- fi
+ echo "ready ${ADDR}/${MODULE}//$sst_ver"
}
check_extra()
@@ -469,8 +533,14 @@ recv_joiner()
local dir=$1
local msg=$2
local tmt=$3
+ local checkf=$4
local ltcmd
+ if [[ ! -d ${dir} ]];then
+ # This indicates that IST is in progress
+ return
+ fi
+
pushd ${dir} 1>/dev/null
set +e
@@ -478,7 +548,7 @@ recv_joiner()
if timeout --help | grep -q -- '-k';then
ltcmd="timeout -k $(( tmt+10 )) $tmt $tcmd"
else
- ltcmd="timeout $tmt $tcmd"
+ ltcmd="timeout -s9 $tmt $tcmd"
fi
timeit "$msg" "$ltcmd | $strmcmd; RC=( "\${PIPESTATUS[@]}" )"
else
@@ -501,7 +571,7 @@ recv_joiner()
fi
done
- if [ ! -r "${MAGIC_FILE}" ];then
+ if [[ $checkf -eq 1 && ! -r "${MAGIC_FILE}" ]];then
# this message should cause joiner to abort
wsrep_log_error "xtrabackup process ended without creating '${MAGIC_FILE}'"
wsrep_log_info "Contents of datadir"
@@ -547,18 +617,52 @@ fi
read_cnf
setup_ports
-get_stream
-get_transfer
-if ${INNOBACKUPEX_BIN} /tmp --help | grep -- '--version-check' >/dev/null ; then
+if ${INNOBACKUPEX_BIN} /tmp --help 2>/dev/null | grep -q -- '--version-check'; then
disver="--no-version-check"
fi
+if [[ ${FORCE_FTWRL:-0} -eq 1 ]];then
+ wsrep_log_info "Forcing FTWRL due to environment variable FORCE_FTWRL equal to $FORCE_FTWRL"
+ iopts+=" --no-backup-locks "
+fi
+
INNOEXTRA=""
-INNOAPPLY="${INNOBACKUPEX_BIN} $disver $iapts --apply-log \$rebuildcmd \${DATA} &>\${DATA}/innobackup.prepare.log"
-INNOMOVE="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} $disver $impts --move-back --force-non-empty-directories \${DATA} &>\${DATA}/innobackup.move.log"
-INNOBACKUP="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} $disver $iopts \$tmpopts \$INNOEXTRA --galera-info --stream=\$sfmt \$itmpdir 2>\${DATA}/innobackup.backup.log"
+
+if [[ $ssyslog -eq 1 ]];then
+
+ if [[ ! -x `which logger` ]];then
+ wsrep_log_error "logger not in path: $PATH. Ignoring"
+ else
+
+ wsrep_log_info "Logging all stderr of SST/Innobackupex to syslog"
+
+ exec 2> >(logger -p daemon.err -t ${ssystag}wsrep-sst-$WSREP_SST_OPT_ROLE)
+
+ wsrep_log_error()
+ {
+ logger -p daemon.err -t ${ssystag}wsrep-sst-$WSREP_SST_OPT_ROLE "$@"
+ }
+
+ wsrep_log_info()
+ {
+ logger -p daemon.info -t ${ssystag}wsrep-sst-$WSREP_SST_OPT_ROLE "$@"
+ }
+
+ INNOAPPLY="${INNOBACKUPEX_BIN} $disver $iapts --apply-log \$rebuildcmd \${DATA} 2>&1 | logger -p daemon.err -t ${ssystag}innobackupex-apply "
+ INNOMOVE="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} $disver $impts --move-back --force-non-empty-directories \${DATA} 2>&1 | logger -p daemon.err -t ${ssystag}innobackupex-move "
+ INNOBACKUP="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} $disver $iopts \$tmpopts \$INNOEXTRA --galera-info --stream=\$sfmt \$itmpdir 2> >(logger -p daemon.err -t ${ssystag}innobackupex-backup)"
+ fi
+
+else
+ INNOAPPLY="${INNOBACKUPEX_BIN} $disver $iapts --apply-log \$rebuildcmd \${DATA} &>\${DATA}/innobackup.prepare.log"
+ INNOMOVE="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} $disver $impts --move-back --force-non-empty-directories \${DATA} &>\${DATA}/innobackup.move.log"
+ INNOBACKUP="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} $disver $iopts \$tmpopts \$INNOEXTRA --galera-info --stream=\$sfmt \$itmpdir 2>\${DATA}/innobackup.backup.log"
+fi
+
+get_stream
+get_transfer
if [ "$WSREP_SST_OPT_ROLE" = "donor" ]
then
@@ -566,6 +670,11 @@ then
if [ $WSREP_SST_OPT_BYPASS -eq 0 ]
then
+ if [[ -z $sst_ver ]];then
+ wsrep_log_error "Upgrade joiner to 5.6.21 or higher for backup locks support"
+ wsrep_log_error "The joiner is not supported for this version of donor"
+ exit 93
+ fi
if [[ -z $(parse_cnf mysqld tmpdir "") && -z $(parse_cnf xtrabackup tmpdir "") ]];then
xtmpdir=$(mktemp -d)
@@ -576,13 +685,14 @@ then
itmpdir=$(mktemp -d)
wsrep_log_info "Using $itmpdir as innobackupex temporary directory"
- if [ "${AUTH[0]}" != "(null)" ]; then
- INNOEXTRA+=" --user=${AUTH[0]}"
- fi
+ if [ "$WSREP_SST_OPT_USER" != "(null)" ]; then
+ INNOEXTRA+=" --user=$WSREP_SST_OPT_USER"
+ fi
- if [ ${#AUTH[*]} -eq 2 ]; then
- INNOEXTRA+=" --password=${AUTH[1]}"
- elif [ "${AUTH[0]}" != "(null)" ]; then
+ if [ -n "$WSREP_SST_OPT_PSWD" ]; then
+# INNOEXTRA+=" --password=$WSREP_SST_OPT_PSWD"
+ export MYSQL_PWD="$WSREP_SST_OPT_PSWD"
+ else
# Empty password, used for testing, debugging etc.
INNOEXTRA+=" --password="
fi
@@ -596,9 +706,6 @@ then
fi
fi
- if [[ -n $lsn ]];then
- INNOEXTRA+=" --incremental --incremental-lsn=$lsn "
- fi
check_extra
@@ -691,25 +798,12 @@ then
[[ -e $SST_PROGRESS_FILE ]] && wsrep_log_info "Stale sst_in_progress file: $SST_PROGRESS_FILE"
[[ -n $SST_PROGRESS_FILE ]] && touch $SST_PROGRESS_FILE
- if [[ $speciald -eq 1 ]];then
- ib_home_dir=$(parse_cnf mysqld innodb-data-home-dir "")
- ib_log_dir=$(parse_cnf mysqld innodb-log-group-home-dir "")
- if [[ -z $ib_home_dir && -z $ib_log_dir ]];then
- speciald=0
- fi
- fi
+ ib_home_dir=$(parse_cnf mysqld innodb-data-home-dir "")
+ ib_log_dir=$(parse_cnf mysqld innodb-log-group-home-dir "")
+ ib_undo_dir=$(parse_cnf mysqld innodb-undo-directory "")
stagemsg="Joiner-Recv"
- if [[ ! -e ${DATA}/ibdata1 ]];then
- incremental=0
- fi
-
- if [[ $incremental -eq 1 ]];then
- wsrep_log_info "Incremental SST enabled: NOT SUPPORTED yet"
- lsn=$(grep to_lsn xtrabackup_checkpoints | cut -d= -f2 | tr -d ' ')
- wsrep_log_info "Recovered LSN: $lsn"
- fi
sencrypted=1
nthreads=1
@@ -738,12 +832,6 @@ then
tcmd+=" | $pcmd"
fi
- if [[ $incremental -eq 1 ]];then
- BDATA=$DATA
- DATA=$(mktemp -d)
- MAGIC_FILE="${DATA}/${INFO_FILE}"
- fi
-
get_keys
if [[ $encrypt -eq 1 && $sencrypted -eq 1 ]];then
if [[ -n $sdecomp ]];then
@@ -757,7 +845,8 @@ then
STATDIR=$(mktemp -d)
MAGIC_FILE="${STATDIR}/${INFO_FILE}"
- recv_joiner $STATDIR "${stagemsg}-gtid" $stimeout
+ recv_joiner $STATDIR "${stagemsg}-gtid" $stimeout 1
+
if ! ps -p ${WSREP_SST_OPT_PARENT} &>/dev/null
then
@@ -767,51 +856,48 @@ then
if [ ! -r "${STATDIR}/${IST_FILE}" ]
then
- wsrep_log_info "Proceeding with SST"
- if [[ $speciald -eq 1 && -d ${DATA}/.sst ]];then
- wsrep_log_info "WARNING: Stale temporary SST directory: ${DATA}/.sst from previous SST"
+ if [[ -d ${DATA}/.sst ]];then
+ wsrep_log_info "WARNING: Stale temporary SST directory: ${DATA}/.sst from previous state transfer"
fi
+ mkdir -p ${DATA}/.sst
+ (recv_joiner $DATA/.sst "${stagemsg}-SST" 0 0) &
+ jpid=$!
+ wsrep_log_info "Proceeding with SST"
- if [[ $incremental -ne 1 ]];then
- if [[ $speciald -eq 1 ]];then
- wsrep_log_info "Cleaning the existing datadir and innodb-data/log directories"
- find $ib_home_dir $ib_log_dir $DATA -mindepth 1 -regex $cpat -prune -o -exec rm -rfv {} 1>&2 \+
- else
- wsrep_log_info "Cleaning the existing datadir"
- find $DATA -mindepth 1 -regex $cpat -prune -o -exec rm -rfv {} 1>&2 \+
- fi
- tempdir=$(parse_cnf mysqld log-bin "")
- if [[ -n ${tempdir:-} ]];then
- binlog_dir=$(dirname $tempdir)
- binlog_file=$(basename $tempdir)
- if [[ -n ${binlog_dir:-} && $binlog_dir != '.' && $binlog_dir != $DATA ]];then
- pattern="$binlog_dir/$binlog_file\.[0-9]+$"
- wsrep_log_info "Cleaning the binlog directory $binlog_dir as well"
- find $binlog_dir -maxdepth 1 -type f -regex $pattern -exec rm -fv {} 1>&2 \+
- rm $binlog_dir/*.index || true
- rm $binlog_dir/*.state || true
- fi
- fi
- else
- wsrep_log_info "Removing existing ib_logfile files"
- rm -f ${BDATA}/ib_logfile*
+ wsrep_log_info "Cleaning the existing datadir and innodb-data/log directories"
+ find $ib_home_dir $ib_log_dir $ib_undo_dir $DATA -mindepth 1 -regex $cpat -prune -o -exec rm -rfv {} 1>&2 \+
+
+ tempdir=$(parse_cnf mysqld log-bin "")
+ if [[ -n ${tempdir:-} ]];then
+ binlog_dir=$(dirname $tempdir)
+ binlog_file=$(basename $tempdir)
+ if [[ -n ${binlog_dir:-} && $binlog_dir != '.' && $binlog_dir != $DATA ]];then
+ pattern="$binlog_dir/$binlog_file\.[0-9]+$"
+ wsrep_log_info "Cleaning the binlog directory $binlog_dir as well"
+ find $binlog_dir -maxdepth 1 -type f -regex $pattern -exec rm -fv {} 1>&2 \+ || true
+ rm $binlog_dir/*.index || true
+ fi
fi
- if [[ $speciald -eq 1 ]];then
- mkdir -p ${DATA}/.sst
- TDATA=${DATA}
- DATA="${DATA}/.sst"
- fi
+
+ TDATA=${DATA}
+ DATA="${DATA}/.sst"
MAGIC_FILE="${DATA}/${INFO_FILE}"
- recv_joiner $DATA "${stagemsg}-SST" 0
+ wsrep_log_info "Waiting for SST streaming to complete!"
+ wait $jpid
get_proc
+ if [[ ! -s ${DATA}/xtrabackup_checkpoints ]];then
+ wsrep_log_error "xtrabackup_checkpoints missing, failed innobackupex/SST on donor"
+ exit 2
+ fi
+
# Rebuild indexes for compact backups
if grep -q 'compact = 1' ${DATA}/xtrabackup_checkpoints;then
wsrep_log_info "Index compaction detected"
@@ -883,12 +969,6 @@ then
fi
- if [[ $incremental -eq 1 ]];then
- # Added --ibbackup=xtrabackup_55 because it fails otherwise citing connection issues.
- INNOAPPLY="${INNOBACKUPEX_BIN} $disver ${WSREP_SST_OPT_CONF} \
- --ibbackup=xtrabackup_56 --apply-log $rebuildcmd --redo-only $BDATA --incremental-dir=${DATA} &>>${BDATA}/innobackup.prepare.log"
- fi
-
wsrep_log_info "Preparing the backup at ${DATA}"
timeit "Xtrabackup prepare stage" "$INNOAPPLY"
@@ -898,28 +978,22 @@ then
exit 22
fi
- if [[ $speciald -eq 1 ]];then
- MAGIC_FILE="${TDATA}/${INFO_FILE}"
- set +e
- rm $TDATA/innobackup.prepare.log $TDATA/innobackup.move.log
- set -e
- wsrep_log_info "Moving the backup to ${TDATA}"
- timeit "Xtrabackup move stage" "$INNOMOVE"
- if [[ $? -eq 0 ]];then
- wsrep_log_info "Move successful, removing ${DATA}"
- rm -rf $DATA
- DATA=${TDATA}
- else
- wsrep_log_error "Move failed, keeping ${DATA} for further diagnosis"
- wsrep_log_error "Check ${DATA}/innobackup.move.log for details"
- fi
+ MAGIC_FILE="${TDATA}/${INFO_FILE}"
+ set +e
+ rm $TDATA/innobackup.prepare.log $TDATA/innobackup.move.log
+ set -e
+ wsrep_log_info "Moving the backup to ${TDATA}"
+ timeit "Xtrabackup move stage" "$INNOMOVE"
+ if [[ $? -eq 0 ]];then
+ wsrep_log_info "Move successful, removing ${DATA}"
+ rm -rf $DATA
+ DATA=${TDATA}
+ else
+ wsrep_log_error "Move failed, keeping ${DATA} for further diagnosis"
+ wsrep_log_error "Check ${DATA}/innobackup.move.log for details"
+ exit 22
fi
- if [[ $incremental -eq 1 ]];then
- wsrep_log_info "Cleaning up ${DATA} after incremental SST"
- [[ -d ${DATA} ]] && rm -rf ${DATA}
- DATA=$BDATA
- fi
else
wsrep_log_info "${IST_FILE} received from donor: Running IST"
@@ -929,6 +1003,7 @@ then
wsrep_log_error "SST magic file ${MAGIC_FILE} not found/readable"
exit 2
fi
+ wsrep_log_info "Galera co-ords from recovery: $(cat ${MAGIC_FILE})"
cat "${MAGIC_FILE}" # Output : UUID:seqno wsrep_gtid_domain_id
wsrep_log_info "Total time on joiner: $totime seconds"
fi
diff --git a/scripts/wsrep_sst_xtrabackup.sh b/scripts/wsrep_sst_xtrabackup.sh
index 4b22c227dd5..1ef3c3f3ce1 100644
--- a/scripts/wsrep_sst_xtrabackup.sh
+++ b/scripts/wsrep_sst_xtrabackup.sh
@@ -61,7 +61,6 @@ pcmd="pv $pvopts"
declare -a RC
INNOBACKUPEX_BIN=innobackupex
-readonly AUTH=(${WSREP_SST_OPT_AUTH//:/ })
DATA="${WSREP_SST_OPT_DATA}"
INFO_FILE="xtrabackup_galera_info"
IST_FILE="xtrabackup_ist"
@@ -150,7 +149,11 @@ get_transfer()
fi
wsrep_log_info "Using netcat as streamer"
if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
- tcmd="nc -dl ${TSST_PORT}"
+ if nc -h | grep -q ncat;then
+ tcmd="nc -l ${TSST_PORT}"
+ else
+ tcmd="nc -dl ${TSST_PORT}"
+ fi
else
tcmd="nc ${REMOTEIP} ${TSST_PORT}"
fi
@@ -435,13 +438,14 @@ then
then
TMPDIR="${TMPDIR:-/tmp}"
- if [ "${AUTH[0]}" != "(null)" ]; then
- INNOEXTRA+=" --user=${AUTH[0]}"
- fi
+ if [ "$WSREP_SST_OPT_USER" != "(null)" ]; then
+ INNOEXTRA+=" --user=$WSREP_SST_OPT_USER"
+ fi
- if [ ${#AUTH[*]} -eq 2 ]; then
- INNOEXTRA+=" --password=${AUTH[1]}"
- elif [ "${AUTH[0]}" != "(null)" ]; then
+ if [ -n "$WSREP_SST_OPT_PSWD" ]; then
+# INNOEXTRA+=" --password=$WSREP_SST_OPT_PSWD"
+ export MYSQL_PWD="$WSREP_SST_OPT_PSWD"
+ else
# Empty password, used for testing, debugging etc.
INNOEXTRA+=" --password="
fi