mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Merge 10.4 into 10.5
This commit is contained in:
@@ -611,8 +611,12 @@ then
|
||||
echo
|
||||
echo
|
||||
echo "PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !"
|
||||
echo "To do so, start the server, then issue the following command:"
|
||||
echo "To do so, start the server, then issue the following commands:"
|
||||
echo
|
||||
echo "'$bindir/mysqladmin' -u root password 'new-password'"
|
||||
echo "'$bindir/mysqladmin' -u root -h $hostname password 'new-password'"
|
||||
echo
|
||||
echo "Alternatively you can run:"
|
||||
echo "'$bindir/mysql_secure_installation'"
|
||||
echo
|
||||
echo "which will also give you the option of removing the test"
|
||||
|
@@ -1,4 +1,5 @@
|
||||
# Copyright (C) 2012-2015 Codership Oy
|
||||
# Copyright (C) 2017-2021 MariaDB
|
||||
#
|
||||
# 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
|
||||
@@ -21,24 +22,32 @@ set -u
|
||||
WSREP_SST_OPT_BYPASS=0
|
||||
WSREP_SST_OPT_BINLOG=""
|
||||
WSREP_SST_OPT_BINLOG_INDEX=""
|
||||
WSREP_SST_OPT_LOG_BASENAME=""
|
||||
WSREP_SST_OPT_DATA=""
|
||||
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_AUTH="${WSREP_SST_OPT_AUTH:-}"
|
||||
WSREP_SST_OPT_USER="${WSREP_SST_OPT_USER:-}"
|
||||
WSREP_SST_OPT_PSWD="${WSREP_SST_OPT_PSWD:-}"
|
||||
WSREP_SST_OPT_REMOTE_AUTH="${WSREP_SST_OPT_REMOTE_AUTH:-}"
|
||||
WSREP_SST_OPT_DEFAULT=""
|
||||
WSREP_SST_OPT_EXTRA_DEFAULT=""
|
||||
WSREP_SST_OPT_SUFFIX_DEFAULT=""
|
||||
WSREP_SST_OPT_SUFFIX_VALUE=""
|
||||
WSREP_SST_OPT_MYSQLD=""
|
||||
INNODB_DATA_HOME_DIR_ARG=""
|
||||
INNODB_LOG_GROUP_HOME_ARG=""
|
||||
INNODB_UNDO_DIR_ARG=""
|
||||
LOG_BIN_ARG=""
|
||||
WSREP_SST_OPT_PORT=""
|
||||
WSREP_SST_OPT_ADDR=""
|
||||
WSREP_SST_OPT_ADDR_PORT=""
|
||||
WSREP_SST_OPT_HOST=""
|
||||
WSREP_SST_OPT_HOST_UNESCAPED=""
|
||||
WSREP_SST_OPT_HOST_ESCAPED=""
|
||||
INNODB_DATA_HOME_DIR="${INNODB_DATA_HOME_DIR:-}"
|
||||
INNODB_LOG_GROUP_HOME="${INNODB_LOG_GROUP_HOME:-}"
|
||||
INNODB_UNDO_DIR="${INNODB_UNDO_DIR:-}"
|
||||
INNOEXTRA=""
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
'--address')
|
||||
readonly WSREP_SST_OPT_ADDR="$2"
|
||||
WSREP_SST_OPT_ADDR="$2"
|
||||
#
|
||||
# Break address string into host:port/path parts
|
||||
#
|
||||
@@ -46,60 +55,61 @@ case "$1" in
|
||||
\[*)
|
||||
# IPv6
|
||||
# Remove the starting and ending square brackets, if present:
|
||||
addr_no_bracket=${WSREP_SST_OPT_ADDR#\[}
|
||||
readonly WSREP_SST_OPT_HOST_UNESCAPED=${addr_no_bracket%%\]*}
|
||||
# Square brackets are needed in most cases:
|
||||
readonly WSREP_SST_OPT_HOST="[${WSREP_SST_OPT_HOST_UNESCAPED}]"
|
||||
addr_no_bracket="${WSREP_SST_OPT_ADDR#\[}"
|
||||
# Some utilities and subsequent code require an address
|
||||
# without square brackets:
|
||||
readonly WSREP_SST_OPT_HOST_UNESCAPED="${addr_no_bracket%%\]*}"
|
||||
# Square brackets are needed in most cases:
|
||||
readonly WSREP_SST_OPT_HOST="[${WSREP_SST_OPT_HOST_UNESCAPED}]"
|
||||
readonly WSREP_SST_OPT_HOST_ESCAPED="\\[${WSREP_SST_OPT_HOST_UNESCAPED}\\]"
|
||||
# Mark this address as IPv6:
|
||||
readonly WSREP_SST_OPT_HOST_IPv6=1
|
||||
;;
|
||||
*)
|
||||
readonly WSREP_SST_OPT_HOST=${WSREP_SST_OPT_ADDR%%[:/]*}
|
||||
readonly WSREP_SST_OPT_HOST_UNESCAPED=$WSREP_SST_OPT_HOST
|
||||
readonly WSREP_SST_OPT_HOST_ESCAPED=$WSREP_SST_OPT_HOST
|
||||
readonly WSREP_SST_OPT_HOST="${WSREP_SST_OPT_ADDR%%[:/]*}"
|
||||
readonly WSREP_SST_OPT_HOST_UNESCAPED="$WSREP_SST_OPT_HOST"
|
||||
readonly WSREP_SST_OPT_HOST_ESCAPED="$WSREP_SST_OPT_HOST"
|
||||
readonly WSREP_SST_OPT_HOST_IPv6=0
|
||||
;;
|
||||
esac
|
||||
# Let's remove the leading part that contains the host address:
|
||||
remain=${WSREP_SST_OPT_ADDR#${WSREP_SST_OPT_HOST_ESCAPED}}
|
||||
remain="${WSREP_SST_OPT_ADDR#$WSREP_SST_OPT_HOST_ESCAPED}"
|
||||
# Let's remove the ":" character that separates the port number
|
||||
# from the hostname:
|
||||
remain=${remain#:}
|
||||
remain="${remain#:}"
|
||||
# Extract the port number from the address - all characters
|
||||
# up to "/" (if present):
|
||||
readonly WSREP_SST_OPT_ADDR_PORT=${remain%%/*}
|
||||
WSREP_SST_OPT_ADDR_PORT="${remain%%/*}"
|
||||
# If the "/" character is present, then the path is not empty:
|
||||
if [ "${remain#*/}" != "${remain}" ]; then
|
||||
# This operation removes everything up to the "/" character,
|
||||
# effectively removing the port number from the string:
|
||||
readonly WSREP_SST_OPT_PATH=${remain#*/}
|
||||
readonly WSREP_SST_OPT_PATH="${remain#*/}"
|
||||
else
|
||||
readonly WSREP_SST_OPT_PATH=""
|
||||
fi
|
||||
# The rest of the string is the same as the path (for now):
|
||||
remain=${WSREP_SST_OPT_PATH}
|
||||
remain="${WSREP_SST_OPT_PATH}"
|
||||
# If there is one more "/" in the string, then everything before
|
||||
# it will be the module name, otherwise the module name is empty:
|
||||
if [ "${remain%%/*}" != "${remain}" ]; then
|
||||
# This operation removes the tail after the very first
|
||||
# occurrence of the "/" character (inclusively):
|
||||
readonly WSREP_SST_OPT_MODULE=${remain%%/*}
|
||||
readonly WSREP_SST_OPT_MODULE="${remain%%/*}"
|
||||
else
|
||||
readonly WSREP_SST_OPT_MODULE=""
|
||||
fi
|
||||
# Remove the module name part from the string, which ends with "/":
|
||||
remain=${WSREP_SST_OPT_PATH#*/}
|
||||
remain="${WSREP_SST_OPT_PATH#*/}"
|
||||
# If the rest of the string does not match the original, then there
|
||||
# was something else besides the module name:
|
||||
if [ "$remain" != "${WSREP_SST_OPT_PATH}" ]; then
|
||||
# Extract the part that matches the LSN by removing all
|
||||
# characters starting from the very first "/":
|
||||
readonly WSREP_SST_OPT_LSN=${remain%%/*}
|
||||
readonly WSREP_SST_OPT_LSN="${remain%%/*}"
|
||||
# Exctract everything after the first occurrence of
|
||||
# the "/" character in the string:
|
||||
remain=${remain#*/}
|
||||
remain="${remain#*/}"
|
||||
# If the remainder does not match the original string,
|
||||
# then there is something else (the version number in
|
||||
# our case):
|
||||
@@ -107,7 +117,7 @@ case "$1" in
|
||||
# Let's extract the version number by removing the tail
|
||||
# after the very first occurence of the "/" character
|
||||
# (inclusively):
|
||||
readonly WSREP_SST_OPT_SST_VER=${remain%%/*}
|
||||
readonly WSREP_SST_OPT_SST_VER="${remain%%/*}"
|
||||
else
|
||||
readonly WSREP_SST_OPT_SST_VER=""
|
||||
fi
|
||||
@@ -121,23 +131,23 @@ case "$1" in
|
||||
WSREP_SST_OPT_BYPASS=1
|
||||
;;
|
||||
'--datadir')
|
||||
readonly WSREP_SST_OPT_DATA="$2"
|
||||
# Let's remove the trailing slash:
|
||||
readonly WSREP_SST_OPT_DATA="${2%/}"
|
||||
shift
|
||||
;;
|
||||
'--innodb-data-home-dir')
|
||||
readonly INNODB_DATA_HOME_DIR_ARG="$2"
|
||||
# Let's remove the trailing slash:
|
||||
readonly INNODB_DATA_HOME_DIR="${2%/}"
|
||||
shift
|
||||
;;
|
||||
'--innodb-log-group-home-dir')
|
||||
readonly INNODB_LOG_GROUP_HOME_ARG="$2"
|
||||
# Let's remove the trailing slash:
|
||||
readonly INNODB_LOG_GROUP_HOME="${2%/}"
|
||||
shift
|
||||
;;
|
||||
'--innodb-undo-directory')
|
||||
readonly INNODB_UNDO_DIR_ARG="$2"
|
||||
shift
|
||||
;;
|
||||
'--log-bin')
|
||||
readonly LOG_BIN_ARG="$2"
|
||||
# Let's remove the trailing slash:
|
||||
readonly INNODB_UNDO_DIR="${2%/}"
|
||||
shift
|
||||
;;
|
||||
'--defaults-file')
|
||||
@@ -154,7 +164,28 @@ case "$1" in
|
||||
shift
|
||||
;;
|
||||
'--host')
|
||||
readonly WSREP_SST_OPT_HOST="$2"
|
||||
case "$2" in
|
||||
\[*)
|
||||
# IPv6
|
||||
# Remove the starting and ending square brackets, if present:
|
||||
addr_no_bracket="${2#\[}"
|
||||
# Some utilities and subsequent code require an address
|
||||
# without square brackets:
|
||||
readonly WSREP_SST_OPT_HOST_UNESCAPED="${addr_no_bracket%%\]*}"
|
||||
# Square brackets are needed in most cases:
|
||||
readonly WSREP_SST_OPT_HOST="[${WSREP_SST_OPT_HOST_UNESCAPED}]"
|
||||
readonly WSREP_SST_OPT_HOST_ESCAPED="\\[${WSREP_SST_OPT_HOST_UNESCAPED}\\]"
|
||||
# Mark this address as IPv6:
|
||||
readonly WSREP_SST_OPT_HOST_IPv6=1
|
||||
;;
|
||||
*)
|
||||
readonly WSREP_SST_OPT_HOST="$2"
|
||||
readonly WSREP_SST_OPT_HOST_UNESCAPED="$2"
|
||||
readonly WSREP_SST_OPT_HOST_ESCAPED="$2"
|
||||
readonly WSREP_SST_OPT_HOST_IPv6=0
|
||||
;;
|
||||
esac
|
||||
WSREP_SST_OPT_ADDR="$WSREP_SST_OPT_HOST"
|
||||
shift
|
||||
;;
|
||||
'--local-port')
|
||||
@@ -189,14 +220,18 @@ case "$1" in
|
||||
readonly WSREP_SST_OPT_GTID="$2"
|
||||
shift
|
||||
;;
|
||||
'--binlog')
|
||||
WSREP_SST_OPT_BINLOG="$2"
|
||||
'--binlog'|'--log-bin')
|
||||
readonly WSREP_SST_OPT_BINLOG="$2"
|
||||
shift
|
||||
;;
|
||||
'--binlog-index'|'--log-bin-index')
|
||||
readonly WSREP_SST_OPT_BINLOG_INDEX="$2"
|
||||
shift
|
||||
;;
|
||||
'--log-basename')
|
||||
readonly WSREP_SST_OPT_LOG_BASENAME="$2"
|
||||
shift
|
||||
;;
|
||||
'--binlog-index')
|
||||
WSREP_SST_OPT_BINLOG_INDEX="$2"
|
||||
shift
|
||||
;;
|
||||
'--gtid-domain-id')
|
||||
readonly WSREP_SST_OPT_GTID_DOMAIN_ID="$2"
|
||||
shift
|
||||
@@ -205,47 +240,116 @@ case "$1" in
|
||||
original_cmd=""
|
||||
shift
|
||||
while [ $# -gt 0 ]; do
|
||||
option=${1%%=*}
|
||||
if [[ "$option" != "--defaults-file" && \
|
||||
"$option" != "--defaults-extra-file" && \
|
||||
"$option" != "--defaults-group-suffix" && \
|
||||
"$option" != "--port" && \
|
||||
"$option" != "--socket" ]]; then
|
||||
value=${1#*=}
|
||||
if [ "$value" == "$1" ]; then
|
||||
value=""
|
||||
fi
|
||||
case "$option" in
|
||||
'--innodb-data-home-dir')
|
||||
if [ -z "$INNODB_DATA_HOME_DIR_ARG" ]; then
|
||||
readonly INNODB_DATA_HOME_DIR_ARG="$value"
|
||||
fi
|
||||
;;
|
||||
'--innodb-log-group-home-dir')
|
||||
if [ -z "$INNODB_LOG_GROUP_HOME_ARG" ]; then
|
||||
readonly INNODB_LOG_GROUP_HOME_ARG="$value"
|
||||
fi
|
||||
;;
|
||||
'--innodb-undo-directory')
|
||||
if [ -z "$INNODB_UNDO_DIR_ARG" ]; then
|
||||
readonly INNODB_UNDO_DIR_ARG="$value"
|
||||
fi
|
||||
;;
|
||||
'--log-bin')
|
||||
if [ -z "$LOG_BIN_ARG" ]; then
|
||||
readonly LOG_BIN_ARG="$value"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
if [ -z "$original_cmd" ]; then
|
||||
original_cmd="$1"
|
||||
else
|
||||
original_cmd="$original_cmd $1"
|
||||
fi
|
||||
# check if the argument is the short option
|
||||
# (starting with "-" instead of "--"):
|
||||
if [ "${1#--}" = "$1" -a "${1#-}" != "$1" ]; then
|
||||
option="${1#-}"
|
||||
value=""
|
||||
# check that the option value follows the name,
|
||||
# without a space:
|
||||
if [ ${#option} -gt 1 ]; then
|
||||
# let's separate the first character as the option name,
|
||||
# and the subsequent characters consider its value:
|
||||
value="${1#-?}"
|
||||
option="${1%$value}"
|
||||
# check that the option name consists of one letter
|
||||
# and there are the following arguments:
|
||||
elif [ ${#option} -eq 1 -a $# -gt 1 ]; then
|
||||
# if the next argument does not start with a "-" character,
|
||||
# then this is the value of the current option:
|
||||
if [ "${2#-}" = "$2" ]; then
|
||||
value="$2"
|
||||
shift
|
||||
fi
|
||||
fi
|
||||
shift
|
||||
if [ "$option" = 'h' ]; then
|
||||
if [ -z "$WSREP_SST_OPT_DATA" ]; then
|
||||
MYSQLD_OPT_DATADIR="${value%/}"
|
||||
fi
|
||||
elif [ "$option" != 'u' -a \
|
||||
"$option" != 'P' ]; then
|
||||
if [ -z "$original_cmd" ]; then
|
||||
original_cmd="'-$option$value'"
|
||||
else
|
||||
original_cmd="$original_cmd '-$option$value'"
|
||||
fi
|
||||
fi
|
||||
continue;
|
||||
fi
|
||||
shift
|
||||
option="${1%%=*}"
|
||||
if [ "$option" != '--defaults-file' -a \
|
||||
"$option" != '--defaults-extra-file' -a \
|
||||
"$option" != '--defaults-group-suffix' -a \
|
||||
"$option" != '--user' -a \
|
||||
"$option" != '--port' -a \
|
||||
"$option" != '--socket' ]; then
|
||||
value="${1#*=}"
|
||||
if [ "$value" = "$1" ]; then
|
||||
value=""
|
||||
fi
|
||||
# Let's fill in the variables containing important paths
|
||||
# that might not have been passed through explicit parameters
|
||||
# (+ removing the trailing slash in these paths). Many of these
|
||||
# options are processed internally within scripts or passed
|
||||
# explicitly to other programs, so we need to remove them
|
||||
# from mysqld's argument list:
|
||||
skip_mysqld_arg=0
|
||||
case "$option" in
|
||||
'--innodb-data-home-dir')
|
||||
if [ -z "$INNODB_DATA_HOME_DIR" ]; then
|
||||
MYSQLD_OPT_INNODB_DATA_HOME_DIR="${value%/}"
|
||||
fi
|
||||
skip_mysqld_arg=1
|
||||
;;
|
||||
'--innodb-log-group-home-dir')
|
||||
if [ -z "$INNODB_LOG_GROUP_HOME" ]; then
|
||||
MYSQLD_OPT_INNODB_LOG_GROUP_HOME="${value%/}"
|
||||
fi
|
||||
skip_mysqld_arg=1
|
||||
;;
|
||||
'--innodb-undo-directory')
|
||||
if [ -z "$INNODB_UNDO_DIR" ]; then
|
||||
MYSQLD_OPT_INNODB_UNDO_DIR="${value%/}"
|
||||
fi
|
||||
skip_mysqld_arg=1
|
||||
;;
|
||||
'--log-bin')
|
||||
if [ -z "$WSREP_SST_OPT_BINLOG" ]; then
|
||||
MYSQLD_OPT_LOG_BIN="$value"
|
||||
fi
|
||||
skip_mysqld_arg=1
|
||||
;;
|
||||
'--log-bin-index')
|
||||
if [ -z "$WSREP_SST_OPT_BINLOG_INDEX" ]; then
|
||||
MYSQLD_OPT_LOG_BIN_INDEX="$value"
|
||||
fi
|
||||
skip_mysqld_arg=1
|
||||
;;
|
||||
'--log-basename')
|
||||
if [ -z "$WSREP_SST_OPT_LOG_BASENAME" ]; then
|
||||
MYSQLD_OPT_LOG_BASENAME="$value"
|
||||
fi
|
||||
skip_mysqld_arg=1
|
||||
;;
|
||||
'--datadir')
|
||||
if [ -z "$WSREP_SST_OPT_DATA" ]; then
|
||||
MYSQLD_OPT_DATADIR="${value%/}"
|
||||
fi
|
||||
skip_mysqld_arg=1
|
||||
;;
|
||||
esac
|
||||
if [ $skip_mysqld_arg -eq 0 ]; then
|
||||
if [ -z "$original_cmd" ]; then
|
||||
original_cmd="'$1'"
|
||||
else
|
||||
original_cmd="$original_cmd '$1'"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
shift
|
||||
done
|
||||
readonly WSREP_SST_OPT_MYSQLD="$original_cmd"
|
||||
WSREP_SST_OPT_MYSQLD="$original_cmd"
|
||||
break
|
||||
;;
|
||||
*) # must be command
|
||||
@@ -256,19 +360,178 @@ esac
|
||||
shift
|
||||
done
|
||||
readonly WSREP_SST_OPT_BYPASS
|
||||
readonly WSREP_SST_OPT_BINLOG
|
||||
readonly WSREP_SST_OPT_BINLOG_INDEX
|
||||
|
||||
if [ -n "${WSREP_SST_OPT_ADDR_PORT:-}" ]; then
|
||||
if [ -n "${WSREP_SST_OPT_PORT:-}" ]; then
|
||||
if [ "$WSREP_SST_OPT_PORT" != "$WSREP_SST_OPT_ADDR_PORT" ]; then
|
||||
echo "WSREP_SST: [ERROR] port in --port=$WSREP_SST_OPT_PORT differs from port in --address=$WSREP_SST_OPT_ADDR" >&2
|
||||
exit 2
|
||||
fi
|
||||
else
|
||||
readonly WSREP_SST_OPT_PORT="$WSREP_SST_OPT_ADDR_PORT"
|
||||
fi
|
||||
# The same argument can be present on the command line several
|
||||
# times, in this case we must take its last value:
|
||||
if [ -n "${MYSQLD_OPT_INNODB_DATA_HOME_DIR:-}" -a \
|
||||
-z "$INNODB_DATA_HOME_DIR" ]; then
|
||||
readonly INNODB_DATA_HOME_DIR="$MYSQLD_OPT_INNODB_DATA_HOME_DIR"
|
||||
fi
|
||||
if [ -n "${MYSQLD_OPT_INNODB_LOG_GROUP_HOME:-}" -a \
|
||||
-z "$INNODB_LOG_GROUP_HOME" ]; then
|
||||
readonly INNODB_LOG_GROUP_HOME="$MYSQLD_OPT_INNODB_LOG_GROUP_HOME"
|
||||
fi
|
||||
if [ -n "${MYSQLD_OPT_INNODB_UNDO_DIR:-}" -a \
|
||||
-z "$INNODB_UNDO_DIR" ]; then
|
||||
readonly INNODB_UNDO_DIR="$MYSQLD_OPT_INNODB_UNDO_DIR"
|
||||
fi
|
||||
if [ -n "${MYSQLD_OPT_LOG_BIN:-}" -a \
|
||||
-z "$WSREP_SST_OPT_BINLOG" ]; then
|
||||
readonly WSREP_SST_OPT_BINLOG="$MYSQLD_OPT_LOG_BIN"
|
||||
fi
|
||||
if [ -n "${MYSQLD_OPT_LOG_BIN_INDEX:-}" -a \
|
||||
-z "$WSREP_SST_OPT_BINLOG_INDEX" ]; then
|
||||
readonly WSREP_SST_OPT_BINLOG_INDEX="$MYSQLD_OPT_LOG_BIN_INDEX"
|
||||
fi
|
||||
if [ -n "${MYSQLD_OPT_DATADIR:-}" -a \
|
||||
-z "$WSREP_SST_OPT_DATA" ]; then
|
||||
readonly WSREP_SST_OPT_DATA="$MYSQLD_OPT_DATADIR"
|
||||
fi
|
||||
if [ -n "${MYSQLD_OPT_LOG_BASENAME:-}" -a \
|
||||
-z "$WSREP_SST_OPT_LOG_BASENAME" ]; then
|
||||
readonly WSREP_SST_OPT_LOG_BASENAME="$MYSQLD_OPT_LOG_BASENAME"
|
||||
fi
|
||||
|
||||
# If the --log-bin option is present without a value, then
|
||||
# setting WSREP_SST_OPT_BINLOG by using other arguments:
|
||||
if [ -z "$WSREP_SST_OPT_BINLOG" -a -n "${MYSQLD_OPT_LOG_BIN+x}" ]; then
|
||||
if [ -n "$WSREP_SST_OPT_LOG_BASENAME" ]; then
|
||||
# If the WSREP_SST_OPT_BINLOG variable is not set, but
|
||||
# --log-basename is present among the arguments to mysqld,
|
||||
# then set WSREP_SST_OPT_BINLOG equal to the base name with
|
||||
# the "-bin" suffix:
|
||||
readonly WSREP_SST_OPT_BINLOG="$WSREP_SST_OPT_LOG_BASENAME-bin"
|
||||
else
|
||||
# Take the default name:
|
||||
readonly WSREP_SST_OPT_BINLOG='mysql-bin'
|
||||
fi
|
||||
fi
|
||||
|
||||
# Reconstructing the command line arguments that control the innodb
|
||||
# and binlog options:
|
||||
if [ -n "$WSREP_SST_OPT_LOG_BASENAME" ]; then
|
||||
if [ -n "$WSREP_SST_OPT_MYSQLD" ]; then
|
||||
WSREP_SST_OPT_MYSQLD="--log-basename='$WSREP_SST_OPT_LOG_BASENAME' $WSREP_SST_OPT_MYSQLD"
|
||||
else
|
||||
WSREP_SST_OPT_MYSQLD="--log-basename='$WSREP_SST_OPT_LOG_BASENAME'"
|
||||
fi
|
||||
fi
|
||||
if [ -n "$INNODB_DATA_HOME_DIR" ]; then
|
||||
INNOEXTRA="$INNOEXTRA --innodb-data-home-dir='$INNODB_DATA_HOME_DIR'"
|
||||
fi
|
||||
if [ -n "$INNODB_LOG_GROUP_HOME" ]; then
|
||||
INNOEXTRA="$INNOEXTRA --innodb-log-group-home-dir='$INNODB_LOG_GROUP_HOME'"
|
||||
fi
|
||||
if [ -n "$INNODB_UNDO_DIR" ]; then
|
||||
INNOEXTRA="$INNOEXTRA --innodb-undo-directory='$INNODB_UNDO_DIR'"
|
||||
fi
|
||||
if [ -n "$WSREP_SST_OPT_BINLOG" ]; then
|
||||
INNOEXTRA="$INNOEXTRA --log-bin='$WSREP_SST_OPT_BINLOG'"
|
||||
if [ -n "$WSREP_SST_OPT_BINLOG_INDEX" ]; then
|
||||
if [ -n "$WSREP_SST_OPT_MYSQLD" ]; then
|
||||
WSREP_SST_OPT_MYSQLD="--log-bin-index='$WSREP_SST_OPT_BINLOG_INDEX' $WSREP_SST_OPT_MYSQLD"
|
||||
else
|
||||
WSREP_SST_OPT_MYSQLD="--log-bin-index='$WSREP_SST_OPT_BINLOG_INDEX'"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
readonly WSREP_SST_OPT_MYSQLD
|
||||
|
||||
get_binlog()
|
||||
{
|
||||
# if no command line argument and WSREP_SST_OPT_BINLOG is not set,
|
||||
# try to get it from my.cnf:
|
||||
if [ -z "$WSREP_SST_OPT_BINLOG" ]; then
|
||||
WSREP_SST_OPT_BINLOG=$(parse_cnf '--mysqld' 'log-bin')
|
||||
fi
|
||||
# if no command line argument and WSREP_SST_OPT_BINLOG_INDEX is not set,
|
||||
# try to get it from my.cnf:
|
||||
if [ -z "$WSREP_SST_OPT_BINLOG_INDEX" ]; then
|
||||
WSREP_SST_OPT_BINLOG_INDEX=$(parse_cnf '--mysqld' 'log-bin-index')
|
||||
fi
|
||||
# if no command line argument and WSREP_SST_OPT_LOG_BASENAME is not set,
|
||||
# try to get it from my.cnf:
|
||||
if [ -z "$WSREP_SST_OPT_LOG_BASENAME" ]; then
|
||||
WSREP_SST_OPT_LOG_BASENAME=$(parse_cnf '--mysqld' 'log-basename')
|
||||
fi
|
||||
if [ -z "$WSREP_SST_OPT_BINLOG" ]; then
|
||||
# If the --log-bin option is specified without a parameter,
|
||||
# then we need to build the name of the index file according
|
||||
# to the rules described in the server documentation:
|
||||
if [ -n "${MYSQLD_OPT_LOG_BIN+x}" -o \
|
||||
$(in_config '--mysqld' 'log-bin') -eq 1 ]
|
||||
then
|
||||
if [ -n "$WSREP_SST_OPT_LOG_BASENAME" ]; then
|
||||
# If the WSREP_SST_OPT_BINLOG variable is not set, but
|
||||
# --log-basename is present among the arguments of mysqld,
|
||||
# then set WSREP_SST_OPT_BINLOG equal to the base name with
|
||||
# the "-bin" suffix:
|
||||
readonly WSREP_SST_OPT_BINLOG="$WSREP_SST_OPT_LOG_BASENAME-bin"
|
||||
else
|
||||
# If the --log-bin option is present without a value, then
|
||||
# we take the default name:
|
||||
readonly WSREP_SST_OPT_BINLOG='mysql-bin'
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [ -n "$WSREP_SST_OPT_BINLOG" ]; then
|
||||
# If the name of the index file is not specified, then we will build
|
||||
# it according to the specifications for the server:
|
||||
if [ -z "$WSREP_SST_OPT_BINLOG_INDEX" ]; then
|
||||
if [ -n "$WSREP_SST_OPT_LOG_BASENAME" ]; then
|
||||
# If the WSREP_SST_OPT_BINLOG variable is not set, but
|
||||
# --log-basename is present among the arguments of mysqld,
|
||||
# then set WSREP_SST_OPT_BINLOG equal to the base name with
|
||||
# the "-bin" suffix:
|
||||
readonly WSREP_SST_OPT_BINLOG_INDEX="$WSREP_SST_OPT_LOG_BASENAME-bin.index"
|
||||
else
|
||||
# If the base name not specified, then we take
|
||||
# the default name:
|
||||
readonly WSREP_SST_OPT_BINLOG_INDEX='mysql-bin.index'
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Check the presence of the port value and, if necessary, transfer
|
||||
# the port number from the address to the WSREP_SST_OPT_PORT variable
|
||||
# or vice versa, and also, if necessary, substitute the missing port
|
||||
# value into the address value:
|
||||
if [ -n "$WSREP_SST_OPT_ADDR_PORT" ]; then
|
||||
if [ -n "$WSREP_SST_OPT_PORT" ]; then
|
||||
if [ "$WSREP_SST_OPT_PORT" != "$WSREP_SST_OPT_ADDR_PORT" ]; then
|
||||
echo "WSREP_SST: [ERROR] port in --port=$WSREP_SST_OPT_PORT differs from port in --address=$WSREP_SST_OPT_ADDR" >&2
|
||||
exit 2
|
||||
fi
|
||||
else
|
||||
# If the address contains a port number, assign it to
|
||||
# the corresponding variable:
|
||||
readonly WSREP_SST_OPT_PORT="$WSREP_SST_OPT_ADDR_PORT"
|
||||
fi
|
||||
elif [ -n "$WSREP_SST_OPT_ADDR" ]; then
|
||||
# If the port is missing, take the default port:
|
||||
if [ -z "$WSREP_SST_OPT_PORT" ]; then
|
||||
readonly WSREP_SST_OPT_PORT=4444
|
||||
fi
|
||||
WSREP_SST_OPT_ADDR_PORT="$WSREP_SST_OPT_PORT"
|
||||
# Let's remove the leading part that contains the host address:
|
||||
remain="${WSREP_SST_OPT_ADDR#$WSREP_SST_OPT_HOST_ESCAPED}"
|
||||
# Let's remove the ":" character that separates the port number
|
||||
# from the hostname:
|
||||
remain="${remain#:}"
|
||||
# Let's remove all characters upto first "/" character that
|
||||
# separates the hostname with port number from the path:
|
||||
remain="${remain#/}"
|
||||
# Let's construct a new value for the address with the port:
|
||||
WSREP_SST_OPT_ADDR="$WSREP_SST_OPT_HOST:$WSREP_SST_OPT_PORT"
|
||||
if [ -n "$remain" ]; then
|
||||
WSREP_SST_OPT_ADDR="$WSREP_SST_OPT_ADDR/$remain"
|
||||
fi
|
||||
fi
|
||||
|
||||
readonly WSREP_SST_OPT_ADDR
|
||||
readonly WSREP_SST_OPT_ADDR_PORT
|
||||
|
||||
# try to use my_print_defaults, mysql and mysqldump that come with the sources
|
||||
# (for MTR suite)
|
||||
@@ -279,13 +542,13 @@ CLIENT_DIR="$SCRIPTS_DIR/../client"
|
||||
if [ -x "$CLIENT_DIR/mysql" ]; then
|
||||
MYSQL_CLIENT="$CLIENT_DIR/mysql"
|
||||
else
|
||||
MYSQL_CLIENT=mysql
|
||||
MYSQL_CLIENT="$(command -v mysql)"
|
||||
fi
|
||||
|
||||
if [ -x "$CLIENT_DIR/mysqldump" ]; then
|
||||
MYSQLDUMP="$CLIENT_DIR/mysqldump"
|
||||
else
|
||||
MYSQLDUMP=mysqldump
|
||||
MYSQLDUMP="$(command -v mysqldump)"
|
||||
fi
|
||||
|
||||
if [ -x "$SCRIPTS_DIR/my_print_defaults" ]; then
|
||||
@@ -293,43 +556,147 @@ if [ -x "$SCRIPTS_DIR/my_print_defaults" ]; then
|
||||
elif [ -x "$EXTRA_DIR/my_print_defaults" ]; then
|
||||
MY_PRINT_DEFAULTS="$EXTRA_DIR/my_print_defaults"
|
||||
else
|
||||
MY_PRINT_DEFAULTS=my_print_defaults
|
||||
MY_PRINT_DEFAULTS="$(command -v my_print_defaults)"
|
||||
fi
|
||||
|
||||
wsrep_defaults="$WSREP_SST_OPT_DEFAULT"
|
||||
if [ -n "$wsrep_defaults" ]; then
|
||||
wsrep_defaults="$wsrep_defaults "
|
||||
wsrep_defaults="$wsrep_defaults "
|
||||
fi
|
||||
wsrep_defaults="$wsrep_defaults$WSREP_SST_OPT_EXTRA_DEFAULT"
|
||||
if [ -n "$wsrep_defaults" ]; then
|
||||
wsrep_defaults="$wsrep_defaults "
|
||||
wsrep_defaults="$wsrep_defaults "
|
||||
fi
|
||||
readonly WSREP_SST_OPT_CONF="$wsrep_defaults$WSREP_SST_OPT_SUFFIX_DEFAULT"
|
||||
readonly MY_PRINT_DEFAULTS="$MY_PRINT_DEFAULTS $WSREP_SST_OPT_CONF"
|
||||
|
||||
wsrep_auth_not_set()
|
||||
#
|
||||
# User can specify mariabackup specific settings that will be used during sst
|
||||
# process like encryption, etc. Parse such configuration option.
|
||||
#
|
||||
# 1st parameter: group (config file section like sst) or
|
||||
# my_print_defaults argument (like --mysqld)
|
||||
# 2nd parameter: var : name of the variable in the section, e.g. server-id
|
||||
# 3rd parameter: default value for the parameter
|
||||
#
|
||||
parse_cnf()
|
||||
{
|
||||
[ -z "$WSREP_SST_OPT_AUTH" -o "$WSREP_SST_OPT_AUTH" = "(null)" ]
|
||||
local group="$1"
|
||||
local var="$2"
|
||||
local reval=""
|
||||
|
||||
# normalize the variable names specified in cnf file (user can use _ or - for example log-bin or log_bin)
|
||||
# then search for needed variable
|
||||
# finally get the variable value (if variables has been specified multiple time use the last value only)
|
||||
|
||||
if [ "$group" = '--mysqld' -o \
|
||||
"$group" = 'mysqld' ]; then
|
||||
if [ -n "$WSREP_SST_OPT_SUFFIX_VALUE" ]; then
|
||||
reval=$($MY_PRINT_DEFAULTS "mysqld$WSREP_SST_OPT_SUFFIX_VALUE" | awk 'BEGIN {OFS=FS="="} {sub(/^--loose/,"-",$0); gsub(/_/,"-",$1); if ($1=="--'"$var"'") lastval=substr($0,length($1)+2)} END {print lastval}')
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$reval" ]; then
|
||||
reval=$($MY_PRINT_DEFAULTS "$group" | awk 'BEGIN {OFS=FS="="} {sub(/^--loose/,"-",$0); gsub(/_/,"-",$1); if ($1=="--'"$var"'") lastval=substr($0,length($1)+2)} END {print lastval}')
|
||||
fi
|
||||
|
||||
# use default if we haven't found a value
|
||||
if [ -z "$reval" ]; then
|
||||
[ -n "${3:-}" ] && reval="$3"
|
||||
fi
|
||||
echo $reval
|
||||
}
|
||||
|
||||
# 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 wsrep_auth_not_set; then
|
||||
WSREP_SST_OPT_AUTH=$($MY_PRINT_DEFAULTS sst | grep -- "--wsrep_sst_auth" | cut -d= -f2)
|
||||
#
|
||||
# This function simply checks for the presence of the parameter
|
||||
# in the config file, but does not return its value. It returns "1"
|
||||
# (true) even if the parameter is present in the configuration file
|
||||
# without a value:
|
||||
#
|
||||
in_config()
|
||||
{
|
||||
local group="$1"
|
||||
local var="$2"
|
||||
local found=0
|
||||
if [ "$group" = '--mysqld' -o \
|
||||
"$group" = 'mysqld' ]; then
|
||||
if [ -n "$WSREP_SST_OPT_SUFFIX_VALUE" ]; then
|
||||
found=$($MY_PRINT_DEFAULTS "mysqld$WSREP_SST_OPT_SUFFIX_VALUE" | awk 'BEGIN {OFS=FS="="; found=0} {sub(/^--loose/,"-",$0); gsub(/_/,"-",$1); if ($1=="--'"$var"'") found=1} END {print found}')
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
readonly WSREP_SST_OPT_AUTH
|
||||
if [ $found -eq 0 ]; then
|
||||
found=$($MY_PRINT_DEFAULTS "$group" | awk 'BEGIN {OFS=FS="="; found=0} {sub(/^--loose/,"-",$0); gsub(/_/,"-",$1); if ($1=="--'"$var"'") found=1} END {print found}')
|
||||
fi
|
||||
echo $found
|
||||
}
|
||||
|
||||
# Splitting AUTH into potential user:password pair
|
||||
wsrep_auth_not_set()
|
||||
{
|
||||
[ -z "$WSREP_SST_OPT_AUTH" ]
|
||||
}
|
||||
|
||||
# Get rid of incorrect values resulting from substitution
|
||||
# in programs external to the script:
|
||||
if [ "$WSREP_SST_OPT_USER" = '(null)' ]; then
|
||||
WSREP_SST_OPT_USER=""
|
||||
fi
|
||||
if [ "$WSREP_SST_OPT_PSWD" = '(null)' ]; then
|
||||
WSREP_SST_OPT_PSWD=""
|
||||
fi
|
||||
if [ "$WSREP_SST_OPT_AUTH" = '(null)' ]; then
|
||||
WSREP_SST_OPT_AUTH=""
|
||||
fi
|
||||
|
||||
# Let's read the value of the authentication string from the
|
||||
# configuration file so that it does not go to the command line
|
||||
# and does not appear in the ps output:
|
||||
if wsrep_auth_not_set; then
|
||||
WSREP_SST_OPT_AUTH=$(parse_cnf 'sst' 'wsrep-sst-auth')
|
||||
fi
|
||||
|
||||
# Splitting WSREP_SST_OPT_AUTH as "user:password" pair:
|
||||
if ! wsrep_auth_not_set
|
||||
then
|
||||
WSREP_SST_OPT_USER="${WSREP_SST_OPT_AUTH%%:*}"
|
||||
WSREP_SST_OPT_PSWD="${WSREP_SST_OPT_AUTH##*:}"
|
||||
# Extract username as shortest prefix up to first ':' character:
|
||||
WSREP_SST_OPT_AUTH_USER="${WSREP_SST_OPT_AUTH%%:*}"
|
||||
if [ -z "$WSREP_SST_OPT_USER" ]; then
|
||||
# if the username is not in the command line arguments,
|
||||
# set the username and password using WSREP_SST_OPT_AUTH
|
||||
# from the environment:
|
||||
WSREP_SST_OPT_USER="$WSREP_SST_OPT_AUTH_USER"
|
||||
WSREP_SST_OPT_PSWD="${WSREP_SST_OPT_AUTH#*:}"
|
||||
elif [ "$WSREP_SST_OPT_USER" = "$WSREP_SST_OPT_AUTH_USER" ]; then
|
||||
# If the username in the command line arguments and in
|
||||
# the environment variable are the same, set the password
|
||||
# if it was not specified in the command line:
|
||||
if [ -z "$WSREP_SST_OPT_PSWD" ]; then
|
||||
WSREP_SST_OPT_PSWD="${WSREP_SST_OPT_AUTH#*:}"
|
||||
fi
|
||||
else
|
||||
# The username is passed through the command line and does
|
||||
# not match the username in the environment variable - ignore
|
||||
# the environment and rebuild the authentication parameters:
|
||||
WSREP_SST_OPT_AUTH="$WSREP_SST_OPT_USER:$WSREP_SST_OPT_PSWD"
|
||||
fi
|
||||
fi
|
||||
|
||||
readonly WSREP_SST_OPT_USER
|
||||
readonly WSREP_SST_OPT_PSWD
|
||||
readonly WSREP_SST_OPT_AUTH
|
||||
|
||||
if [ -n "${WSREP_SST_OPT_DATA:-}" ]
|
||||
if [ -n "$WSREP_SST_OPT_REMOTE_AUTH" ]
|
||||
then
|
||||
# Split auth string at the last ':'
|
||||
readonly WSREP_SST_OPT_REMOTE_USER="${WSREP_SST_OPT_REMOTE_AUTH%%:*}"
|
||||
readonly WSREP_SST_OPT_REMOTE_PSWD="${WSREP_SST_OPT_REMOTE_AUTH#*:}"
|
||||
else
|
||||
readonly WSREP_SST_OPT_REMOTE_USER=
|
||||
readonly WSREP_SST_OPT_REMOTE_PSWD=
|
||||
fi
|
||||
|
||||
readonly WSREP_SST_OPT_REMOTE_AUTH
|
||||
|
||||
if [ -n "$WSREP_SST_OPT_DATA" ]
|
||||
then
|
||||
SST_PROGRESS_FILE="$WSREP_SST_OPT_DATA/sst_in_progress"
|
||||
else
|
||||
@@ -361,17 +728,16 @@ wsrep_log_info()
|
||||
|
||||
wsrep_cleanup_progress_file()
|
||||
{
|
||||
[ -n "${SST_PROGRESS_FILE:-}" ] && rm -f "$SST_PROGRESS_FILE" 2>/dev/null || true
|
||||
[ -n "$SST_PROGRESS_FILE" ] && rm -f "$SST_PROGRESS_FILE" 2>/dev/null || true
|
||||
}
|
||||
|
||||
wsrep_check_program()
|
||||
{
|
||||
local prog=$1
|
||||
|
||||
if ! command -v $prog >/dev/null
|
||||
then
|
||||
local prog="$1"
|
||||
local cmd=$(command -v "$prog")
|
||||
if [ ! -x "$cmd" ]; then
|
||||
echo "'$prog' not found in PATH"
|
||||
exit 2 # ENOENT no such file or directory
|
||||
return 2 # no such file or directory
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -381,34 +747,49 @@ wsrep_check_programs()
|
||||
|
||||
while [ $# -gt 0 ]
|
||||
do
|
||||
wsrep_check_program $1
|
||||
wsrep_check_program $1 || ret=$?
|
||||
shift
|
||||
done
|
||||
|
||||
return $ret
|
||||
}
|
||||
|
||||
#
|
||||
# user can specify mariabackup specific settings that will be used during sst
|
||||
# process like encryption, etc.....
|
||||
# parse such configuration option. (group for xb settings is [sst] in my.cnf
|
||||
#
|
||||
# 1st param: group (config file section like sst) or my_print_defaults argument (like --mysqld)
|
||||
# 2nd param: var : name of the variable in the section, e.g. server-id
|
||||
# 3rd param: - : default value for the param
|
||||
parse_cnf()
|
||||
wsrep_check_datadir()
|
||||
{
|
||||
local group=$1
|
||||
local var=$2
|
||||
local reval=""
|
||||
|
||||
# normalize the variable names specified in cnf file (user can use _ or - for example log-bin or log_bin)
|
||||
# then search for needed variable
|
||||
# finally get the variable value (if variables has been specified multiple time use the last value only)
|
||||
|
||||
reval=$($MY_PRINT_DEFAULTS "${group}" | awk -v var="${var}" 'BEGIN { OFS=FS="=" } { gsub(/_/,"-",$1); if ( $1=="--"var) lastval=substr($0,length($1)+2) } END { print lastval}')
|
||||
|
||||
# use default if we haven't found a value
|
||||
if [ -z "$reval" ]; then
|
||||
[ -n "$3" ] && reval=$3
|
||||
if [ -z "$WSREP_SST_OPT_DATA" ]
|
||||
then
|
||||
wsrep_log_error "The '--datadir' parameter must be passed to the SST script"
|
||||
exit 2
|
||||
fi
|
||||
}
|
||||
|
||||
get_openssl()
|
||||
{
|
||||
# If the OPENSSL_BINARY variable is already defined, just return:
|
||||
if [ -n "${OPENSSL_BINARY+x}" ]; then
|
||||
return
|
||||
fi
|
||||
# Let's look for openssl:
|
||||
OPENSSL_BINARY="$(command -v openssl)"
|
||||
if [ ! -x "$OPENSSL_BINARY" ]; then
|
||||
OPENSSL_BINARY='/usr/bin/openssl'
|
||||
if [ ! -x "$OPENSSL_BINARY" ]; then
|
||||
OPENSSL_BINARY=""
|
||||
fi
|
||||
fi
|
||||
readonly OPENSSL_BINARY
|
||||
}
|
||||
|
||||
# Generate a string equivalent to 16 random bytes
|
||||
wsrep_gen_secret()
|
||||
{
|
||||
get_openssl
|
||||
if [ -n "$OPENSSL_BINARY" ]
|
||||
then
|
||||
echo $("$OPENSSL_BINARY" rand -hex 16)
|
||||
else
|
||||
printf "%04x%04x%04x%04x%04x%04x%04x%04x" \
|
||||
$RANDOM $RANDOM $RANDOM $RANDOM \
|
||||
$RANDOM $RANDOM $RANDOM $RANDOM
|
||||
fi
|
||||
echo $reval
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,6 @@
|
||||
#!/bin/bash -ue
|
||||
# Copyright (C) 2009-2015 Codership Oy
|
||||
# Copyright (C) 2017-2021 MariaDB
|
||||
#
|
||||
# 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
|
||||
@@ -101,12 +102,12 @@ SET_START_POSITION="SET GLOBAL wsrep_start_position='$WSREP_SST_OPT_GTID';"
|
||||
SET_WSREP_GTID_DOMAIN_ID=""
|
||||
if [ -n $WSREP_SST_OPT_GTID_DOMAIN_ID ]
|
||||
then
|
||||
SET_WSREP_GTID_DOMAIN_ID="
|
||||
SET @val = (SELECT GLOBAL_VALUE FROM INFORMATION_SCHEMA.SYSTEM_VARIABLES WHERE VARIABLE_NAME = 'WSREP_GTID_STRICT_MODE' AND GLOBAL_VALUE > 0);
|
||||
SET @stmt = IF (@val IS NOT NULL, 'SET GLOBAL WSREP_GTID_DOMAIN_ID=$WSREP_SST_OPT_GTID_DOMAIN_ID', 'SET @dummy = 0');
|
||||
PREPARE stmt FROM @stmt;
|
||||
EXECUTE stmt;
|
||||
DROP PREPARE stmt;"
|
||||
SET_WSREP_GTID_DOMAIN_ID="
|
||||
SET @val = (SELECT GLOBAL_VALUE FROM INFORMATION_SCHEMA.SYSTEM_VARIABLES WHERE VARIABLE_NAME = 'WSREP_GTID_STRICT_MODE' AND GLOBAL_VALUE > 0);
|
||||
SET @stmt = IF (@val IS NOT NULL, 'SET GLOBAL WSREP_GTID_DOMAIN_ID=$WSREP_SST_OPT_GTID_DOMAIN_ID', 'SET @dummy = 0');
|
||||
PREPARE stmt FROM @stmt;
|
||||
EXECUTE stmt;
|
||||
DROP PREPARE stmt;"
|
||||
fi
|
||||
|
||||
MYSQL="$MYSQL_CLIENT $WSREP_SST_OPT_CONF "\
|
||||
@@ -133,16 +134,16 @@ SQL_LOG_BIN_OFF=""
|
||||
# Safety check
|
||||
if [ "${SERVER_VERSION%%.*}" != '5' ]
|
||||
then
|
||||
# If binary logging is enabled on the joiner node, we need to copy donor's
|
||||
# gtid_binlog_state to joiner. In order to do that, a RESET MASTER must be
|
||||
# executed to erase binary logs (if any). Binary logging should also be
|
||||
# turned off for the session so that gtid state does not get altered while
|
||||
# the dump gets replayed on joiner.
|
||||
if [[ "$LOG_BIN" == 'ON' ]]; then
|
||||
RESET_MASTER="SET GLOBAL wsrep_on=OFF; RESET MASTER; SET GLOBAL wsrep_on=ON;"
|
||||
SET_GTID_BINLOG_STATE="SET GLOBAL wsrep_on=OFF; SET @@global.gtid_binlog_state='$GTID_BINLOG_STATE'; SET GLOBAL wsrep_on=ON;"
|
||||
SQL_LOG_BIN_OFF="SET @@session.sql_log_bin=OFF;"
|
||||
fi
|
||||
# If binary logging is enabled on the joiner node, we need to copy donor's
|
||||
# gtid_binlog_state to joiner. In order to do that, a RESET MASTER must be
|
||||
# executed to erase binary logs (if any). Binary logging should also be
|
||||
# turned off for the session so that gtid state does not get altered while
|
||||
# the dump gets replayed on joiner.
|
||||
if [[ "$LOG_BIN" == 'ON' ]]; then
|
||||
RESET_MASTER="SET GLOBAL wsrep_on=OFF; RESET MASTER; SET GLOBAL wsrep_on=ON;"
|
||||
SET_GTID_BINLOG_STATE="SET GLOBAL wsrep_on=OFF; SET @@global.gtid_binlog_state='$GTID_BINLOG_STATE'; SET GLOBAL wsrep_on=ON;"
|
||||
SQL_LOG_BIN_OFF="SET @@session.sql_log_bin=OFF;"
|
||||
fi
|
||||
fi
|
||||
|
||||
# NOTE: we don't use --routines here because we're dumping mysql.proc table
|
||||
|
@@ -1,6 +1,7 @@
|
||||
#!/bin/bash -ue
|
||||
|
||||
# Copyright (C) 2010-2014 Codership Oy
|
||||
# Copyright (C) 2017-2021 MariaDB
|
||||
#
|
||||
# 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
|
||||
@@ -23,12 +24,13 @@ RSYNC_CONF= # rsync configuration file
|
||||
RSYNC_REAL_PID= # rsync process id
|
||||
|
||||
OS=$(uname)
|
||||
[ "$OS" = "Darwin" ] && export -n LD_LIBRARY_PATH
|
||||
[ "$OS" = 'Darwin' ] && export -n LD_LIBRARY_PATH
|
||||
|
||||
# Setting the path for lsof on CentOS
|
||||
export PATH="/usr/sbin:/sbin:$PATH"
|
||||
|
||||
. $(dirname $0)/wsrep_sst_common
|
||||
wsrep_check_datadir
|
||||
|
||||
wsrep_check_programs rsync
|
||||
|
||||
@@ -54,13 +56,13 @@ cleanup_joiner()
|
||||
# Check whether rsync process is still running.
|
||||
check_pid()
|
||||
{
|
||||
local pid_file=$1
|
||||
[ -r "$pid_file" ] && ps -p $(cat $pid_file) >/dev/null 2>&1
|
||||
local pid_file="$1"
|
||||
[ -r "$pid_file" ] && ps -p $(cat "$pid_file") >/dev/null 2>&1
|
||||
}
|
||||
|
||||
check_pid_and_port()
|
||||
{
|
||||
local pid_file=$1
|
||||
local pid_file="$1"
|
||||
local rsync_pid=$2
|
||||
local rsync_addr=$3
|
||||
local rsync_port=$4
|
||||
@@ -73,11 +75,10 @@ check_pid_and_port()
|
||||
grep -E '[[:space:]]+(rsync|stunnel)[[:space:]]+'"$rsync_pid" 2>/dev/null)"
|
||||
;;
|
||||
*)
|
||||
if ! command -v lsof > /dev/null; then
|
||||
wsrep_log_error "lsof tool not found in PATH! Make sure you have it installed."
|
||||
exit 2 # ENOENT
|
||||
if [ ! -x "$(command -v lsof)" ]; then
|
||||
wsrep_log_error "lsof tool not found in PATH! Make sure you have it installed."
|
||||
exit 2 # ENOENT
|
||||
fi
|
||||
|
||||
local port_info="$(lsof -i :$rsync_port -Pn 2>/dev/null | \
|
||||
grep "(LISTEN)")"
|
||||
local is_rsync="$(echo $port_info | \
|
||||
@@ -96,27 +97,25 @@ check_pid_and_port()
|
||||
exit 16 # EBUSY
|
||||
fi
|
||||
fi
|
||||
check_pid $pid_file && \
|
||||
check_pid "$pid_file" && \
|
||||
[ -n "$port_info" ] && [ -n "$is_rsync" ] && \
|
||||
[ $(cat $pid_file) -eq $rsync_pid ]
|
||||
[ $(cat "$pid_file") -eq $rsync_pid ]
|
||||
}
|
||||
|
||||
is_local_ip()
|
||||
{
|
||||
local address="$1"
|
||||
local get_addr_bin
|
||||
if ! command -v ifconfig > /dev/null
|
||||
local get_addr_bin="$(command -v ifconfig)"
|
||||
if [ -z "$get_addr_bin" ]
|
||||
then
|
||||
get_addr_bin=ip
|
||||
get_addr_bin="$get_addr_bin address show"
|
||||
# Add an slash at the end, so we don't get false positive : 172.18.0.4 matches 172.18.0.41
|
||||
# ip output format is "X.X.X.X/mask"
|
||||
address="${address}/"
|
||||
get_addr_bin="$(command -v ip) address show"
|
||||
# Add an slash at the end, so we don't get false positive : 172.18.0.4 matches 172.18.0.41
|
||||
# ip output format is "X.X.X.X/mask"
|
||||
address="$address/"
|
||||
else
|
||||
# Add an space at the end, so we don't get false positive : 172.18.0.4 matches 172.18.0.41
|
||||
# ifconfig output format is "X.X.X.X "
|
||||
get_addr_bin=ifconfig
|
||||
address="$address "
|
||||
# Add an space at the end, so we don't get false positive : 172.18.0.4 matches 172.18.0.41
|
||||
# ifconfig output format is "X.X.X.X "
|
||||
address="$address "
|
||||
fi
|
||||
|
||||
$get_addr_bin | grep -F "$address" > /dev/null
|
||||
@@ -135,65 +134,64 @@ BINLOG_TAR_FILE="$WSREP_SST_OPT_DATA/wsrep_sst_binlog.tar"
|
||||
BINLOG_N_FILES=1
|
||||
rm -f "$BINLOG_TAR_FILE" || :
|
||||
|
||||
if ! [ -z $WSREP_SST_OPT_BINLOG ]
|
||||
then
|
||||
BINLOG_DIRNAME=$(dirname $WSREP_SST_OPT_BINLOG)
|
||||
BINLOG_FILENAME=$(basename $WSREP_SST_OPT_BINLOG)
|
||||
BINLOG_INDEX_DIRNAME=$(dirname $WSREP_SST_OPT_BINLOG)
|
||||
BINLOG_INDEX_FILENAME=$(basename $WSREP_SST_OPT_BINLOG)
|
||||
get_binlog
|
||||
|
||||
if [ -n "$WSREP_SST_OPT_BINLOG" ]; then
|
||||
BINLOG_DIRNAME=$(dirname "$WSREP_SST_OPT_BINLOG")
|
||||
BINLOG_FILENAME=$(basename "$WSREP_SST_OPT_BINLOG")
|
||||
fi
|
||||
|
||||
if ! [ -z $WSREP_SST_OPT_BINLOG_INDEX ]
|
||||
then
|
||||
BINLOG_INDEX_DIRNAME=$(dirname $WSREP_SST_OPT_BINLOG_INDEX)
|
||||
BINLOG_INDEX_FILENAME=$(basename $WSREP_SST_OPT_BINLOG_INDEX)
|
||||
BINLOG_INDEX_FILENAME=${BINLOG_INDEX_FILENAME%.index}.index
|
||||
fi
|
||||
|
||||
WSREP_LOG_DIR=${WSREP_LOG_DIR:-""}
|
||||
# Try to set WSREP_LOG_DIR from the command line:
|
||||
if [ ! -z "$INNODB_LOG_GROUP_HOME_ARG" ]; then
|
||||
WSREP_LOG_DIR=$INNODB_LOG_GROUP_HOME_ARG
|
||||
fi
|
||||
# if no command line arg and WSREP_LOG_DIR is not set,
|
||||
# if no command line argument and INNODB_LOG_GROUP_HOME is not set,
|
||||
# try to get it from my.cnf:
|
||||
if [ -z "$WSREP_LOG_DIR" ]; then
|
||||
WSREP_LOG_DIR=$(parse_cnf mysqld$WSREP_SST_OPT_SUFFIX_VALUE innodb-log-group-home-dir '')
|
||||
fi
|
||||
if [ -z "$WSREP_LOG_DIR" ]; then
|
||||
WSREP_LOG_DIR=$(parse_cnf --mysqld innodb-log-group-home-dir '')
|
||||
if [ -z "$INNODB_LOG_GROUP_HOME" ]; then
|
||||
INNODB_LOG_GROUP_HOME=$(parse_cnf '--mysqld' 'innodb-log-group-home-dir')
|
||||
fi
|
||||
|
||||
OLD_PWD="$(pwd)"
|
||||
|
||||
WSREP_LOG_DIR="$INNODB_LOG_GROUP_HOME"
|
||||
|
||||
if [ -n "$WSREP_LOG_DIR" ]; then
|
||||
# handle both relative and absolute paths
|
||||
WSREP_LOG_DIR=$(cd $WSREP_SST_OPT_DATA; mkdir -p "$WSREP_LOG_DIR"; cd $WSREP_LOG_DIR; pwd -P)
|
||||
WSREP_LOG_DIR=$(cd "$WSREP_SST_OPT_DATA"; mkdir -p "$WSREP_LOG_DIR"; cd "$WSREP_LOG_DIR"; pwd -P)
|
||||
else
|
||||
# default to datadir
|
||||
WSREP_LOG_DIR=$(cd $WSREP_SST_OPT_DATA; pwd -P)
|
||||
WSREP_LOG_DIR=$(cd "$WSREP_SST_OPT_DATA"; pwd -P)
|
||||
fi
|
||||
|
||||
INNODB_DATA_HOME_DIR=${INNODB_DATA_HOME_DIR:-""}
|
||||
# Try to set INNODB_DATA_HOME_DIR from the command line:
|
||||
if [ ! -z "$INNODB_DATA_HOME_DIR_ARG" ]; then
|
||||
INNODB_DATA_HOME_DIR=$INNODB_DATA_HOME_DIR_ARG
|
||||
fi
|
||||
# if no command line arg and INNODB_DATA_HOME_DIR environment variable
|
||||
cd "$OLD_PWD"
|
||||
|
||||
# if no command line argument and INNODB_DATA_HOME_DIR environment variable
|
||||
# is not set, try to get it from my.cnf:
|
||||
if [ -z "$INNODB_DATA_HOME_DIR" ]; then
|
||||
INNODB_DATA_HOME_DIR=$(parse_cnf mysqld$WSREP_SST_OPT_SUFFIX_VALUE innodb-data-home-dir '')
|
||||
fi
|
||||
if [ -z "$INNODB_DATA_HOME_DIR" ]; then
|
||||
INNODB_DATA_HOME_DIR=$(parse_cnf --mysqld innodb-data-home-dir '')
|
||||
INNODB_DATA_HOME_DIR=$(parse_cnf '--mysqld' 'innodb-data-home-dir')
|
||||
fi
|
||||
|
||||
if [ -n "$INNODB_DATA_HOME_DIR" ]; then
|
||||
# handle both relative and absolute paths
|
||||
INNODB_DATA_HOME_DIR=$(cd $WSREP_SST_OPT_DATA; mkdir -p "$INNODB_DATA_HOME_DIR"; cd $INNODB_DATA_HOME_DIR; pwd -P)
|
||||
INNODB_DATA_HOME_DIR=$(cd "$WSREP_SST_OPT_DATA"; mkdir -p "$INNODB_DATA_HOME_DIR"; cd "$INNODB_DATA_HOME_DIR"; pwd -P)
|
||||
else
|
||||
# default to datadir
|
||||
INNODB_DATA_HOME_DIR=$(cd $WSREP_SST_OPT_DATA; pwd -P)
|
||||
INNODB_DATA_HOME_DIR=$(cd "$WSREP_SST_OPT_DATA"; pwd -P)
|
||||
fi
|
||||
|
||||
cd "$OLD_PWD"
|
||||
|
||||
# if no command line argument then try to get it from my.cnf:
|
||||
if [ -z "$INNODB_UNDO_DIR" ]; then
|
||||
INNODB_UNDO_DIR=$(parse_cnf '--mysqld' 'innodb-undo-directory')
|
||||
fi
|
||||
|
||||
if [ -n "$INNODB_UNDO_DIR" ]; then
|
||||
# handle both relative and absolute paths
|
||||
INNODB_UNDO_DIR=$(cd "$WSREP_SST_OPT_DATA"; mkdir -p "$INNODB_UNDO_DIR"; cd "$INNODB_UNDO_DIR"; pwd -P)
|
||||
else
|
||||
# default to datadir
|
||||
INNODB_UNDO_DIR=$(cd "$WSREP_SST_OPT_DATA"; pwd -P)
|
||||
fi
|
||||
|
||||
cd "$OLD_PWD"
|
||||
|
||||
# Old filter - include everything except selected
|
||||
# FILTER=(--exclude '*.err' --exclude '*.pid' --exclude '*.sock' \
|
||||
# --exclude '*.conf' --exclude core --exclude 'galera.*' \
|
||||
@@ -208,30 +206,99 @@ FILTER="-f '- /lost+found'
|
||||
-f '+ /wsrep_sst_binlog.tar'
|
||||
-f '- $INNODB_DATA_HOME_DIR/ib_lru_dump'
|
||||
-f '- $INNODB_DATA_HOME_DIR/ibdata*'
|
||||
-f '+ /undo*'
|
||||
-f '+ $INNODB_UNDO_DIR/undo*'
|
||||
-f '+ /*/'
|
||||
-f '- /*'"
|
||||
|
||||
SSTKEY=$(parse_cnf sst tkey "")
|
||||
SSTCERT=$(parse_cnf sst tcert "")
|
||||
STUNNEL=""
|
||||
if [ -f "$SSTKEY" ] && [ -f "$SSTCERT" ] && wsrep_check_programs stunnel
|
||||
# old-style SSL config
|
||||
SSTKEY=$(parse_cnf 'sst' 'tkey')
|
||||
SSTCERT=$(parse_cnf 'sst' 'tcert')
|
||||
SSTCA=$(parse_cnf 'sst' 'tca')
|
||||
|
||||
check_server_ssl_config()
|
||||
{
|
||||
local section="$1"
|
||||
SSTKEY=$(parse_cnf "$section" 'ssl-key')
|
||||
SSTCERT=$(parse_cnf "$section" 'ssl-cert')
|
||||
SSTCA=$(parse_cnf "$section" 'ssl-ca')
|
||||
}
|
||||
|
||||
SSLMODE=$(parse_cnf 'sst' 'ssl-mode' | tr [:lower:] [:upper:])
|
||||
|
||||
if [ -z "$SSTKEY" -a -z "$SSTCERT" ]
|
||||
then
|
||||
STUNNEL="stunnel ${STUNNEL_CONF}"
|
||||
# no old-style SSL config in [sst], check for new one
|
||||
check_server_ssl_config 'sst'
|
||||
if [ -z "$SSTKEY" -a -z "$SSTCERT" ]; then
|
||||
check_server_ssl_config '--mysqld'
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$WSREP_SST_OPT_ROLE" = "donor" ]
|
||||
if [ -z "$SSLMODE" ]; then
|
||||
# Implicit verification if CA is set and the SSL mode
|
||||
# is not specified by user:
|
||||
if [ -n "$SSTCA" ]; then
|
||||
if [ -x "$(command -v stunnel)" ]; then
|
||||
SSLMODE='VERIFY_CA'
|
||||
fi
|
||||
# Require SSL by default if SSL key and cert are present:
|
||||
elif [ -n "$SSTKEY" -a -n "$SSTCERT" ]; then
|
||||
SSLMODE='REQUIRED'
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$SSTCA" ]
|
||||
then
|
||||
CAFILE_OPT="CAfile = $SSTCA"
|
||||
else
|
||||
CAFILE_OPT=""
|
||||
fi
|
||||
|
||||
if [ "${SSLMODE#VERIFY}" != "$SSLMODE" ]
|
||||
then
|
||||
case "$SSLMODE" in
|
||||
'VERIFY_IDENTITY')
|
||||
VERIFY_OPT='verifyPeer = yes'
|
||||
;;
|
||||
'VERIFY_CA')
|
||||
VERIFY_OPT='verifyChain = yes'
|
||||
;;
|
||||
*)
|
||||
wsrep_log_error "Unrecognized ssl-mode option: '$SSLMODE'"
|
||||
exit 22 # EINVAL
|
||||
esac
|
||||
if [ -z "$CAFILE_OPT" ]
|
||||
then
|
||||
wsrep_log_error "Can't have ssl-mode=$SSLMODE without CA file"
|
||||
exit 22 # EINVAL
|
||||
fi
|
||||
else
|
||||
VERIFY_OPT=""
|
||||
fi
|
||||
|
||||
STUNNEL=""
|
||||
if [ -n "$SSLMODE" -a "$SSLMODE" != 'DISABLED' ] && wsrep_check_programs stunnel
|
||||
then
|
||||
wsrep_log_info "Using stunnel for SSL encryption: CAfile: $SSTCA, SSLMODE: $SSLMODE"
|
||||
STUNNEL="stunnel $STUNNEL_CONF"
|
||||
fi
|
||||
|
||||
readonly SECRET_TAG="secret"
|
||||
|
||||
if [ "$WSREP_SST_OPT_ROLE" = 'donor' ]
|
||||
then
|
||||
|
||||
cat << EOF > "$STUNNEL_CONF"
|
||||
CApath = ${SSTCERT%/*}
|
||||
key = $SSTKEY
|
||||
cert = $SSTCERT
|
||||
${CAFILE_OPT}
|
||||
foreground = yes
|
||||
pid = $STUNNEL_PID
|
||||
debug = warning
|
||||
client = yes
|
||||
connect = ${WSREP_SST_OPT_ADDR%/*}
|
||||
TIMEOUTclose = 0
|
||||
verifyPeer = yes
|
||||
${VERIFY_OPT}
|
||||
EOF
|
||||
|
||||
if [ $WSREP_SST_OPT_BYPASS -eq 0 ]
|
||||
@@ -244,7 +311,7 @@ EOF
|
||||
rm -rf "$ERROR"
|
||||
|
||||
# Use deltaxfer only for WAN
|
||||
inv=$(basename $0)
|
||||
inv=$(basename "$0")
|
||||
[ "$inv" = "wsrep_sst_rsync_wan" ] && WHOLE_FILE_OPT="" \
|
||||
|| WHOLE_FILE_OPT="--whole-file"
|
||||
|
||||
@@ -268,49 +335,43 @@ EOF
|
||||
sleep 0.2
|
||||
done
|
||||
|
||||
STATE="$(cat $FLUSHED)"
|
||||
STATE=$(cat "$FLUSHED")
|
||||
rm -rf "$FLUSHED"
|
||||
|
||||
sync
|
||||
|
||||
if ! [ -z $WSREP_SST_OPT_BINLOG ]
|
||||
if [ -n "$WSREP_SST_OPT_BINLOG" ]
|
||||
then
|
||||
# Prepare binlog files
|
||||
OLD_PWD="$(pwd)"
|
||||
cd $BINLOG_DIRNAME
|
||||
cd "$BINLOG_DIRNAME"
|
||||
|
||||
if [ -z $WSREP_SST_OPT_BINLOG_INDEX ]
|
||||
then
|
||||
binlog_files_full=$(tail -n $BINLOG_N_FILES ${BINLOG_FILENAME}.index)
|
||||
else
|
||||
cd $BINLOG_INDEX_DIRNAME
|
||||
binlog_files_full=$(tail -n $BINLOG_N_FILES ${BINLOG_INDEX_FILENAME})
|
||||
fi
|
||||
binlog_files_full=$(tail -n $BINLOG_N_FILES "${WSREP_SST_OPT_BINLOG_INDEX%.index}.index")
|
||||
|
||||
cd $BINLOG_DIRNAME
|
||||
binlog_files=""
|
||||
for ii in $binlog_files_full
|
||||
do
|
||||
binlog_files="$binlog_files $(basename $ii)"
|
||||
binlog_file=$(basename "$ii")
|
||||
binlog_files="$binlog_files $binlog_file"
|
||||
done
|
||||
|
||||
if ! [ -z "$binlog_files" ]
|
||||
if [ -n "$binlog_files" ]
|
||||
then
|
||||
wsrep_log_info "Preparing binlog files for transfer:"
|
||||
tar -cvf $BINLOG_TAR_FILE $binlog_files >&2
|
||||
tar -cvf "$BINLOG_TAR_FILE" $binlog_files >&2
|
||||
fi
|
||||
|
||||
cd "$OLD_PWD"
|
||||
fi
|
||||
|
||||
# first, the normal directories, so that we can detect incompatible protocol
|
||||
RC=0
|
||||
eval rsync ${STUNNEL:+--rsh="$STUNNEL"} \
|
||||
eval rsync ${STUNNEL:+--rsh=\"$STUNNEL\"} \
|
||||
--owner --group --perms --links --specials \
|
||||
--ignore-times --inplace --dirs --delete --quiet \
|
||||
$WHOLE_FILE_OPT ${FILTER} "$WSREP_SST_OPT_DATA/" \
|
||||
rsync://$WSREP_SST_OPT_ADDR >&2 || RC=$?
|
||||
|
||||
if [ "$RC" -ne 0 ]; then
|
||||
if [ $RC -ne 0 ]; then
|
||||
wsrep_log_error "rsync returned code $RC:"
|
||||
|
||||
case $RC in
|
||||
@@ -340,7 +401,7 @@ EOF
|
||||
exit 255 # unknown error
|
||||
fi
|
||||
|
||||
# second, we transfer InnoDB and Aria log files
|
||||
# second, we transfer InnoDB log files
|
||||
rsync ${STUNNEL:+--rsh="$STUNNEL"} \
|
||||
--owner --group --perms --links --specials \
|
||||
--ignore-times --inplace --dirs --delete --quiet \
|
||||
@@ -353,8 +414,7 @@ EOF
|
||||
fi
|
||||
|
||||
# then, we parallelize the transfer of database directories, use . so that pathconcatenation works
|
||||
OLD_PWD="$(pwd)"
|
||||
cd $WSREP_SST_OPT_DATA
|
||||
cd "$WSREP_SST_OPT_DATA"
|
||||
|
||||
count=1
|
||||
[ "$OS" = "Linux" ] && count=$(grep -c processor /proc/cpuinfo)
|
||||
@@ -376,60 +436,58 @@ EOF
|
||||
fi
|
||||
|
||||
else # BYPASS
|
||||
|
||||
wsrep_log_info "Bypassing state dump."
|
||||
|
||||
# Store donor's wsrep GTID (state ID) and wsrep_gtid_domain_id
|
||||
# (separated by a space).
|
||||
STATE="$WSREP_SST_OPT_GTID $WSREP_SST_OPT_GTID_DOMAIN_ID"
|
||||
|
||||
fi
|
||||
|
||||
echo "continue" # now server can resume updating data
|
||||
|
||||
echo "$STATE" > "$MAGIC_FILE"
|
||||
|
||||
if [ -n "$WSREP_SST_OPT_REMOTE_PSWD" ]; then
|
||||
# Let joiner know that we know its secret
|
||||
echo "$SECRET_TAG $WSREP_SST_OPT_REMOTE_PSWD" >> "$MAGIC_FILE"
|
||||
fi
|
||||
|
||||
rsync ${STUNNEL:+--rsh="$STUNNEL"} \
|
||||
--archive --quiet --checksum "$MAGIC_FILE" rsync://$WSREP_SST_OPT_ADDR
|
||||
|
||||
echo "done $STATE"
|
||||
|
||||
elif [ "$WSREP_SST_OPT_ROLE" = "joiner" ]
|
||||
elif [ "$WSREP_SST_OPT_ROLE" = 'joiner' ]
|
||||
then
|
||||
wsrep_check_programs lsof
|
||||
|
||||
touch $SST_PROGRESS_FILE
|
||||
MYSQLD_PID=$WSREP_SST_OPT_PARENT
|
||||
touch "$SST_PROGRESS_FILE"
|
||||
MYSQLD_PID="$WSREP_SST_OPT_PARENT"
|
||||
|
||||
MODULE="rsync_sst"
|
||||
|
||||
RSYNC_PID="$WSREP_SST_OPT_DATA/$MODULE.pid"
|
||||
# give some time for lingering rsync from previous SST to complete
|
||||
check_round=0
|
||||
while check_pid $RSYNC_PID && [ $check_round -lt 10 ]
|
||||
while check_pid "$RSYNC_PID" && [ $check_round -lt 10 ]
|
||||
do
|
||||
wsrep_log_info "lingering rsync daemon found at startup, waiting for it to exit"
|
||||
check_round=$(( check_round + 1 ))
|
||||
sleep 1
|
||||
done
|
||||
|
||||
if check_pid $RSYNC_PID
|
||||
if check_pid "$RSYNC_PID"
|
||||
then
|
||||
wsrep_log_error "rsync daemon already running."
|
||||
exit 114 # EALREADY
|
||||
fi
|
||||
rm -rf "$RSYNC_PID"
|
||||
|
||||
ADDR=$WSREP_SST_OPT_ADDR
|
||||
if [ "${ADDR#\[}" != "$ADDR" ]; then
|
||||
RSYNC_PORT=$(echo $ADDR | awk -F '\\]:' '{ print $2 }')
|
||||
RSYNC_ADDR=$(echo $ADDR | awk -F '\\]:' '{ print $1 }')"]"
|
||||
else
|
||||
RSYNC_PORT=$(echo $ADDR | awk -F ':' '{ print $2 }')
|
||||
RSYNC_ADDR=$(echo $ADDR | awk -F ':' '{ print $1 }')
|
||||
fi
|
||||
if [ -z "$RSYNC_PORT" ]
|
||||
then
|
||||
RSYNC_PORT=4444
|
||||
ADDR="$RSYNC_ADDR:$RSYNC_PORT"
|
||||
fi
|
||||
ADDR="$WSREP_SST_OPT_ADDR"
|
||||
RSYNC_PORT="$WSREP_SST_OPT_PORT"
|
||||
RSYNC_ADDR="$WSREP_SST_OPT_HOST"
|
||||
|
||||
trap "exit 32" HUP PIPE
|
||||
trap "exit 3" INT TERM ABRT
|
||||
@@ -437,7 +495,7 @@ then
|
||||
|
||||
RSYNC_CONF="$WSREP_SST_OPT_DATA/$MODULE.conf"
|
||||
|
||||
if [ -n "${MYSQL_TMP_DIR:-}" ] ; then
|
||||
if [ -n "${MYSQL_TMP_DIR:-}" ]; then
|
||||
SILENT="log file = $MYSQL_TMP_DIR/rsyncd.log"
|
||||
else
|
||||
SILENT=""
|
||||
@@ -460,40 +518,40 @@ EOF
|
||||
|
||||
# rm -rf "$DATA"/ib_logfile* # we don't want old logs around
|
||||
|
||||
readonly RSYNC_PORT=${WSREP_SST_OPT_PORT:-4444}
|
||||
# If the IP is local listen only in it
|
||||
if is_local_ip "$RSYNC_ADDR"
|
||||
then
|
||||
RSYNC_EXTRA_ARGS="--address $RSYNC_ADDR"
|
||||
STUNNEL_ACCEPT="$RSYNC_ADDR:$RSYNC_PORT"
|
||||
RSYNC_EXTRA_ARGS="--address $RSYNC_ADDR"
|
||||
STUNNEL_ACCEPT="$RSYNC_ADDR:$RSYNC_PORT"
|
||||
else
|
||||
# Not local, possibly a NAT, listen on all interfaces
|
||||
RSYNC_EXTRA_ARGS=""
|
||||
STUNNEL_ACCEPT="$RSYNC_PORT"
|
||||
# Overwrite address with all
|
||||
RSYNC_ADDR="*"
|
||||
# Not local, possibly a NAT, listen on all interfaces
|
||||
RSYNC_EXTRA_ARGS=""
|
||||
STUNNEL_ACCEPT="$RSYNC_PORT"
|
||||
# Overwrite address with all
|
||||
RSYNC_ADDR="*"
|
||||
fi
|
||||
|
||||
if [ -z "$STUNNEL" ]
|
||||
then
|
||||
rsync --daemon --no-detach --port "$RSYNC_PORT" --config "$RSYNC_CONF" ${RSYNC_EXTRA_ARGS} &
|
||||
RSYNC_REAL_PID=$!
|
||||
rsync --daemon --no-detach --port "$RSYNC_PORT" --config "$RSYNC_CONF" ${RSYNC_EXTRA_ARGS} &
|
||||
RSYNC_REAL_PID=$!
|
||||
else
|
||||
cat << EOF > "$STUNNEL_CONF"
|
||||
cat << EOF > "$STUNNEL_CONF"
|
||||
key = $SSTKEY
|
||||
cert = $SSTCERT
|
||||
${CAFILE_OPT}
|
||||
foreground = yes
|
||||
pid = $STUNNEL_PID
|
||||
debug = warning
|
||||
client = no
|
||||
[rsync]
|
||||
accept = $STUNNEL_ACCEPT
|
||||
exec = $(which rsync)
|
||||
execargs = rsync --server --daemon --config=$RSYNC_CONF .
|
||||
exec = $(command -v rsync)
|
||||
execargs = rsync --server --daemon --config='$RSYNC_CONF' .
|
||||
EOF
|
||||
stunnel "$STUNNEL_CONF" &
|
||||
RSYNC_REAL_PID=$!
|
||||
RSYNC_PID=$STUNNEL_PID
|
||||
stunnel "$STUNNEL_CONF" &
|
||||
RSYNC_REAL_PID=$!
|
||||
RSYNC_PID="$STUNNEL_PID"
|
||||
fi
|
||||
|
||||
until check_pid_and_port "$RSYNC_PID" "$RSYNC_REAL_PID" "$RSYNC_ADDR" "$RSYNC_PORT"
|
||||
@@ -501,7 +559,30 @@ EOF
|
||||
sleep 0.2
|
||||
done
|
||||
|
||||
echo "ready $WSREP_SST_OPT_HOST:$RSYNC_PORT/$MODULE"
|
||||
if [ "${SSLMODE#VERIFY}" != "$SSLMODE" ]
|
||||
then # backward-incompatible behavior
|
||||
CN=""
|
||||
if [ -n "$SSTCERT" ]
|
||||
then
|
||||
# find out my Common Name
|
||||
get_openssl
|
||||
if [ -z "$OPENSSL_BINARY" ]; then
|
||||
wsrep_log_error 'openssl not found but it is required for authentication'
|
||||
exit 42
|
||||
fi
|
||||
CN=$("$OPENSSL_BINARY" x509 -noout -subject -in "$SSTCERT" | \
|
||||
tr "," "\n" | grep "CN =" | cut -d= -f2 | sed s/^\ // | \
|
||||
sed s/\ %//)
|
||||
fi
|
||||
MY_SECRET=$(wsrep_gen_secret)
|
||||
# Add authentication data to address
|
||||
ADDR="$CN:$MY_SECRET@$WSREP_SST_OPT_HOST"
|
||||
else
|
||||
MY_SECRET="" # for check down in recv_joiner()
|
||||
ADDR=$WSREP_SST_OPT_HOST
|
||||
fi
|
||||
|
||||
echo "ready $ADDR:$RSYNC_PORT/$MODULE"
|
||||
|
||||
# wait for SST to complete by monitoring magic file
|
||||
while [ ! -r "$MAGIC_FILE" ] && check_pid "$RSYNC_PID" && \
|
||||
@@ -514,44 +595,53 @@ EOF
|
||||
then
|
||||
wsrep_log_error \
|
||||
"Parent mysqld process (PID:$MYSQLD_PID) terminated unexpectedly."
|
||||
kill -- -"${MYSQLD_PID}"
|
||||
kill -- -$MYSQLD_PID
|
||||
sleep 1
|
||||
exit 32
|
||||
fi
|
||||
|
||||
if ! [ -z $WSREP_SST_OPT_BINLOG ]
|
||||
then
|
||||
if [ -n "$WSREP_SST_OPT_BINLOG" ]; then
|
||||
if [ -f "$BINLOG_TAR_FILE" ]; then
|
||||
cd "$BINLOG_DIRNAME"
|
||||
|
||||
OLD_PWD="$(pwd)"
|
||||
cd $BINLOG_DIRNAME
|
||||
binlog_index="${WSREP_SST_OPT_BINLOG_INDEX%.index}.index"
|
||||
|
||||
if [ -f $BINLOG_TAR_FILE ]
|
||||
then
|
||||
# Clean up old binlog files first
|
||||
rm -f ${BINLOG_FILENAME}.*
|
||||
rm -f "$BINLOG_FILENAME".[0-9]*
|
||||
[ -f "$binlog_index" ] && rm "$binlog_index"
|
||||
|
||||
wsrep_log_info "Extracting binlog files:"
|
||||
tar -xvf $BINLOG_TAR_FILE >> _binlog_tmp_files_$!
|
||||
tar -xvf "$BINLOG_TAR_FILE" >> _binlog_tmp_files_$!
|
||||
while read bin_file; do
|
||||
if [ -z $WSREP_SST_OPT_BINLOG_INDEX ]
|
||||
then
|
||||
echo ${BINLOG_DIRNAME}/${bin_file} >> ${BINLOG_FILENAME}.index
|
||||
else
|
||||
echo ${BINLOG_DIRNAME}/${bin_file} >> ${BINLOG_INDEX_DIRNAME}/${BINLOG_INDEX_FILENAME}
|
||||
fi
|
||||
echo "$BINLOG_DIRNAME/$bin_file" >> "$binlog_index"
|
||||
done < _binlog_tmp_files_$!
|
||||
rm -f _binlog_tmp_files_$!
|
||||
fi
|
||||
cd "$OLD_PWD"
|
||||
|
||||
cd "$OLD_PWD"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -r "$MAGIC_FILE" ]
|
||||
then
|
||||
# check donor supplied secret
|
||||
SECRET=$(grep "$SECRET_TAG " "$MAGIC_FILE" 2>/dev/null | cut -d ' ' -f 2)
|
||||
if [ "$SECRET" != "$MY_SECRET" ]; then
|
||||
wsrep_log_error "Donor does not know my secret!"
|
||||
wsrep_log_info "Donor:'$SECRET', my:'$MY_SECRET'"
|
||||
exit 32
|
||||
fi
|
||||
|
||||
# remove secret from magic file
|
||||
grep -v "$SECRET_TAG " "$MAGIC_FILE" > "$MAGIC_FILE.new"
|
||||
|
||||
mv "$MAGIC_FILE.new" "$MAGIC_FILE"
|
||||
# UUID:seqno & wsrep_gtid_domain_id is received here.
|
||||
cat "$MAGIC_FILE" # Output : UUID:seqno wsrep_gtid_domain_id
|
||||
else
|
||||
# this message should cause joiner to abort
|
||||
echo "rsync process ended without creating '$MAGIC_FILE'"
|
||||
fi
|
||||
|
||||
wsrep_cleanup_progress_file
|
||||
# cleanup_joiner
|
||||
else
|
||||
@@ -559,6 +649,6 @@ else
|
||||
exit 22 # EINVAL
|
||||
fi
|
||||
|
||||
rm -f $BINLOG_TAR_FILE || :
|
||||
rm -f "$BINLOG_TAR_FILE" || :
|
||||
|
||||
exit 0
|
||||
|
Reference in New Issue
Block a user