2015-06-06 00:08:41 +02:00
|
|
|
# Copyright (C) 2012-2015 Codership Oy
|
2014-08-06 14:39:15 +02:00
|
|
|
#
|
|
|
|
# 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
|
|
|
|
# the Free Software Foundation; version 2 of the License.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; see the file COPYING. If not, write to the
|
|
|
|
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston
|
2019-05-11 21:19:05 +02:00
|
|
|
# MA 02110-1335 USA.
|
2014-08-06 14:39:15 +02:00
|
|
|
|
|
|
|
# This is a common command line parser to be sourced by other SST scripts
|
|
|
|
|
|
|
|
set -u
|
|
|
|
|
|
|
|
WSREP_SST_OPT_BYPASS=0
|
|
|
|
WSREP_SST_OPT_BINLOG=""
|
2018-06-26 11:56:19 +02:00
|
|
|
WSREP_SST_OPT_BINLOG_INDEX=""
|
2014-08-06 14:39:15 +02:00
|
|
|
WSREP_SST_OPT_DATA=""
|
2015-06-06 00:08:41 +02:00
|
|
|
WSREP_SST_OPT_AUTH=${WSREP_SST_OPT_AUTH:-}
|
|
|
|
WSREP_SST_OPT_USER=${WSREP_SST_OPT_USER:-}
|
|
|
|
WSREP_SST_OPT_PSWD=${WSREP_SST_OPT_PSWD:-}
|
2014-09-26 15:54:42 +02:00
|
|
|
WSREP_SST_OPT_DEFAULT=""
|
|
|
|
WSREP_SST_OPT_EXTRA_DEFAULT=""
|
2014-09-26 15:54:42 +02:00
|
|
|
WSREP_SST_OPT_SUFFIX_DEFAULT=""
|
MDEV-18863: Galera SST scripts can't read [mysqldN] option groups
Some users and some scripts (for example, mysqld_multi.sh) use special
option groups with names like [mysqld1], [mysqld2], ..., [mysqldN].
But SST scripts can't currently fully support these option groups.
The only option group-related value it gets from the server is
--defaults-group-suffix, if that option was set for mysqld when
the server was started.
However, the SST scripts does not get told by the server to read
these option groups, so this means that the SST script will fail
to read options like innodb-data-home-dir when it is in a option
group like [mysqld1]...[mysqldN].
Moreover, SST scripts ignore many parameters that can be passed
to them explicitly and cannot transfer them further, for example,
to the input of mariabackup utility. Ideally, we want to transfer
all the parameters of the original mysqld call to utilities such
as mariabackup, however the SST script does not receive these
parameters from the server and therefore cannot transfer them to
mariabackup.
To correct these shortcomings, we need to transfer to the scripts
all of the parameters of the original mysqld call, and in the SST
scripts themselves provide for the transfer all of these parameters
to utilities such as mariabackup. To prevent these parameters from
mixing with the script's own parameters, they should be transferred
to SST script after the special option "--mysqld-args", followed by
the string argument with the original parameters, as it received by
the mysqld call at the time of launch (further all these parameters
will be passed to mariabackup, for example).
In addition, the SST scripts themselves must be refined so that
they can read the parameters from the user-selected group, not just
from the global mysqld configuration group. And also so that they
can receive the parameters (which important for their work) as
command-line arguments.
2019-07-30 13:45:13 +02:00
|
|
|
WSREP_SST_OPT_SUFFIX_VALUE=""
|
|
|
|
WSREP_SST_OPT_MYSQLD=""
|
2018-08-27 16:10:20 +02:00
|
|
|
INNODB_DATA_HOME_DIR_ARG=""
|
MDEV-18863: Galera SST scripts can't read [mysqldN] option groups
Some users and some scripts (for example, mysqld_multi.sh) use special
option groups with names like [mysqld1], [mysqld2], ..., [mysqldN].
But SST scripts can't currently fully support these option groups.
The only option group-related value it gets from the server is
--defaults-group-suffix, if that option was set for mysqld when
the server was started.
However, the SST scripts does not get told by the server to read
these option groups, so this means that the SST script will fail
to read options like innodb-data-home-dir when it is in a option
group like [mysqld1]...[mysqldN].
Moreover, SST scripts ignore many parameters that can be passed
to them explicitly and cannot transfer them further, for example,
to the input of mariabackup utility. Ideally, we want to transfer
all the parameters of the original mysqld call to utilities such
as mariabackup, however the SST script does not receive these
parameters from the server and therefore cannot transfer them to
mariabackup.
To correct these shortcomings, we need to transfer to the scripts
all of the parameters of the original mysqld call, and in the SST
scripts themselves provide for the transfer all of these parameters
to utilities such as mariabackup. To prevent these parameters from
mixing with the script's own parameters, they should be transferred
to SST script after the special option "--mysqld-args", followed by
the string argument with the original parameters, as it received by
the mysqld call at the time of launch (further all these parameters
will be passed to mariabackup, for example).
In addition, the SST scripts themselves must be refined so that
they can read the parameters from the user-selected group, not just
from the global mysqld configuration group. And also so that they
can receive the parameters (which important for their work) as
command-line arguments.
2019-07-30 13:45:13 +02:00
|
|
|
INNODB_LOG_GROUP_HOME_ARG=""
|
|
|
|
INNODB_UNDO_DIR_ARG=""
|
|
|
|
LOG_BIN_ARG=""
|
2014-09-26 15:54:42 +02:00
|
|
|
|
2014-08-06 14:39:15 +02:00
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
case "$1" in
|
|
|
|
'--address')
|
|
|
|
readonly WSREP_SST_OPT_ADDR="$2"
|
2017-03-03 21:28:27 +01:00
|
|
|
#
|
|
|
|
# Break address string into host:port/path parts
|
|
|
|
#
|
2018-03-07 03:10:01 +01:00
|
|
|
case "${WSREP_SST_OPT_ADDR}" in
|
|
|
|
\[*)
|
|
|
|
# IPv6
|
|
|
|
addr_no_bracket=${WSREP_SST_OPT_ADDR#\[}
|
|
|
|
readonly WSREP_SST_OPT_HOST_UNESCAPED=${addr_no_bracket%%\]*}
|
|
|
|
readonly WSREP_SST_OPT_HOST="[${WSREP_SST_OPT_HOST_UNESCAPED}]"
|
2019-01-26 01:11:45 +01:00
|
|
|
readonly WSREP_SST_OPT_HOST_ESCAPED="\\[${WSREP_SST_OPT_HOST_UNESCAPED}\\]"
|
2018-03-07 03:10:01 +01:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
readonly WSREP_SST_OPT_HOST=${WSREP_SST_OPT_ADDR%%[:/]*}
|
|
|
|
readonly WSREP_SST_OPT_HOST_UNESCAPED=$WSREP_SST_OPT_HOST
|
2019-01-26 01:11:45 +01:00
|
|
|
readonly WSREP_SST_OPT_HOST_ESCAPED=$WSREP_SST_OPT_HOST
|
2018-03-07 03:10:01 +01:00
|
|
|
;;
|
|
|
|
esac
|
2019-01-26 01:11:45 +01:00
|
|
|
remain=${WSREP_SST_OPT_ADDR#${WSREP_SST_OPT_HOST_ESCAPED}}
|
2018-06-14 15:12:13 +02:00
|
|
|
remain=${remain#:}
|
2018-03-12 05:14:15 +01:00
|
|
|
readonly WSREP_SST_OPT_ADDR_PORT=${remain%%/*}
|
2018-03-07 03:10:01 +01:00
|
|
|
remain=${remain#*/}
|
|
|
|
readonly WSREP_SST_OPT_MODULE=${remain%%/*}
|
2017-03-03 21:28:27 +01:00
|
|
|
readonly WSREP_SST_OPT_PATH=${WSREP_SST_OPT_ADDR#*/}
|
2018-01-14 01:28:43 +01:00
|
|
|
remain=${WSREP_SST_OPT_PATH#*/}
|
2018-09-13 01:58:50 +02:00
|
|
|
if [ "$remain" != "${WSREP_SST_OPT_PATH}" ]; then
|
|
|
|
readonly WSREP_SST_OPT_LSN=${remain%%/*}
|
|
|
|
remain=${remain#*/}
|
|
|
|
if [ "$remain" != "${WSREP_SST_OPT_LSN}" ]; then
|
|
|
|
readonly WSREP_SST_OPT_SST_VER=${remain%%/*}
|
|
|
|
else
|
|
|
|
readonly WSREP_SST_OPT_SST_VER=""
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
readonly WSREP_SST_OPT_LSN=""
|
|
|
|
readonly WSREP_SST_OPT_SST_VER=""
|
|
|
|
fi
|
2014-08-06 14:39:15 +02:00
|
|
|
shift
|
|
|
|
;;
|
|
|
|
'--bypass')
|
|
|
|
WSREP_SST_OPT_BYPASS=1
|
|
|
|
;;
|
|
|
|
'--datadir')
|
|
|
|
readonly WSREP_SST_OPT_DATA="$2"
|
|
|
|
shift
|
|
|
|
;;
|
2018-08-27 16:10:20 +02:00
|
|
|
'--innodb-data-home-dir')
|
|
|
|
readonly INNODB_DATA_HOME_DIR_ARG="$2"
|
|
|
|
shift
|
|
|
|
;;
|
MDEV-18863: Galera SST scripts can't read [mysqldN] option groups
Some users and some scripts (for example, mysqld_multi.sh) use special
option groups with names like [mysqld1], [mysqld2], ..., [mysqldN].
But SST scripts can't currently fully support these option groups.
The only option group-related value it gets from the server is
--defaults-group-suffix, if that option was set for mysqld when
the server was started.
However, the SST scripts does not get told by the server to read
these option groups, so this means that the SST script will fail
to read options like innodb-data-home-dir when it is in a option
group like [mysqld1]...[mysqldN].
Moreover, SST scripts ignore many parameters that can be passed
to them explicitly and cannot transfer them further, for example,
to the input of mariabackup utility. Ideally, we want to transfer
all the parameters of the original mysqld call to utilities such
as mariabackup, however the SST script does not receive these
parameters from the server and therefore cannot transfer them to
mariabackup.
To correct these shortcomings, we need to transfer to the scripts
all of the parameters of the original mysqld call, and in the SST
scripts themselves provide for the transfer all of these parameters
to utilities such as mariabackup. To prevent these parameters from
mixing with the script's own parameters, they should be transferred
to SST script after the special option "--mysqld-args", followed by
the string argument with the original parameters, as it received by
the mysqld call at the time of launch (further all these parameters
will be passed to mariabackup, for example).
In addition, the SST scripts themselves must be refined so that
they can read the parameters from the user-selected group, not just
from the global mysqld configuration group. And also so that they
can receive the parameters (which important for their work) as
command-line arguments.
2019-07-30 13:45:13 +02:00
|
|
|
'--innodb-log-group-home-dir')
|
|
|
|
readonly INNODB_LOG_GROUP_HOME_ARG="$2"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
'--innodb-undo-directory')
|
|
|
|
readonly INNODB_UNDO_DIR_ARG="$2"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
'--log-bin')
|
|
|
|
readonly LOG_BIN_ARG="$2"
|
|
|
|
shift
|
|
|
|
;;
|
2014-08-06 14:39:15 +02:00
|
|
|
'--defaults-file')
|
2014-09-26 15:54:42 +02:00
|
|
|
readonly WSREP_SST_OPT_DEFAULT="$1=$2"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
'--defaults-extra-file')
|
|
|
|
readonly WSREP_SST_OPT_EXTRA_DEFAULT="$1=$2"
|
2014-08-06 14:39:15 +02:00
|
|
|
shift
|
2015-11-21 01:49:16 +01:00
|
|
|
;;
|
2015-06-06 00:38:07 +02:00
|
|
|
'--defaults-group-suffix')
|
2014-09-26 15:54:42 +02:00
|
|
|
readonly WSREP_SST_OPT_SUFFIX_DEFAULT="$1=$2"
|
MDEV-18863: Galera SST scripts can't read [mysqldN] option groups
Some users and some scripts (for example, mysqld_multi.sh) use special
option groups with names like [mysqld1], [mysqld2], ..., [mysqldN].
But SST scripts can't currently fully support these option groups.
The only option group-related value it gets from the server is
--defaults-group-suffix, if that option was set for mysqld when
the server was started.
However, the SST scripts does not get told by the server to read
these option groups, so this means that the SST script will fail
to read options like innodb-data-home-dir when it is in a option
group like [mysqld1]...[mysqldN].
Moreover, SST scripts ignore many parameters that can be passed
to them explicitly and cannot transfer them further, for example,
to the input of mariabackup utility. Ideally, we want to transfer
all the parameters of the original mysqld call to utilities such
as mariabackup, however the SST script does not receive these
parameters from the server and therefore cannot transfer them to
mariabackup.
To correct these shortcomings, we need to transfer to the scripts
all of the parameters of the original mysqld call, and in the SST
scripts themselves provide for the transfer all of these parameters
to utilities such as mariabackup. To prevent these parameters from
mixing with the script's own parameters, they should be transferred
to SST script after the special option "--mysqld-args", followed by
the string argument with the original parameters, as it received by
the mysqld call at the time of launch (further all these parameters
will be passed to mariabackup, for example).
In addition, the SST scripts themselves must be refined so that
they can read the parameters from the user-selected group, not just
from the global mysqld configuration group. And also so that they
can receive the parameters (which important for their work) as
command-line arguments.
2019-07-30 13:45:13 +02:00
|
|
|
readonly WSREP_SST_OPT_SUFFIX_VALUE="$2"
|
2015-06-06 00:38:07 +02:00
|
|
|
shift
|
2014-08-06 14:39:15 +02:00
|
|
|
;;
|
|
|
|
'--host')
|
|
|
|
readonly WSREP_SST_OPT_HOST="$2"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
'--local-port')
|
|
|
|
readonly WSREP_SST_OPT_LPORT="$2"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
'--parent')
|
|
|
|
readonly WSREP_SST_OPT_PARENT="$2"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
'--password')
|
|
|
|
WSREP_SST_OPT_PSWD="$2"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
'--port')
|
|
|
|
readonly WSREP_SST_OPT_PORT="$2"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
'--role')
|
|
|
|
readonly WSREP_SST_OPT_ROLE="$2"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
'--socket')
|
|
|
|
readonly WSREP_SST_OPT_SOCKET="$2"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
'--user')
|
|
|
|
WSREP_SST_OPT_USER="$2"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
'--gtid')
|
|
|
|
readonly WSREP_SST_OPT_GTID="$2"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
'--binlog')
|
|
|
|
WSREP_SST_OPT_BINLOG="$2"
|
|
|
|
shift
|
|
|
|
;;
|
2018-06-26 11:56:19 +02:00
|
|
|
'--binlog-index')
|
|
|
|
WSREP_SST_OPT_BINLOG_INDEX="$2"
|
|
|
|
shift
|
|
|
|
;;
|
2015-02-28 04:33:41 +01:00
|
|
|
'--gtid-domain-id')
|
|
|
|
readonly WSREP_SST_OPT_GTID_DOMAIN_ID="$2"
|
|
|
|
shift
|
|
|
|
;;
|
MDEV-18863: Galera SST scripts can't read [mysqldN] option groups
Some users and some scripts (for example, mysqld_multi.sh) use special
option groups with names like [mysqld1], [mysqld2], ..., [mysqldN].
But SST scripts can't currently fully support these option groups.
The only option group-related value it gets from the server is
--defaults-group-suffix, if that option was set for mysqld when
the server was started.
However, the SST scripts does not get told by the server to read
these option groups, so this means that the SST script will fail
to read options like innodb-data-home-dir when it is in a option
group like [mysqld1]...[mysqldN].
Moreover, SST scripts ignore many parameters that can be passed
to them explicitly and cannot transfer them further, for example,
to the input of mariabackup utility. Ideally, we want to transfer
all the parameters of the original mysqld call to utilities such
as mariabackup, however the SST script does not receive these
parameters from the server and therefore cannot transfer them to
mariabackup.
To correct these shortcomings, we need to transfer to the scripts
all of the parameters of the original mysqld call, and in the SST
scripts themselves provide for the transfer all of these parameters
to utilities such as mariabackup. To prevent these parameters from
mixing with the script's own parameters, they should be transferred
to SST script after the special option "--mysqld-args", followed by
the string argument with the original parameters, as it received by
the mysqld call at the time of launch (further all these parameters
will be passed to mariabackup, for example).
In addition, the SST scripts themselves must be refined so that
they can read the parameters from the user-selected group, not just
from the global mysqld configuration group. And also so that they
can receive the parameters (which important for their work) as
command-line arguments.
2019-07-30 13:45:13 +02:00
|
|
|
'--mysqld-args')
|
|
|
|
original_cmd=""
|
|
|
|
shift
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
option=${1%%=*}
|
2019-08-26 13:37:09 +02:00
|
|
|
if [[ "$option" != "--defaults-file" && \
|
|
|
|
"$option" != "--defaults-extra-file" && \
|
|
|
|
"$option" != "--defaults-group-suffix" && \
|
|
|
|
"$option" != "--port" && \
|
|
|
|
"$option" != "--socket" ]]; then
|
MDEV-18863: Galera SST scripts can't read [mysqldN] option groups
Some users and some scripts (for example, mysqld_multi.sh) use special
option groups with names like [mysqld1], [mysqld2], ..., [mysqldN].
But SST scripts can't currently fully support these option groups.
The only option group-related value it gets from the server is
--defaults-group-suffix, if that option was set for mysqld when
the server was started.
However, the SST scripts does not get told by the server to read
these option groups, so this means that the SST script will fail
to read options like innodb-data-home-dir when it is in a option
group like [mysqld1]...[mysqldN].
Moreover, SST scripts ignore many parameters that can be passed
to them explicitly and cannot transfer them further, for example,
to the input of mariabackup utility. Ideally, we want to transfer
all the parameters of the original mysqld call to utilities such
as mariabackup, however the SST script does not receive these
parameters from the server and therefore cannot transfer them to
mariabackup.
To correct these shortcomings, we need to transfer to the scripts
all of the parameters of the original mysqld call, and in the SST
scripts themselves provide for the transfer all of these parameters
to utilities such as mariabackup. To prevent these parameters from
mixing with the script's own parameters, they should be transferred
to SST script after the special option "--mysqld-args", followed by
the string argument with the original parameters, as it received by
the mysqld call at the time of launch (further all these parameters
will be passed to mariabackup, for example).
In addition, the SST scripts themselves must be refined so that
they can read the parameters from the user-selected group, not just
from the global mysqld configuration group. And also so that they
can receive the parameters (which important for their work) as
command-line arguments.
2019-07-30 13:45:13 +02:00
|
|
|
value=${1#*=}
|
|
|
|
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
|
2019-08-21 11:12:39 +02:00
|
|
|
original_cmd="$original_cmd $1"
|
MDEV-18863: Galera SST scripts can't read [mysqldN] option groups
Some users and some scripts (for example, mysqld_multi.sh) use special
option groups with names like [mysqld1], [mysqld2], ..., [mysqldN].
But SST scripts can't currently fully support these option groups.
The only option group-related value it gets from the server is
--defaults-group-suffix, if that option was set for mysqld when
the server was started.
However, the SST scripts does not get told by the server to read
these option groups, so this means that the SST script will fail
to read options like innodb-data-home-dir when it is in a option
group like [mysqld1]...[mysqldN].
Moreover, SST scripts ignore many parameters that can be passed
to them explicitly and cannot transfer them further, for example,
to the input of mariabackup utility. Ideally, we want to transfer
all the parameters of the original mysqld call to utilities such
as mariabackup, however the SST script does not receive these
parameters from the server and therefore cannot transfer them to
mariabackup.
To correct these shortcomings, we need to transfer to the scripts
all of the parameters of the original mysqld call, and in the SST
scripts themselves provide for the transfer all of these parameters
to utilities such as mariabackup. To prevent these parameters from
mixing with the script's own parameters, they should be transferred
to SST script after the special option "--mysqld-args", followed by
the string argument with the original parameters, as it received by
the mysqld call at the time of launch (further all these parameters
will be passed to mariabackup, for example).
In addition, the SST scripts themselves must be refined so that
they can read the parameters from the user-selected group, not just
from the global mysqld configuration group. And also so that they
can receive the parameters (which important for their work) as
command-line arguments.
2019-07-30 13:45:13 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
readonly WSREP_SST_OPT_MYSQLD="$original_cmd"
|
|
|
|
break
|
|
|
|
;;
|
2014-08-06 14:39:15 +02:00
|
|
|
*) # must be command
|
|
|
|
# usage
|
|
|
|
# exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
readonly WSREP_SST_OPT_BYPASS
|
|
|
|
readonly WSREP_SST_OPT_BINLOG
|
2018-06-26 11:56:19 +02:00
|
|
|
readonly WSREP_SST_OPT_BINLOG_INDEX
|
2014-08-06 14:39:15 +02:00
|
|
|
|
2017-10-24 20:59:54 +02:00
|
|
|
if [ -n "${WSREP_SST_OPT_ADDR_PORT:-}" ]; then
|
2017-10-24 20:59:54 +02:00
|
|
|
if [ -n "${WSREP_SST_OPT_PORT:-}" ]; then
|
2017-10-16 17:49:52 +02:00
|
|
|
if [ "$WSREP_SST_OPT_PORT" != "$WSREP_SST_OPT_ADDR_PORT" ]; then
|
2018-03-12 05:23:58 +01:00
|
|
|
echo "WSREP_SST: [ERROR] port in --port=$WSREP_SST_OPT_PORT differs from port in --address=$WSREP_SST_OPT_ADDR" >&2
|
2017-10-16 17:49:52 +02:00
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
readonly WSREP_SST_OPT_PORT="$WSREP_SST_OPT_ADDR_PORT"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2015-07-14 22:05:29 +02:00
|
|
|
# try to use my_print_defaults, mysql and mysqldump that come with the sources
|
|
|
|
# (for MTR suite)
|
|
|
|
SCRIPTS_DIR="$(cd $(dirname "$0"); pwd -P)"
|
|
|
|
EXTRA_DIR="$SCRIPTS_DIR/../extra"
|
|
|
|
CLIENT_DIR="$SCRIPTS_DIR/../client"
|
|
|
|
|
|
|
|
if [ -x "$CLIENT_DIR/mysql" ]; then
|
|
|
|
MYSQL_CLIENT="$CLIENT_DIR/mysql"
|
|
|
|
else
|
|
|
|
MYSQL_CLIENT=$(which mysql)
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -x "$CLIENT_DIR/mysqldump" ]; then
|
|
|
|
MYSQLDUMP="$CLIENT_DIR/mysqldump"
|
|
|
|
else
|
|
|
|
MYSQLDUMP=$(which mysqldump)
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -x "$SCRIPTS_DIR/my_print_defaults" ]; then
|
|
|
|
MY_PRINT_DEFAULTS="$SCRIPTS_DIR/my_print_defaults"
|
|
|
|
elif [ -x "$EXTRA_DIR/my_print_defaults" ]; then
|
|
|
|
MY_PRINT_DEFAULTS="$EXTRA_DIR/my_print_defaults"
|
|
|
|
else
|
|
|
|
MY_PRINT_DEFAULTS=$(which my_print_defaults)
|
|
|
|
fi
|
|
|
|
|
2019-08-26 13:37:09 +02:00
|
|
|
wsrep_defaults="$WSREP_SST_OPT_DEFAULT"
|
|
|
|
if [ -n "$wsrep_defaults" ]; then
|
|
|
|
wsrep_defaults="$wsrep_defaults "
|
|
|
|
fi
|
|
|
|
wsrep_defaults="$wsrep_defaults$WSREP_SST_OPT_EXTRA_DEFAULT"
|
|
|
|
if [ -n "$wsrep_defaults" ]; then
|
|
|
|
wsrep_defaults="$wsrep_defaults "
|
|
|
|
fi
|
|
|
|
readonly WSREP_SST_OPT_CONF="$wsrep_defaults$WSREP_SST_OPT_SUFFIX_DEFAULT"
|
2018-02-03 08:09:06 +01:00
|
|
|
readonly MY_PRINT_DEFAULTS="$MY_PRINT_DEFAULTS $WSREP_SST_OPT_CONF"
|
2014-09-26 15:54:42 +02:00
|
|
|
|
2015-06-06 00:08:41 +02:00
|
|
|
wsrep_auth_not_set()
|
|
|
|
{
|
|
|
|
[ -z "$WSREP_SST_OPT_AUTH" -o "$WSREP_SST_OPT_AUTH" = "(null)" ]
|
|
|
|
}
|
2014-09-26 15:54:42 +02:00
|
|
|
|
2014-09-26 15:54:42 +02:00
|
|
|
# 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)
|
2014-08-06 14:39:15 +02:00
|
|
|
fi
|
|
|
|
fi
|
2015-06-06 00:08:41 +02:00
|
|
|
readonly WSREP_SST_OPT_AUTH
|
|
|
|
|
|
|
|
# Splitting AUTH into potential user:password pair
|
|
|
|
if ! wsrep_auth_not_set
|
|
|
|
then
|
2016-07-24 22:01:14 +02:00
|
|
|
WSREP_SST_OPT_USER="${WSREP_SST_OPT_AUTH%%:*}"
|
|
|
|
WSREP_SST_OPT_PSWD="${WSREP_SST_OPT_AUTH##*:}"
|
2015-06-06 00:08:41 +02:00
|
|
|
fi
|
|
|
|
readonly WSREP_SST_OPT_USER
|
|
|
|
readonly WSREP_SST_OPT_PSWD
|
2014-08-06 14:39:15 +02:00
|
|
|
|
|
|
|
if [ -n "${WSREP_SST_OPT_DATA:-}" ]
|
|
|
|
then
|
|
|
|
SST_PROGRESS_FILE="$WSREP_SST_OPT_DATA/sst_in_progress"
|
|
|
|
else
|
|
|
|
SST_PROGRESS_FILE=""
|
|
|
|
fi
|
|
|
|
|
|
|
|
wsrep_log()
|
|
|
|
{
|
|
|
|
# echo everything to stderr so that it gets into common error log
|
|
|
|
# deliberately made to look different from the rest of the log
|
|
|
|
local readonly tst="$(date +%Y%m%d\ %H:%M:%S.%N | cut -b -21)"
|
2015-06-25 05:38:04 +02:00
|
|
|
echo "WSREP_SST: $* ($tst)" >&2
|
2014-08-06 14:39:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
wsrep_log_error()
|
|
|
|
{
|
|
|
|
wsrep_log "[ERROR] $*"
|
|
|
|
}
|
|
|
|
|
2017-03-03 21:28:27 +01:00
|
|
|
wsrep_log_warning()
|
|
|
|
{
|
|
|
|
wsrep_log "[WARNING] $*"
|
|
|
|
}
|
|
|
|
|
2014-08-06 14:39:15 +02:00
|
|
|
wsrep_log_info()
|
|
|
|
{
|
|
|
|
wsrep_log "[INFO] $*"
|
|
|
|
}
|
|
|
|
|
|
|
|
wsrep_cleanup_progress_file()
|
|
|
|
{
|
2016-01-11 21:43:27 +01:00
|
|
|
[ -n "${SST_PROGRESS_FILE:-}" ] && rm -f "$SST_PROGRESS_FILE" 2>/dev/null || true
|
2014-08-06 14:39:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
wsrep_check_program()
|
|
|
|
{
|
|
|
|
local prog=$1
|
|
|
|
|
|
|
|
if ! which $prog >/dev/null
|
|
|
|
then
|
|
|
|
echo "'$prog' not found in PATH"
|
|
|
|
return 2 # no such file or directory
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
wsrep_check_programs()
|
|
|
|
{
|
|
|
|
local ret=0
|
|
|
|
|
|
|
|
while [ $# -gt 0 ]
|
|
|
|
do
|
|
|
|
wsrep_check_program $1 || ret=$?
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
return $ret
|
|
|
|
}
|
2017-03-03 21:28:27 +01:00
|
|
|
|
|
|
|
#
|
2019-01-26 01:11:45 +01:00
|
|
|
# user can specify mariabackup specific settings that will be used during sst
|
2017-03-03 21:28:27 +01:00
|
|
|
# process like encryption, etc.....
|
|
|
|
# parse such configuration option. (group for xb settings is [sst] in my.cnf
|
|
|
|
#
|
2014-09-26 15:54:42 +02:00
|
|
|
# 1st param: group (config file section like sst) or my_print_defaults argument (like --mysqld)
|
2017-03-03 21:28:27 +01:00
|
|
|
# 2nd param: var : name of the variable in the section, e.g. server-id
|
|
|
|
# 3rd param: - : default value for the param
|
|
|
|
parse_cnf()
|
|
|
|
{
|
|
|
|
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)
|
2018-01-13 13:05:21 +01:00
|
|
|
# then search for needed variable
|
2017-03-03 21:28:27 +01:00
|
|
|
# finally get the variable value (if variables has been specified multiple time use the last value only)
|
|
|
|
|
2018-01-13 13:05:21 +01:00
|
|
|
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}')
|
2017-03-03 21:28:27 +01:00
|
|
|
|
|
|
|
# use default if we haven't found a value
|
2018-08-29 18:30:03 +02:00
|
|
|
if [ -z "$reval" ]; then
|
|
|
|
[ -n "$3" ] && reval=$3
|
2017-03-03 21:28:27 +01:00
|
|
|
fi
|
|
|
|
echo $reval
|
|
|
|
}
|