summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/CMakeLists.txt177
-rwxr-xr-xscripts/galera_new_cluster.sh27
-rw-r--r--scripts/galera_recovery.sh118
-rw-r--r--scripts/make_binary_distribution.sh386
-rw-r--r--scripts/maria_add_gis_sp.sql.in37
-rwxr-xr-xscripts/mariadb-service-convert82
-rw-r--r--scripts/mysql_config.sh59
-rw-r--r--scripts/mysql_convert_table_format.sh2
-rw-r--r--scripts/mysql_find_rows.sh2
-rw-r--r--scripts/mysql_fix_extensions.sh6
-rw-r--r--scripts/mysql_install_db.pl.in74
-rw-r--r--scripts/mysql_install_db.sh82
-rw-r--r--scripts/mysql_performance_tables.sql1424
-rw-r--r--scripts/mysql_setpermission.sh18
-rw-r--r--scripts/mysql_system_tables.sql4
-rw-r--r--scripts/mysql_system_tables_data.sql27
-rw-r--r--scripts/mysql_system_tables_fix.sql10
-rw-r--r--scripts/mysql_to_mariadb.sql22
-rw-r--r--scripts/mysql_zap.sh4
-rw-r--r--scripts/mysqlaccess.sh6
-rw-r--r--scripts/mysqld_multi.sh67
-rw-r--r--scripts/mysqld_safe.sh158
-rw-r--r--scripts/mysqldumpslow.sh19
-rw-r--r--scripts/mytop.sh39
-rw-r--r--scripts/wsrep_sst_common.sh306
-rw-r--r--scripts/wsrep_sst_mariabackup.sh1148
-rw-r--r--scripts/wsrep_sst_mysqldump.sh179
-rw-r--r--scripts/wsrep_sst_rsync.sh498
-rw-r--r--scripts/wsrep_sst_xtrabackup-v2.sh1269
-rw-r--r--scripts/wsrep_sst_xtrabackup.sh701
30 files changed, 4885 insertions, 2066 deletions
diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt
index 24b48e1920e..9f320ce6aa4 100644
--- a/scripts/CMakeLists.txt
+++ b/scripts/CMakeLists.txt
@@ -74,6 +74,23 @@ IF(UNIX)
)
ENDIF()
+# Configure two scripts from one 'in' file.
+# The maria_add_gis_sp.sql - to be sent to 'mysql' tool
+# and the maria_add_gis_sp_bootstrap.sql, that can be sent to
+# the server as a bootstrap command.
+
+SET(ADD_GIS_SP_SET_DELIMITER "delimiter |")
+SET(ADD_GIS_SP_RESET_DELIMITER "delimiter ;")
+SET(ADD_GIS_SP_EOL "|")
+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/maria_add_gis_sp.sql.in
+ ${CMAKE_CURRENT_BINARY_DIR}/maria_add_gis_sp.sql ESCAPE_QUOTES @ONLY)
+
+SET(ADD_GIS_SP_SET_DELIMITER "")
+SET(ADD_GIS_SP_RESET_DELIMITER "")
+SET(ADD_GIS_SP_EOL ";")
+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/maria_add_gis_sp.sql.in
+ ${CMAKE_CURRENT_BINARY_DIR}/maria_add_gis_sp_bootstrap.sql ESCAPE_QUOTES @ONLY)
+
IF (NOT WITHOUT_SERVER)
INSTALL(FILES
${CMAKE_CURRENT_SOURCE_DIR}/mysql_system_tables.sql
@@ -81,6 +98,9 @@ INSTALL(FILES
${CMAKE_CURRENT_SOURCE_DIR}/mysql_performance_tables.sql
${CMAKE_CURRENT_SOURCE_DIR}/fill_help_tables.sql
${CMAKE_CURRENT_SOURCE_DIR}/mysql_test_data_timezone.sql
+ ${CMAKE_CURRENT_SOURCE_DIR}/mysql_to_mariadb.sql
+ ${CMAKE_CURRENT_BINARY_DIR}/maria_add_gis_sp.sql
+ ${CMAKE_CURRENT_BINARY_DIR}/maria_add_gis_sp_bootstrap.sql
${FIX_PRIVILEGES_SQL}
DESTINATION ${INSTALL_MYSQLSHAREDIR} COMPONENT Server
)
@@ -92,7 +112,7 @@ IF(MALLOC_LIB)
INSTALL(FILES ${MALLOC_LIB} DESTINATION ${INSTALL_LIBDIR} OPTIONAL)
ENDIF()
-IF(CMAKE_GENERATOR MATCHES "Makefiles")
+IF(CMAKE_GENERATOR MATCHES "Makefiles|Ninja")
FOREACH(ARCH ${CMAKE_OSX_ARCHITECTURES})
SET(CFLAGS "${CFLAGS} -arch ${ARCH}")
SET(CXXFLAGS "${CXXFLAGS} -arch ${ARCH}")
@@ -187,18 +207,19 @@ ENDIF(UNIX)
IF(INSTALL_LAYOUT MATCHES "STANDALONE")
SET(prefix ".")
-ELSE()
- SET(prefix "${CMAKE_INSTALL_PREFIX}")
-ENDIF()
-
-SET(bindir ${prefix}/${INSTALL_BINDIR})
-SET(sbindir ${prefix}/${INSTALL_SBINDIR})
-SET(scriptdir ${prefix}/${INSTALL_BINDIR})
-SET(libexecdir ${prefix}/${INSTALL_SBINDIR})
-SET(pkgdatadir ${prefix}/${INSTALL_MYSQLSHAREDIR})
-IF(INSTALL_LAYOUT MATCHES "STANDALONE")
+ SET(bindir ${prefix}/${INSTALL_BINDIR})
+ SET(sbindir ${prefix}/${INSTALL_SBINDIR})
+ SET(scriptdir ${prefix}/${INSTALL_BINDIR})
+ SET(libexecdir ${prefix}/${INSTALL_SBINDIR})
+ SET(pkgdatadir ${prefix}/${INSTALL_MYSQLSHAREDIR})
SET(localstatedir ${prefix}/data)
ELSE()
+ SET(prefix "${CMAKE_INSTALL_PREFIX}")
+ SET(bindir ${INSTALL_BINDIRABS})
+ SET(sbindir ${INSTALL_SBINDIRABS})
+ SET(scriptdir ${INSTALL_BINDIRABS})
+ SET(libexecdir ${INSTALL_SBINDIRABS})
+ SET(pkgdatadir ${INSTALL_MYSQLSHAREDIRABS})
SET(localstatedir ${MYSQL_DATADIR})
ENDIF()
@@ -210,15 +231,13 @@ SET(pkgdata_locations "$basedir/${INSTALL_MYSQLSHAREDIR} $basedir/share $basedir
IF(UNIX)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/mysql_install_db.sh
${CMAKE_CURRENT_BINARY_DIR}/mysql_install_db ESCAPE_QUOTES @ONLY)
- SET(DEST ${INSTALL_SCRIPTDIR})
- SET(EXT)
EXECUTE_PROCESS(
COMMAND chmod +x ${CMAKE_CURRENT_BINARY_DIR}/mysql_install_db
)
INSTALL_SCRIPT(
"${CMAKE_CURRENT_BINARY_DIR}/mysql_install_db"
- DESTINATION ${DEST}
+ DESTINATION ${INSTALL_SCRIPTDIR}
COMPONENT Server
)
ENDIF()
@@ -229,15 +248,15 @@ IF(INSTALL_SYSCONFDIR)
ELSE()
SET(sysconfdir "/etc")
ENDIF()
-SET(bindir ${prefix}/${INSTALL_BINDIR})
-SET(libexecdir ${prefix}/${INSTALL_SBINDIR})
-SET(scriptdir ${prefix}/${INSTALL_BINDIR})
-SET(datadir ${prefix}/${INSTALL_MYSQLSHAREDIR})
-SET(pkgdatadir ${prefix}/${INSTALL_MYSQLSHAREDIR})
+SET(bindir ${INSTALL_BINDIRABS})
+SET(libexecdir ${INSTALL_SBINDIRABS})
+SET(scriptdir ${INSTALL_BINDIRABS})
+SET(datadir ${INSTALL_MYSQLSHAREDIRABS})
+SET(pkgdatadir ${INSTALL_MYSQLSHAREDIRABS})
SET(libsubdir ${INSTALL_LIBDIR})
-SET(pkgincludedir ${prefix}/${INSTALL_INCLUDEDIR})
-SET(pkglibdir ${prefix}/${INSTALL_LIBDIR})
-SET(pkgplugindir ${prefix}/${INSTALL_PLUGINDIR})
+SET(pkgincludedir ${INSTALL_INCLUDEDIRABS})
+SET(pkglibdir ${INSTALL_LIBDIRABS})
+SET(pkgplugindir ${INSTALL_PLUGINDIRABS})
SET(localstatedir ${MYSQL_DATADIR})
SET(RPATH_OPTION "")
@@ -252,57 +271,6 @@ ELSE()
SET(TARGET_LINUX "false")
ENDIF()
-# Use cmake variables to inspect dependencies for
-# mysqlclient library (add -l stuff)
-SET(CLIENT_LIBS "")
-SET(LIBS "")
-
-# Avoid compatibility warning about lists with empty elements
-IF(POLICY CMP0011)
- CMAKE_POLICY(SET CMP0011 NEW)
-ENDIF()
-IF(POLICY CMP0007)
- CMAKE_POLICY(SET CMP0007 OLD)
-ENDIF()
-
-# Extract dependencies using CMake's internal ${target}_LIB_DEPENDS variable
-# returned string in ${var} is can be passed to linker's command line
-MACRO(EXTRACT_LINK_LIBRARIES target var)
- IF(${target}_LIB_DEPENDS)
- LIST(REMOVE_ITEM ${target}_LIB_DEPENDS "")
- LIST(REMOVE_DUPLICATES ${target}_LIB_DEPENDS)
- FOREACH(lib ${${target}_LIB_DEPENDS})
- # Filter out "general", it is not a library, just CMake hint
- # Also, remove duplicates
- IF(NOT lib STREQUAL "general" AND NOT ${var} MATCHES "-l${lib} ")
- IF (lib MATCHES "^\\-l")
- SET(${var} "${${var}} ${lib} ")
- ELSEIF(lib MATCHES "^/")
- IF (lib MATCHES "\\.(a|so([0-9.]*)|lib|dll|dylib)$")
- # Full path, convert to just filename, strip "lib" prefix and extension
- GET_FILENAME_COMPONENT(lib "${lib}" NAME_WE)
- STRING(REGEX REPLACE "^lib" "" lib "${lib}")
- SET(${var} "${${var}}-l${lib} " )
- ENDIF()
- ELSE()
- SET(${var} "${${var}}-l${lib} " )
- ENDIF()
- ENDIF()
- ENDFOREACH()
- ENDIF()
- IF(MSVC)
- STRING(REPLACE "-l" "" ${var} "${${var}}")
- ENDIF()
-ENDMACRO()
-
-EXTRACT_LINK_LIBRARIES(mysqlclient CLIENT_LIBS)
-EXTRACT_LINK_LIBRARIES(mysqlserver LIBS)
-
-# mysql_config evaluates ${LIBDL}, we want to avoid it
-# as our CLIENT_LIBS and LIBS are already correct
-SET(LIBDL)
-
-SET(NON_THREADED_LIBS ${CLIENT_LIBS})
SET(mysql_config_COMPONENT COMPONENT Development)
SET(msql2mysql_COMPONENT COMPONENT Client)
SET(mysqlaccess_COMPONENT COMPONENT Client)
@@ -335,6 +303,29 @@ IF(WIN32)
INSTALL_SCRIPT(${CMAKE_CURRENT_BINARY_DIR}/${file}.pl COMPONENT Server_Scripts)
ENDFOREACH()
ELSE()
+ IF(WITH_WSREP)
+ SET(WSREP_SCRIPTS
+ wsrep_sst_mysqldump
+ wsrep_sst_rsync
+ wsrep_sst_xtrabackup
+ wsrep_sst_xtrabackup-v2
+ wsrep_sst_mariabackup
+ )
+ # The following script is sourced from other SST scripts, so it should
+ # not be made executable.
+ SET(WSREP_SOURCE
+ wsrep_sst_common
+ )
+ ENDIF()
+ IF (NOT WITHOUT_SERVER)
+ SET(SERVER_SCRIPTS
+ mysql_fix_extensions
+ mysql_zap
+ mysqld_multi
+ mysqld_safe
+ mysqldumpslow
+ )
+ ENDIF()
# Configure this one, for testing, but do not install it.
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/mysql_config.pl.in
${CMAKE_CURRENT_BINARY_DIR}/mysql_config.pl ESCAPE_QUOTES @ONLY)
@@ -342,18 +333,16 @@ ELSE()
SET(BIN_SCRIPTS
msql2mysql
mysql_config
- mysql_fix_extensions
mysql_setpermission
mysql_secure_installation
- mysql_zap
mysqlaccess
mysql_convert_table_format
mysql_find_rows
mytop
mysqlhotcopy
- mysqldumpslow
- mysqld_multi
- mysqld_safe
+ ${SERVER_SCRIPTS}
+ ${WSREP_SCRIPTS}
+ ${SYSTEMD_SCRIPTS}
)
FOREACH(file ${BIN_SCRIPTS})
IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file}.sh)
@@ -366,6 +355,9 @@ ELSE()
MESSAGE(FATAL_ERROR "Can not find ${file}.sh or ${file} in "
"${CMAKE_CURRENT_SOURCE_DIR}" )
ENDIF()
+ # TODO: The following EXECUTE could be redundant as INSTALL_SCRIPT
+ # macro does an INSTALL(PROGRAMS ..) that automatically sets +x on
+ # the executable.
EXECUTE_PROCESS(COMMAND chmod +x ${CMAKE_CURRENT_BINARY_DIR}/${file})
IF(NOT ${file}_COMPONENT)
SET(${file}_COMPONENT Server)
@@ -376,6 +368,35 @@ ELSE()
COMPONENT ${${file}_COMPONENT}
)
ENDFOREACH()
+ SET (wsrep_sst_rsync_wan ${CMAKE_CURRENT_BINARY_DIR}/wsrep_sst_rsync_wan)
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${wsrep_sst_rsync_wan}
+ COMMAND ${CMAKE_COMMAND} ARGS -E create_symlink
+ wsrep_sst_rsync
+ wsrep_sst_rsync_wan
+ )
+ ADD_CUSTOM_TARGET(symlink_wsrep_sst_rsync
+ ALL
+ DEPENDS ${wsrep_sst_rsync_wan}
+ )
+ INSTALL(
+ FILES ${wsrep_sst_rsync_wan}
+ DESTINATION ${INSTALL_BINDIR}
+ COMPONENT Server
+ )
+
+ FOREACH(file ${WSREP_SOURCE})
+ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${file}.sh
+ ${CMAKE_CURRENT_BINARY_DIR}/${file} ESCAPE_QUOTES @ONLY)
+ IF(NOT ${file}_COMPONENT)
+ SET(${file}_COMPONENT Server)
+ ENDIF()
+ INSTALL(FILES
+ ${CMAKE_CURRENT_BINARY_DIR}/${file}
+ DESTINATION ${INSTALL_BINDIR}
+ COMPONENT ${${file}_COMPONENT}
+ )
+ ENDFOREACH()
ENDIF()
# Install libgcc as mylibgcc.a
diff --git a/scripts/galera_new_cluster.sh b/scripts/galera_new_cluster.sh
new file mode 100755
index 00000000000..837e3e29942
--- /dev/null
+++ b/scripts/galera_new_cluster.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+
+if [ "${1}" = "-h" ] || [ "${1}" = "--help" ]; then
+ cat <<EOF
+
+Usage: ${0}
+
+ The script galera_new_cluster is used to bootstrap new Galera Cluster,
+ when all the nodes are down. Run galera_new_cluster on the first node only.
+ On the remaining nodes simply run 'service @DAEMON_NAME@ start'.
+
+ For more information on Galera Cluster configuration and usage see:
+ https://mariadb.com/kb/en/mariadb/getting-started-with-mariadb-galera-cluster/
+
+EOF
+ exit 0
+fi
+
+systemctl set-environment _WSREP_NEW_CLUSTER='--wsrep-new-cluster' && \
+ systemctl start ${1:-mariadb}
+
+systemctl set-environment _WSREP_NEW_CLUSTER=''
diff --git a/scripts/galera_recovery.sh b/scripts/galera_recovery.sh
new file mode 100644
index 00000000000..c58f3d8f6b9
--- /dev/null
+++ b/scripts/galera_recovery.sh
@@ -0,0 +1,118 @@
+#!/bin/sh
+
+# Copyright (c) 2016 MariaDB Corporation
+#
+# 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; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
+
+
+# This script is intended to be executed by systemd. It starts mysqld with
+# --wsrep-recover to recover from a non-graceful shutdown, determines the
+# last stored global transaction ID and echoes it in --wsrep-start-position=XX
+# format. The output is then captured and used by systemd to start mysqld.
+# If the server was configured to start without wsrep, nothing is echoed.
+
+cmdline_args=$@
+user="@MYSQLD_USER@"
+print_defaults="@bindir@/my_print_defaults"
+log_file=$(mktemp /tmp/wsrep_recovery.XXXXXX)
+euid=$(id -u)
+recovered_pos=""
+skipped=""
+start_pos=""
+start_pos_opt=""
+ret=0
+wsrep_on=0
+
+log ()
+{
+ local msg="$1"
+ # Print all messages to stderr as we reserve stdout for printing
+ # --wsrep-start-position=XXXX.
+ echo "$msg" >&2
+}
+
+finish()
+{
+ rm -f "$log_file"
+}
+
+trap finish EXIT
+
+parse_arguments() {
+ for arg do
+ val=`echo "$arg" | sed -e "s;--[^=]*=;;"`
+ case "$arg" in
+ --wsrep[-_]on) wsrep_on=1 ;;
+ --skip[-_]wsrep[-_]on) wsrep_on=0 ;;
+ --wsrep[-_]on=*)
+ if echo $val | grep -iq '\(ON\|1\)'; then
+ wsrep_on=1
+ else
+ wsrep_on=0
+ fi
+ ;;
+ esac
+ done
+}
+
+wsrep_recover_position() {
+ # Redirect server's error log to the log file.
+ eval @sbindir@/mysqld $cmdline_args --user=$user --wsrep_recover \
+ --disable-log-error 2> "$log_file"
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ # Something went wrong, let us also print the error log so that it
+ # shows up in systemctl status output as a hint to the user.
+ log "WSREP: Failed to start mysqld for wsrep recovery: '`cat $log_file`'"
+ exit 1
+ fi
+
+ # Parse server's error log for recovered position. The server prints
+ # "..skipping position recovery.." if started without wsrep.
+
+ recovered_pos="$(grep 'WSREP: Recovered position:' $log_file)"
+
+ if [ -z "$recovered_pos" ]; then
+ skipped="$(grep WSREP $log_file | grep 'skipping position recovery')"
+ if [ -z "$skipped" ]; then
+ log "WSREP: Failed to recover position: '`cat $log_file`'"
+ exit 1
+ else
+ log "WSREP: Position recovery skipped."
+ fi
+ else
+ start_pos="$(echo $recovered_pos | sed 's/.*WSREP\:\ Recovered\ position://' \
+ | sed 's/^[ \t]*//')"
+ log "WSREP: Recovered position $start_pos"
+ start_pos_opt="--wsrep_start_position=$start_pos"
+ fi
+}
+
+# Safety checks
+if [ -n "$log_file" -a -f "$log_file" ]; then
+ [ "$euid" = "0" ] && chown $user $log_file
+ chmod 600 $log_file
+else
+ log "WSREP: mktemp failed"
+fi
+
+parse_arguments `$print_defaults $cmdline_args --loose-verbose --mysqld`
+
+# Perform wsrep position recovery if wsrep_on=1, skip otherwise.
+if [ "$wsrep_on" -eq 1 ]; then
+ wsrep_recover_position
+fi
+
+echo "$start_pos_opt"
+
diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh
deleted file mode 100644
index 663686ac1c8..00000000000
--- a/scripts/make_binary_distribution.sh
+++ /dev/null
@@ -1,386 +0,0 @@
-#!/bin/sh
-# Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
-#
-# 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; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-##############################################################################
-#
-# This is a script to create a TAR or ZIP binary distribution out of a
-# built source tree. The output file will be put at the top level of
-# the source tree, as "mysql-<vsn>....{tar.gz,zip}"
-#
-# Note that the structure created by this script is slightly different from
-# what a normal "make install" would produce. No extra "mysql" sub directory
-# will be created, i.e. no "$prefix/include/mysql", "$prefix/lib/mysql" or
-# "$prefix/share/mysql". This is because the build system explicitly calls
-# make with pkgdatadir=<datadir>, etc.
-#
-# In GNU make/automake terms
-#
-# "pkglibdir" is set to the same as "libdir"
-# "pkgincludedir" is set to the same as "includedir"
-# "pkgdatadir" is set to the same as "datadir"
-# "pkgplugindir" is set to "$pkglibdir/plugin"
-# "pkgsuppdir" is set to "@prefix@/support-files",
-# normally the same as "datadir"
-#
-# The temporary directory path given to "--tmp=<path>" has to be
-# absolute and with no spaces.
-#
-# Note that for best result, the original "make" should be done with
-# the same arguments as used for "make install" below, especially the
-# 'pkglibdir', as the RPATH should to be set correctly.
-#
-##############################################################################
-
-##############################################################################
-#
-# Read the command line arguments that control this script
-#
-##############################################################################
-
-machine=@MACHINE_TYPE@
-system=@SYSTEM_TYPE@
-SOURCE=`pwd`
-CP="cp -p"
-MV="mv"
-
-# There are platforms, notably OS X on Intel (x86 + x86_64),
-# for which "uname" does not provide sufficient information.
-# The value of CFLAGS as used during compilation is the most exact info
-# we can get - after all, we care about _what_ we built, not _where_ we did it.
-cflags="@CFLAGS@"
-
-STRIP=1 # Option ignored
-SILENT=0
-MALLOC_LIB=
-PLATFORM=""
-TMP=/tmp
-NEW_NAME="" # Final top directory and TAR package name
-SUFFIX=""
-SHORT_PRODUCT_TAG="" # If don't want server suffix in package name
-NDBCLUSTER="" # Option ignored
-
-for arg do
- case "$arg" in
- --tmp=*) TMP=`echo "$arg" | sed -e "s;--tmp=;;"` ;;
- --suffix=*) SUFFIX=`echo "$arg" | sed -e "s;--suffix=;;"` ;;
- --short-product-tag=*) SHORT_PRODUCT_TAG=`echo "$arg" | sed -e "s;--short-product-tag=;;"` ;;
- --inject-malloc-lib=*) MALLOC_LIB=`echo "$arg" | sed -e 's;^[^=]*=;;'` ;;
- --no-strip) STRIP=0 ;;
- --machine=*) machine=`echo "$arg" | sed -e "s;--machine=;;"` ;;
- --platform=*) PLATFORM=`echo "$arg" | sed -e "s;--platform=;;"` ;;
- --silent) SILENT=1 ;;
- --with-ndbcluster) NDBCLUSTER=1 ;;
- *)
- echo "Unknown argument '$arg'"
- exit 1
- ;;
- esac
-done
-
-# ----------------------------------------------------------------------
-# Adjust "system" output from "uname" to be more human readable
-# ----------------------------------------------------------------------
-
-if [ x"$PLATFORM" = x"" ] ; then
- # FIXME move this to the build tools
- # Remove vendor from $system
- system=`echo $system | sed -e 's/[a-z]*-\(.*\)/\1/g'`
-
- # Map OS names to "our" OS names (eg. darwin6.8 -> osx10.2)
- system=`echo $system | sed -e 's/darwin6.*/osx10.2/g'`
- system=`echo $system | sed -e 's/darwin7.*/osx10.3/g'`
- system=`echo $system | sed -e 's/darwin8.*/osx10.4/g'`
- system=`echo $system | sed -e 's/darwin9.*/osx10.5/g'`
- system=`echo $system | sed -e 's/\(aix4.3\).*/\1/g'`
- system=`echo $system | sed -e 's/\(aix5.1\).*/\1/g'`
- system=`echo $system | sed -e 's/\(aix5.2\).*/\1/g'`
- system=`echo $system | sed -e 's/\(aix5.3\).*/\1/g'`
- system=`echo $system | sed -e 's/osf5.1b/tru64/g'`
- system=`echo $system | sed -e 's/linux-gnu/linux/g'`
- system=`echo $system | sed -e 's/solaris2.\([0-9]*\)/solaris\1/g'`
- system=`echo $system | sed -e 's/sco3.2v\(.*\)/openserver\1/g'`
-fi
-
-# Get the "machine", which really is the CPU architecture (including the size).
-# The precedence is:
-# 1) use an explicit argument, if given;
-# 2) use platform-specific fixes, if there are any (see bug#37808);
-# 3) stay with the default (determined during "configure", using predefined macros).
-
-if [ x"$MACHINE" != x"" ] ; then
- machine=$MACHINE
-else
- case $system in
- osx* )
- # Extract "XYZ" from CFLAGS "... -arch XYZ ...", or empty!
- cflag_arch=`echo "$cflags" | sed -n -e 's=.* -arch \([^ ]*\) .*=\1=p'`
- case "$cflag_arch" in
- i386 ) case $system in
- osx10.4 ) machine=i686 ;; # Used a different naming
- * ) machine=x86 ;;
- esac ;;
- x86_64 ) machine=x86_64 ;;
- ppc ) ;; # No treatment needed with PPC
- ppc64 ) ;;
- * ) # No matching compiler flag? "--platform" is needed
- if [ x"$PLATFORM" != x"" ] ; then
- : # See below: "$PLATFORM" will take precedence anyway
- elif [ "$system" = "osx10.3" -a -z "$cflag_arch" ] ; then
- : # Special case of OS X 10.3, which is PPC-32 only and doesn't use "-arch"
- else
- echo "On system '$system' only specific '-arch' values are expected."
- echo "It is taken from the 'CFLAGS' whose value is:"
- echo "$cflags"
- echo "'-arch $cflag_arch' is unexpected, and no '--platform' was given: ABORT"
- exit 1
- fi ;;
- esac # "$cflag_arch"
- ;;
- esac # $system
-fi
-
-# Combine OS and CPU to the "platform". Again, an explicit argument takes precedence.
-if [ x"$PLATFORM" != x"" ] ; then
- :
-else
- PLATFORM="$system-$machine"
-fi
-
-# Print the platform name for build logs
-echo "PLATFORM NAME: $PLATFORM"
-
-# Change the distribution to a long descriptive name
-# For the cluster product, concentrate on the second part
-VERSION_NAME=@VERSION@
-case $VERSION_NAME in
- *-ndb-* ) VERSION_NAME=`echo $VERSION_NAME | sed -e 's/[.0-9]*-ndb-//'` ;;
- *-MariaDB-* ) VERSION_NAME=`echo $VERSION_NAME | sed -e 's/-MariaDB//'` ;;
-esac
-if [ x"$SHORT_PRODUCT_TAG" != x"" ] ; then
- NEW_NAME=mariadb-$SHORT_PRODUCT_TAG-$VERSION_NAME-$PLATFORM$SUFFIX
-else
- NEW_NAME=mariadb@MYSQL_SERVER_SUFFIX@-$VERSION_NAME-$PLATFORM$SUFFIX
-fi
-
-# ----------------------------------------------------------------------
-# Define BASE, and remove the old BASE directory if any
-# ----------------------------------------------------------------------
-BASE=$TMP/my_dist$SUFFIX
-if [ -d $BASE ] ; then
- rm -rf $BASE
-fi
-
-# ----------------------------------------------------------------------
-# Find the TAR to use
-# ----------------------------------------------------------------------
-
-# This is needed to prefer GNU tar over platform tar because that can't
-# always handle long filenames
-
-PATH_DIRS=`echo $PATH | \
- sed -e 's/^:/. /' -e 's/:$/ ./' -e 's/::/ . /g' -e 's/:/ /g' `
-
-which_1 ()
-{
- for cmd
- do
- for d in $PATH_DIRS
- do
- for file in $d/$cmd
- do
- if [ -x $file -a ! -d $file ] ; then
- echo $file
- exit 0
- fi
- done
- done
- done
- exit 1
-}
-
-tar=`which_1 gnutar gtar`
-if [ $? -ne 0 -o x"$tar" = x"" ] ; then
- tar=tar
-fi
-
-
-##############################################################################
-#
-# Handle the Unix/Linux packaging using "make install"
-#
-##############################################################################
-
-# ----------------------------------------------------------------------
-# Terminate on any base level error
-# ----------------------------------------------------------------------
-set -e
-
-#
-# Check that the client is compiled with libmysqlclient.a
-#
-if test -f ./client/.libs/mysql
-then
- echo ""
- echo "The MySQL clients are compiled dynamicly, which is not allowed for"
- echo "a MySQL binary tar file. Please configure with"
- echo "--with-client-ldflags=-all-static and try again"
- exit 1;
-fi
-
-# ----------------------------------------------------------------------
-# Really ugly, one script, "mysql_install_db", needs prefix set to ".",
-# i.e. makes access relative the current directory. This matches
-# the documentation, so better not change this. And for another script,
-# "mysql.server", we make some relative, others not.
-# ----------------------------------------------------------------------
-
-cd scripts
-rm -f mysql_install_db mysqld_safe mysql_fix_privilege_tables
-@MAKE@ mysql_install_db mysqld_safe mysql_fix_privilege_tables \
- prefix=. \
- bindir=./bin \
- sbindir=./bin \
- scriptdir=./bin \
- libexecdir=./bin \
- pkgdatadir=./share \
- localstatedir=./data
-cd ..
-
-cd support-files
-rm -f mysql.server
-@MAKE@ mysql.server \
- bindir=./bin \
- sbindir=./bin \
- scriptdir=./bin \
- libexecdir=./bin \
- pkgdatadir=./share
-cd ..
-
-# ----------------------------------------------------------------------
-# Do a install that we later are to pack. Use the same paths as in
-# the build for the relevant directories.
-# ----------------------------------------------------------------------
-@MAKE@ DESTDIR=$BASE install \
- libexecdir=@prefix@/libexec \
- pkglibdir=@pkglibdir@ \
- pkgincludedir=@pkgincludedir@ \
- pkgdatadir=@pkgdatadir@ \
- pkgplugindir=@pkgplugindir@ \
- pkgsuppdir=@pkgsuppdir@ \
- mandir=@mandir@ \
- infodir=@infodir@
-
-# ----------------------------------------------------------------------
-# Rename top directory, and set DEST to the new directory
-# ----------------------------------------------------------------------
-mv $BASE@prefix@ $BASE/$NEW_NAME
-DEST=$BASE/$NEW_NAME
-
-# ----------------------------------------------------------------------
-# If we compiled with gcc, copy libgcc.a to the dist as libmygcc.a
-# ----------------------------------------------------------------------
-if [ x"@GXX@" = x"yes" ] ; then
- gcclib=`@CC@ @CFLAGS@ --print-libgcc-file 2>/dev/null` || true
- if [ -z "$gcclib" ] ; then
- echo "Warning: Compiler doesn't tell libgcc.a!"
- elif [ -f "$gcclib" ] ; then
- $CP $gcclib $DEST/lib/libmygcc.a
- else
- echo "Warning: Compiler result '$gcclib' not found / no file!"
- fi
-fi
-
-# If requested, add a malloc library .so into pkglibdir for use
-# by mysqld_safe
-if [ -n "$MALLOC_LIB" ]; then
- cp "$MALLOC_LIB" "$DEST/lib/"
-fi
-
-# Note, no legacy "safe_mysqld" link to "mysqld_safe" in 5.1
-
-# Copy readme and license files
-cp README Docs/INSTALL-BINARY TODO CREDITS $DEST/
-if [ -f COPYING -a -f EXCEPTIONS-CLIENT ] ; then
- cp COPYING EXCEPTIONS-CLIENT $DEST/
-elif [ -f LICENSE.mysql ] ; then
- cp LICENSE.mysql $DEST/
-else
- echo "ERROR: no license files found"
- exit 1
-fi
-
-# FIXME should be handled by make file, and to other dir
-mkdir -p $DEST/bin $DEST/support-files
-cp scripts/mysqlaccess.conf $DEST/bin/
-cp support-files/magic $DEST/support-files/
-
-# Create empty data directories, set permission (FIXME why?)
-mkdir $DEST/data $DEST/data/mysql $DEST/data/test
-chmod o-rwx $DEST/data $DEST/data/mysql $DEST/data/test
-
-# Remove not needed files
-rm $DEST/share/mysql/errmsg.txt
-
-# Remove NDB files
-rm -f $DEST/share/mysql/ndb-config-2-node.ini \
- $DEST/share/mysql/config*
-
-#
-# Move things to make them easier to find in tar installation
-#
-
-# The following test is needed if the original configure was done with
-# something like --libexecdir=/usr/local/mysql/bin
-if test -f $DEST/libexec/mysqld
-then
- mv $DEST/libexec/* $DEST/bin
- rmdir $DEST/libexec
-fi
-mv $DEST/share/man $DEST
-mv $DEST/share/mysql/binary-configure $DEST/configure
-mv $DEST/share/mysql/*.sql $DEST/share
-mv $DEST/share/mysql/*.cnf $DEST/share/mysql/*.server $DEST/share/mysql/mysql-log-rotate $DEST/support-files
-
-#
-# Move some scripts that are only run once to 'scripts' directory
-# but add symbolic links instead to old place for compatibility
-#
-mkdir $DEST/scripts
-for i in mysql_secure_installation mysql_fix_extensions mysql_fix_privilege_tables mysql_install_db mytop
-do
- mv $DEST/bin/$i $DEST/scripts
- ln -s "../scripts/$i" $DEST/bin/$i
-done
-
-# ----------------------------------------------------------------------
-# Create the result tar file
-# ----------------------------------------------------------------------
-
-echo "Using $tar to create archive"
-OPT=cvf
-if [ x$SILENT = x1 ] ; then
- OPT=cf
-fi
-
-echo "Creating and compressing archive"
-rm -f $NEW_NAME.tar.gz
-(cd $BASE ; $tar $OPT - $NEW_NAME) | gzip -9 > $NEW_NAME.tar.gz
-echo "$NEW_NAME.tar.gz created"
-
-echo "Removing temporary directory"
-rm -rf $BASE
-exit 0
-
diff --git a/scripts/maria_add_gis_sp.sql.in b/scripts/maria_add_gis_sp.sql.in
new file mode 100644
index 00000000000..3a5dd49b95b
--- /dev/null
+++ b/scripts/maria_add_gis_sp.sql.in
@@ -0,0 +1,37 @@
+-- Copyright (C) 2014 MariaDB Ab.
+--
+-- 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; if not, write to the Free Software
+-- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+# This part creates stored procedures required by the OpenGIS standards.
+# script is prepared to be run with the --bootstrap server option
+
+SET sql_mode='';
+
+@ADD_GIS_SP_SET_DELIMITER@
+
+DROP PROCEDURE IF EXISTS AddGeometryColumn;
+DROP PROCEDURE IF EXISTS DropGeometryColumn;
+
+CREATE DEFINER=`root`@`localhost` PROCEDURE AddGeometryColumn(catalog varchar(64), t_schema varchar(64),
+ t_name varchar(64), geometry_column varchar(64), t_srid int)
+begin
+ set @qwe= concat('ALTER TABLE ', t_schema, '.', t_name, ' ADD ', geometry_column,' GEOMETRY REF_SYSTEM_ID=', t_srid); PREPARE ls from @qwe; execute ls; deallocate prepare ls; end @ADD_GIS_SP_EOL@
+
+CREATE DEFINER=`root`@`localhost` PROCEDURE DropGeometryColumn(catalog varchar(64), t_schema varchar(64),
+ t_name varchar(64), geometry_column varchar(64))
+begin
+ set @qwe= concat('ALTER TABLE ', t_schema, '.', t_name, ' DROP ', geometry_column); PREPARE ls from @qwe; execute ls; deallocate prepare ls; end @ADD_GIS_SP_EOL@
+
+@ADD_GIS_SP_RESET_DELIMITER@
+
diff --git a/scripts/mariadb-service-convert b/scripts/mariadb-service-convert
new file mode 100755
index 00000000000..83c92659144
--- /dev/null
+++ b/scripts/mariadb-service-convert
@@ -0,0 +1,82 @@
+#!/bin/bash
+# Copyright (c) 2015, Daniel Black. All rights reserved.
+#
+# 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; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# PURPOSE:
+#
+# Used to generate a mariadb.service file based on the current mysql/mariadb settings
+#
+# This is to assist distro maintainers in migrating to systemd service definations from
+# a user mysqld_safe settings in the my.cnf files.
+#
+# Redirect output to user directory like /etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf
+
+tz_old=$TZ
+
+. /usr/bin/mysqld_safe --dry-run
+
+echo "# converted using $0"
+echo "#"
+echo
+
+echo '[Service]'
+
+echo
+
+
+if [[ ( "$user" != "root" && "$user" != "mysql" ) || "${SET_USER}" == 1 ]]; then
+ echo User=$user
+fi
+
+
+[ -n "${open_files}" ] && echo LimitNOFILE=$open_files
+[ -n "${core_file_size}" ] && echo LimitCORE=$core_file_size
+[[ "${niceness}" -gt 0 ]] && echo Nice=$niceness
+[ "${TZ}" != "${tz_old}" ] && echo Environment=\"TZ=${TZ}\"
+
+if [ -n "$mysqld_ld_preload" ]; then
+ new_text="$mysqld_ld_preload"
+ [ -n "$LD_PRELOAD" ] && new_text="$new_text $LD_PRELOAD"
+ echo Environment=\"LD_PRELOAD=`shell_quote_string "$new_text"`\"
+fi
+
+if [ -n "$mysqld_ld_library_path" ]; then
+ new_text="$mysqld_ld_library_path"
+ [ -n "$LD_LIBRARY_PATH" ] && new_text="$new_text:$LD_LIBRARY_PATH"
+ echo Environment=\"LD_LIBRARY_PATH=`shell_quote_string "$new_text"`\"
+fi
+
+if [[ $want_syslog -eq 1 ]]; then
+ echo StandardOutput=syslog
+ echo StandardError=syslog
+ echo SyslogFacility=daemon
+ echo SyslogLevel=err
+ echo SyslogIdentifier=${syslog_tag_mysqld}
+fi
+
+if [[ "${flush_caches}" -gt 0 ]]; then
+ echo ExecStartPre=/usr/bin/sync
+ echo ExecStartPre=/usr/sbin/sysctl -q -w vm.drop_caches=3
+fi
+
+if [[ "${numa_interleave}" -gt 0 ]]; then
+ echo
+ echo ExecStart=/usr/bin/numactl --interleave=all ${cmd} '${MYSQLD_OPTS}'
+ echo
+fi
+
+if [ -n "${CRASH_SCRIPT}" ]; then
+ echo FailureAction=${CRASH_SCRIPT}
+fi
diff --git a/scripts/mysql_config.sh b/scripts/mysql_config.sh
index 47010ac087b..52f6d563fe5 100644
--- a/scripts/mysql_config.sh
+++ b/scripts/mysql_config.sh
@@ -15,7 +15,7 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# This script reports various configuration settings that may be needed
-# when using the MySQL client library.
+# when using the MariaDB client library.
which ()
{
@@ -39,7 +39,7 @@ which ()
#
# If we can find the given directory relatively to where mysql_config is
# we should use this instead of the incompiled one.
-# This is to ensure that this script also works with the binary MySQL
+# This is to ensure that this script also works with the binary MariaDB
# version
fix_path ()
@@ -97,7 +97,6 @@ fix_path pkgincludedir include/mysql
version='@VERSION@'
socket='@MYSQL_UNIX_ADDR@'
-ldflags='@LDFLAGS@'
if [ @MYSQL_TCP_PORT_DEFAULT@ -eq 0 ]; then
port=0
@@ -106,58 +105,14 @@ else
fi
# Create options
-# We intentionally add a space to the beginning and end of lib strings, simplifies replace later
-libs=" $ldflags -L$pkglibdir @RPATH_OPTION@ -lmysqlclient @ZLIB_DEPS@ @NON_THREADED_LIBS@"
-libs="$libs @openssl_libs@ @STATIC_NSS_FLAGS@ "
-libs_r=" $ldflags -L$pkglibdir @RPATH_OPTION@ -lmysqlclient_r @ZLIB_DEPS@ @CLIENT_LIBS@ @openssl_libs@ "
-embedded_libs=" $ldflags -L$pkglibdir @RPATH_OPTION@ -lmysqld @LIBDL@ @ZLIB_DEPS@ @LIBS@ @WRAPLIBS@ @openssl_libs@ "
-
-if [ -r "$pkglibdir/libmygcc.a" ]; then
- # When linking against the static library with a different version of GCC
- # from what was used to compile the library, some symbols may not be defined
- # automatically. We package the libmygcc.a from the build host, to provide
- # definitions for those. Bugs 4921, 19561, 19817, 21158, etc.
- libs="$libs -lmygcc "
- libs_r="$libs_r -lmygcc "
- embedded_libs="$embedded_libs -lmygcc "
-fi
+libs="-L$pkglibdir @RPATH_OPTION@ @LIBS_FOR_CLIENTS@"
+embedded_libs="-L$pkglibdir @RPATH_OPTION@ @EMB_LIBS_FOR_CLIENTS@"
include="-I$pkgincludedir"
if [ "$basedir" != "/usr" ]; then
include="$include -I$pkgincludedir/.."
fi
-cflags="$include @CFLAGS@ " #note: end space!
-
-# Remove some options that a client doesn't have to care about
-# FIXME until we have a --cxxflags, we need to remove -Xa
-# and -xstrconst to make --cflags usable for Sun Forte C++
-# FIXME until we have a --cxxflags, we need to remove -AC99
-# to make --cflags usable for HP C++ (aCC)
-for remove in DDBUG_OFF DSAFE_MUTEX DUNIV_MUST_NOT_INLINE DFORCE_INIT_OF_VARS \
- DEXTRA_DEBUG DHAVE_valgrind O 'O[0-9]' 'xO[0-9]' 'W[-A-Za-z]*' \
- 'mtune=[-A-Za-z0-9]*' 'mcpu=[-A-Za-z0-9]*' 'march=[-A-Za-z0-9]*' \
- Xa xstrconst "xc99=none" AC99 'W[-A-Za-z]*=[-A-Za-z0-9]*' \
- unroll2 ip mp restrict
-do
- # The first option we might strip will always have a space before it because
- # we set -I$pkgincludedir as the first option
- cflags=`echo "$cflags"|sed -e ':again' -e "s/ -$remove */ /g" -e 't again'`
-done
-cflags=`echo "$cflags"|sed -e 's/ *\$//'`
-
-# Same for --libs(_r)
-for remove in lmtmalloc static-libcxa i-static static-intel
-do
- # We know the strings starts with a space
- libs=`echo "$libs"|sed -e "s/ -$remove */ /g"`
- libs_r=`echo "$libs_r"|sed -e "s/ -$remove */ /g"`
- embedded_libs=`echo "$embedded_libs"|sed -e "s/ -$remove */ /g"`
-done
-
-# Strip trailing and ending space if any, and '+' (FIXME why?)
-libs=`echo "$libs" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
-libs_r=`echo "$libs_r" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
-embedded_libs=`echo "$embedded_libs" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
+cflags="$include @CFLAGS_FOR_CLIENTS@"
usage () {
cat <<EOF
@@ -166,7 +121,7 @@ Options:
--cflags [$cflags]
--include [$include]
--libs [$libs]
- --libs_r [$libs_r]
+ --libs_r [$libs]
--plugindir [$plugindir]
--socket [$socket]
--port [$port]
@@ -187,7 +142,7 @@ while test $# -gt 0; do
--cflags) echo "$cflags" ;;
--include) echo "$include" ;;
--libs) echo "$libs" ;;
- --libs_r) echo "$libs_r" ;;
+ --libs_r) echo "$libs" ;;
--plugindir) echo "$plugindir" ;;
--socket) echo "$socket" ;;
--port) echo "$port" ;;
diff --git a/scripts/mysql_convert_table_format.sh b/scripts/mysql_convert_table_format.sh
index 5042a742d55..8fe7e9b2276 100644
--- a/scripts/mysql_convert_table_format.sh
+++ b/scripts/mysql_convert_table_format.sh
@@ -124,7 +124,7 @@ sub usage
print <<EOF;
-Conversion of a MySQL tables to other storage engines
+Conversion of a MariaDB tables to other storage engines
Usage: $0 database [table[ table ...]]
If no tables has been specifed, all tables in the database will be converted.
diff --git a/scripts/mysql_find_rows.sh b/scripts/mysql_find_rows.sh
index 20c3e2c3106..4a9c3dbd41c 100644
--- a/scripts/mysql_find_rows.sh
+++ b/scripts/mysql_find_rows.sh
@@ -130,7 +130,7 @@ $0 Ver $version
Prints all SQL queries that matches a regexp or contains a 'use
database' or 'set ..' command to stdout. A SQL query may contain
-newlines. This is useful to find things in a MySQL update log.
+newlines. This is useful to find things in a MariaDB update log.
$0 takes the following options:
diff --git a/scripts/mysql_fix_extensions.sh b/scripts/mysql_fix_extensions.sh
index 7aa07209d4d..edc209589e8 100644
--- a/scripts/mysql_fix_extensions.sh
+++ b/scripts/mysql_fix_extensions.sh
@@ -17,10 +17,10 @@
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
# MA 02110-1301, USA
-# This is a utility for MySQL. It is not needed by any standard part
-# of MySQL.
+# This is a utility for MariaDB. It is not needed by any standard part
+# of MariaDB.
-# Usage: mysql_fix_extentions datadir
+# Usage: mysql_fix_extensions datadir
# does not work with RAID, with InnoDB or BDB tables
# makes .frm lowercase and .MYI/MYD/ISM/ISD uppercase
# useful when datafiles are copied from windows
diff --git a/scripts/mysql_install_db.pl.in b/scripts/mysql_install_db.pl.in
index 2103afc1e63..68d47fed2ea 100644
--- a/scripts/mysql_install_db.pl.in
+++ b/scripts/mysql_install_db.pl.in
@@ -297,17 +297,19 @@ parse_arguments($opt, 'PICK-ARGS-FROM-ARGV', @ARGV);
# ----------------------------------------------------------------------
# FIXME $extra_bindir is not used
-my ($bindir,$extra_bindir,$mysqld,$pkgdatadir,$mysqld_opt,$scriptdir);
+my ($bindir,$extra_bindir,$mysqld,$srcpkgdatadir,$buildpkgdatadir,$mysqld_opt,
+ $scriptdir);
if ( $opt->{srcdir} )
{
- $opt->{basedir} = $opt->{builddir};
- $bindir = "$opt->{basedir}/client";
- $extra_bindir = "$opt->{basedir}/extra";
- $mysqld = "$opt->{basedir}/sql/mysqld";
- $mysqld_opt = "--language=$opt->{srcdir}/sql/share/english";
- $pkgdatadir = "$opt->{srcdir}/scripts";
- $scriptdir = "$opt->{srcdir}/scripts";
+ $opt->{basedir} = $opt->{builddir};
+ $bindir = "$opt->{basedir}/client";
+ $extra_bindir = "$opt->{basedir}/extra";
+ $mysqld = "$opt->{basedir}/sql/mysqld";
+ $mysqld_opt = "--language=$opt->{srcdir}/sql/share/english";
+ $srcpkgdatadir = "$opt->{srcdir}/scripts";
+ $buildpkgdatadir = "$opt->{builddir}/scripts";
+ $scriptdir = "$opt->{srcdir}/scripts";
}
elsif ( $opt->{basedir} )
{
@@ -317,18 +319,20 @@ elsif ( $opt->{basedir} )
"libexec","sbin","bin") || # ,"sql"
find_in_basedir($opt,"file","mysqld-nt",
"bin"); # ,"sql"
- $pkgdatadir = find_in_basedir($opt,"dir","fill_help_tables.sql",
+ $srcpkgdatadir = find_in_basedir($opt,"dir","fill_help_tables.sql",
"share","share/mysql"); # ,"scripts"
+ $buildpkgdir = $srcpkgdatadir;
$scriptdir = "$opt->{basedir}/scripts";
}
else
{
- $opt->{basedir} = '@prefix@';
- $bindir = '@bindir@';
- $extra_bindir = $bindir;
- $mysqld = '@sbindir@/mysqld';
- $pkgdatadir = '@pkgdatadir@';
- $scriptdir = '@scriptdir@';
+ $opt->{basedir} = '@prefix@';
+ $bindir = '@bindir@';
+ $extra_bindir = $bindir;
+ $mysqld = '@sbindir@/mysqld';
+ $srcpkgdatadir = '@pkgdatadir@';
+ $buildpkgdatadir = '@pkgdatadir@';
+ $scriptdir = '@scriptdir@';
}
unless ( $opt->{ldata} )
@@ -336,20 +340,17 @@ unless ( $opt->{ldata} )
$opt->{ldata} = '@localstatedir@';
}
-if ( $opt->{srcdir} )
-{
- $pkgdatadir = "$opt->{srcdir}/scripts";
-}
# ----------------------------------------------------------------------
# Set up paths to SQL scripts required for bootstrap
# ----------------------------------------------------------------------
-my $fill_help_tables = "$pkgdatadir/fill_help_tables.sql";
-my $create_system_tables = "$pkgdatadir/mysql_system_tables.sql";
-my $fill_system_tables = "$pkgdatadir/mysql_system_tables_data.sql";
+my $fill_help_tables = "$srcpkgdatadir/fill_help_tables.sql";
+my $create_system_tables = "$srcpkgdatadir/mysql_system_tables.sql";
+my $fill_system_tables = "$srcpkgdatadir/mysql_system_tables_data.sql";
+my $maria_add_gis_sp = "$buildpkgdatadir/maria_add_gis_sp_bootstrap.sql";
-foreach my $f ( $fill_help_tables,$create_system_tables,$fill_system_tables )
+foreach my $f ( $fill_help_tables,$create_system_tables,$fill_system_tables,$maria_add_gis_sp )
{
-f $f or cannot_find_file($f);
}
@@ -427,6 +428,7 @@ my $mysqld_install_cmd_line = quote_options($mysqld_bootstrap,
"--max_allowed_packet=8M",
"--default-storage-engine=MyISAM",
"--net_buffer_length=16K",
+ "--enforce-storage-engine=\"\"",
@args,
);
@@ -496,6 +498,32 @@ if ( open(PIPE, "| $mysqld_install_cmd_line") )
"The \"HELP\" command might not work properly");
}
+ # ----------------------------------------------------------------------
+ # Pipe maria_add_gis_sp.sql to "mysqld --bootstrap"
+ # ----------------------------------------------------------------------
+
+ report_verbose_wait($opt,"Creating OpenGIS required SP-s...");
+ open(SQL, $maria_add_gis_sp)
+ or error($opt,"can't open $maria_add_gis_sp for reading: $!");
+ # FIXME > /dev/null ?
+ if ( open(PIPE, "| $mysqld_install_cmd_line") )
+ {
+ print PIPE "use mysql;\n";
+ while ( <SQL> )
+ {
+ print PIPE $_;
+ }
+ close PIPE;
+ close SQL;
+
+ report_verbose($opt,"OK");
+ }
+ else
+ {
+ warning($opt,"OPENGIS REQUIRED SP-S WERE NOT COMPLETELY INSTALLED!",
+ "GIS extentions might not work properly");
+ }
+
report_verbose($opt,"To start mysqld at boot time you have to copy",
"support-files/mysql.server to the right place " .
"for your system");
diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh
index 0c1dd7c724f..b89ea716aab 100644
--- a/scripts/mysql_install_db.sh
+++ b/scripts/mysql_install_db.sh
@@ -35,6 +35,9 @@ force=0
in_rpm=0
ip_only=0
cross_bootstrap=0
+install_params=""
+auth_root_authentication_method=normal
+auth_root_socket_user='root'
dirname0=`dirname $0 2>/dev/null`
dirname0=`dirname $dirname0 2>/dev/null`
@@ -43,6 +46,18 @@ usage()
{
cat <<EOF
Usage: $0 [OPTIONS]
+ --auth-root-authentication-method=normal|socket
+ Chooses the authentication method for the created initial
+ root user. The default is 'normal' to creates a root user
+ that can login without password, which can be insecure.
+ The alternative 'socket' allows only the system root user
+ to login as MariaDB root; this requires the unix socket
+ authentication plugin.
+ --auth-root-socket-user=user
+ Used with --auth-root-authentication-method=socket. It
+ specifies the name of the MariaDB root account, as well
+ as of the system account allowed to access it. Defaults
+ to 'root'.
--basedir=path The path to the MariaDB installation directory.
--builddir=path If using --srcdir with out-of-directory builds, you
will need to set this to the location of the build
@@ -66,6 +81,8 @@ Usage: $0 [OPTIONS]
--defaults-file=path Read only this configuration file.
--rpm For internal use. This option is used by RPM files
during the MariaDB installation process.
+ --skip-auth-anonymous-user
+ Do not install an unprivileged anonymous user.
--skip-name-resolve Use IP addresses rather than hostnames when creating
grant table entries. This option can be useful if
your DNS does not work.
@@ -150,6 +167,17 @@ parse_arguments()
#
# --windows is a deprecated alias
cross_bootstrap=1 ;;
+ --skip-auth-anonymous-user)
+ install_params="$install_params
+SET @skip_auth_anonymous=1;" ;;
+ --auth-root-authentication-method=normal)
+ auth_root_authentication_method=normal ;;
+ --auth-root-authentication-method=socket)
+ auth_root_authentication_method=socket ;;
+ --auth-root-authentication-method=*)
+ usage ;;
+ --auth-root-socket-user=*)
+ auth_root_socket_user="$(parse_arg "$arg")" ;;
*)
if test -n "$pick_args"
@@ -282,7 +310,8 @@ then
resolveip="$basedir/extra/resolveip"
mysqld="$basedir/sql/mysqld"
langdir="$basedir/sql/share/english"
- pkgdatadir="$srcdir/scripts"
+ srcpkgdatadir="$srcdir/scripts"
+ buildpkgdatadir="$builddir/scripts"
elif test -n "$basedir"
then
bindir="$basedir/bin" # only used in the help text
@@ -304,8 +333,9 @@ then
cannot_find_file errmsg.sys @errmsg_locations@
exit 1
fi
- pkgdatadir=`find_in_dirs --dir fill_help_tables.sql @pkgdata_locations@`
- if test -z "$pkgdatadir"
+ srcpkgdatadir=`find_in_dirs --dir fill_help_tables.sql @pkgdata_locations@`
+ buildpkgdatadir=$srcpkgdatadir
+ if test -z "$srcpkgdatadir"
then
cannot_find_file fill_help_tables.sql @pkgdata_locations@
exit 1
@@ -317,22 +347,25 @@ then
bindir="$basedir/@INSTALL_SBINDIR@"
resolveip="$bindir/resolveip"
mysqld="$basedir/@INSTALL_SBINDIR@/mysqld"
- pkgdatadir="$basedir/@INSTALL_MYSQLSHAREDIR@"
+ srcpkgdatadir="$basedir/@INSTALL_MYSQLSHAREDIR@"
+ buildpkgdatadir="$basedir/@INSTALL_MYSQLSHAREDIR@"
else
basedir="@prefix@"
bindir="@bindir@"
resolveip="$bindir/resolveip"
mysqld="@sbindir@/mysqld"
- pkgdatadir="@pkgdatadir@"
+ srcpkgdatadir="@pkgdatadir@"
+ buildpkgdatadir="@pkgdatadir@"
fi
# Set up paths to SQL scripts required for bootstrap
-fill_help_tables="$pkgdatadir/fill_help_tables.sql"
-create_system_tables="$pkgdatadir/mysql_system_tables.sql"
-create_system_tables2="$pkgdatadir/mysql_performance_tables.sql"
-fill_system_tables="$pkgdatadir/mysql_system_tables_data.sql"
+fill_help_tables="$srcpkgdatadir/fill_help_tables.sql"
+create_system_tables="$srcpkgdatadir/mysql_system_tables.sql"
+create_system_tables2="$srcpkgdatadir/mysql_performance_tables.sql"
+fill_system_tables="$srcpkgdatadir/mysql_system_tables_data.sql"
+maria_add_gis_sp="$buildpkgdatadir/maria_add_gis_sp_bootstrap.sql"
-for f in "$fill_help_tables" "$create_system_tables" "$create_system_tables2" "$fill_system_tables"
+for f in "$fill_help_tables" "$create_system_tables" "$create_system_tables2" "$fill_system_tables" "$maria_add_gis_sp"
do
if test ! -f "$f"
then
@@ -439,16 +472,26 @@ fi
mysqld_bootstrap="${MYSQLD_BOOTSTRAP-$mysqld}"
mysqld_install_cmd_line()
{
- "$mysqld_bootstrap" $defaults $defaults_group_suffix "$mysqld_opt" \
- --bootstrap "--basedir=$basedir" "--datadir=$ldata" --log-warnings=0 \
- --loose-skip-ndbcluster $args --max_allowed_packet=8M \
+ "$mysqld_bootstrap" $defaults $defaults_group_suffix "$mysqld_opt" --bootstrap \
+ "--basedir=$basedir" "--datadir=$ldata" --log-warnings=0 --enforce-storage-engine="" \
+ $args --max_allowed_packet=8M \
--net_buffer_length=16K
}
# Create the system and help tables by passing them to "mysqld --bootstrap"
s_echo "Installing MariaDB/MySQL system tables in '$ldata' ..."
-if { echo "use mysql;"; cat "$create_system_tables" "$create_system_tables2" "$fill_system_tables"; } | eval "$filter_cmd_line" | mysqld_install_cmd_line > /dev/null
+case "$auth_root_authentication_method" in
+ normal)
+ install_params="$install_params
+SET @skip_auth_root_nopasswd=NULL;
+SET @auth_root_socket=NULL;" ;;
+ socket)
+ install_params="$install_params
+SET @skip_auth_root_nopasswd=1;
+SET @auth_root_socket='$auth_root_socket_user';" ;;
+esac
+if { echo "use mysql;$install_params"; cat "$create_system_tables" "$create_system_tables2" "$fill_system_tables"; } | eval "$filter_cmd_line" | mysqld_install_cmd_line > /dev/null
then
s_echo "OK"
else
@@ -493,6 +536,17 @@ else
echo "The \"HELP\" command might not work properly."
fi
+s_echo "Creating OpenGIS required SP-s..."
+if { echo "use mysql;"; cat "$maria_add_gis_sp"; } | mysqld_install_cmd_line > /dev/null
+then
+ s_echo "OK"
+else
+ echo
+ echo "WARNING: OPENGIS REQUIRED SP-S WERE NOT COMPLETELY INSTALLED!"
+ echo "GIS extentions might not work properly."
+fi
+
+
# Don't output verbose information if running inside bootstrap or using
# --srcdir for testing. In such cases, there's no end user looking at
# the screen.
diff --git a/scripts/mysql_performance_tables.sql b/scripts/mysql_performance_tables.sql
index d4955782e4d..306160355de 100644
--- a/scripts/mysql_performance_tables.sql
+++ b/scripts/mysql_performance_tables.sql
@@ -53,1427 +53,3 @@ SET @str = IF(@broken_pfs = 0, @cmd, 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;
-
---
--- From this point, only create the performance schema tables
--- if the server is built with performance schema
---
-
-set @have_pfs= (select count(engine) from information_schema.engines where engine='PERFORMANCE_SCHEMA' and support != 'NO');
-
---
--- TABLE COND_INSTANCES
---
-
-SET @cmd="CREATE TABLE performance_schema.cond_instances("
- "NAME VARCHAR(128) not null,"
- "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE EVENTS_WAITS_CURRENT
---
-
-SET @cmd="CREATE TABLE performance_schema.events_waits_current("
- "THREAD_ID BIGINT unsigned not null,"
- "EVENT_ID BIGINT unsigned not null,"
- "END_EVENT_ID BIGINT unsigned,"
- "EVENT_NAME VARCHAR(128) not null,"
- "SOURCE VARCHAR(64),"
- "TIMER_START BIGINT unsigned,"
- "TIMER_END BIGINT unsigned,"
- "TIMER_WAIT BIGINT unsigned,"
- "SPINS INTEGER unsigned,"
- "OBJECT_SCHEMA VARCHAR(64),"
- "OBJECT_NAME VARCHAR(512),"
- "INDEX_NAME VARCHAR(64),"
- "OBJECT_TYPE VARCHAR(64),"
- "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null,"
- "NESTING_EVENT_ID BIGINT unsigned,"
- "NESTING_EVENT_TYPE ENUM('STATEMENT', 'STAGE', 'WAIT'),"
- "OPERATION VARCHAR(32) not null,"
- "NUMBER_OF_BYTES BIGINT,"
- "FLAGS INTEGER unsigned"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE EVENTS_WAITS_HISTORY
---
-
-SET @cmd="CREATE TABLE performance_schema.events_waits_history("
- "THREAD_ID BIGINT unsigned not null,"
- "EVENT_ID BIGINT unsigned not null,"
- "END_EVENT_ID BIGINT unsigned,"
- "EVENT_NAME VARCHAR(128) not null,"
- "SOURCE VARCHAR(64),"
- "TIMER_START BIGINT unsigned,"
- "TIMER_END BIGINT unsigned,"
- "TIMER_WAIT BIGINT unsigned,"
- "SPINS INTEGER unsigned,"
- "OBJECT_SCHEMA VARCHAR(64),"
- "OBJECT_NAME VARCHAR(512),"
- "INDEX_NAME VARCHAR(64),"
- "OBJECT_TYPE VARCHAR(64),"
- "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null,"
- "NESTING_EVENT_ID BIGINT unsigned,"
- "NESTING_EVENT_TYPE ENUM('STATEMENT', 'STAGE', 'WAIT'),"
- "OPERATION VARCHAR(32) not null,"
- "NUMBER_OF_BYTES BIGINT,"
- "FLAGS INTEGER unsigned"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE EVENTS_WAITS_HISTORY_LONG
---
-
-SET @cmd="CREATE TABLE performance_schema.events_waits_history_long("
- "THREAD_ID BIGINT unsigned not null,"
- "EVENT_ID BIGINT unsigned not null,"
- "END_EVENT_ID BIGINT unsigned,"
- "EVENT_NAME VARCHAR(128) not null,"
- "SOURCE VARCHAR(64),"
- "TIMER_START BIGINT unsigned,"
- "TIMER_END BIGINT unsigned,"
- "TIMER_WAIT BIGINT unsigned,"
- "SPINS INTEGER unsigned,"
- "OBJECT_SCHEMA VARCHAR(64),"
- "OBJECT_NAME VARCHAR(512),"
- "INDEX_NAME VARCHAR(64),"
- "OBJECT_TYPE VARCHAR(64),"
- "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null,"
- "NESTING_EVENT_ID BIGINT unsigned,"
- "NESTING_EVENT_TYPE ENUM('STATEMENT', 'STAGE', 'WAIT'),"
- "OPERATION VARCHAR(32) not null,"
- "NUMBER_OF_BYTES BIGINT,"
- "FLAGS INTEGER unsigned"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE EVENTS_WAITS_SUMMARY_BY_INSTANCE
---
-
-SET @cmd="CREATE TABLE performance_schema.events_waits_summary_by_instance("
- "EVENT_NAME VARCHAR(128) not null,"
- "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null,"
- "COUNT_STAR BIGINT unsigned not null,"
- "SUM_TIMER_WAIT BIGINT unsigned not null,"
- "MIN_TIMER_WAIT BIGINT unsigned not null,"
- "AVG_TIMER_WAIT BIGINT unsigned not null,"
- "MAX_TIMER_WAIT BIGINT unsigned not null"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE EVENTS_WAITS_SUMMARY_BY_HOST_BY_EVENT_NAME
---
-
-SET @cmd="CREATE TABLE performance_schema.events_waits_summary_by_host_by_event_name("
- "HOST CHAR(60) collate utf8_bin default null,"
- "EVENT_NAME VARCHAR(128) not null,"
- "COUNT_STAR BIGINT unsigned not null,"
- "SUM_TIMER_WAIT BIGINT unsigned not null,"
- "MIN_TIMER_WAIT BIGINT unsigned not null,"
- "AVG_TIMER_WAIT BIGINT unsigned not null,"
- "MAX_TIMER_WAIT BIGINT unsigned not null"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE EVENTS_WAITS_SUMMARY_BY_USER_BY_EVENT_NAME
---
-
-SET @cmd="CREATE TABLE performance_schema.events_waits_summary_by_user_by_event_name("
- "USER CHAR(16) collate utf8_bin default null,"
- "EVENT_NAME VARCHAR(128) not null,"
- "COUNT_STAR BIGINT unsigned not null,"
- "SUM_TIMER_WAIT BIGINT unsigned not null,"
- "MIN_TIMER_WAIT BIGINT unsigned not null,"
- "AVG_TIMER_WAIT BIGINT unsigned not null,"
- "MAX_TIMER_WAIT BIGINT unsigned not null"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE EVENTS_WAITS_SUMMARY_BY_ACCOUNT_BY_EVENT_NAME
---
-
-SET @cmd="CREATE TABLE performance_schema.events_waits_summary_by_account_by_event_name("
- "USER CHAR(16) collate utf8_bin default null,"
- "HOST CHAR(60) collate utf8_bin default null,"
- "EVENT_NAME VARCHAR(128) not null,"
- "COUNT_STAR BIGINT unsigned not null,"
- "SUM_TIMER_WAIT BIGINT unsigned not null,"
- "MIN_TIMER_WAIT BIGINT unsigned not null,"
- "AVG_TIMER_WAIT BIGINT unsigned not null,"
- "MAX_TIMER_WAIT BIGINT unsigned not null"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME
---
-
-SET @cmd="CREATE TABLE performance_schema.events_waits_summary_by_thread_by_event_name("
- "THREAD_ID BIGINT unsigned not null,"
- "EVENT_NAME VARCHAR(128) not null,"
- "COUNT_STAR BIGINT unsigned not null,"
- "SUM_TIMER_WAIT BIGINT unsigned not null,"
- "MIN_TIMER_WAIT BIGINT unsigned not null,"
- "AVG_TIMER_WAIT BIGINT unsigned not null,"
- "MAX_TIMER_WAIT BIGINT unsigned not null"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE EVENTS_WAITS_SUMMARY_GLOBAL_BY_EVENT_NAME
---
-
-SET @cmd="CREATE TABLE performance_schema.events_waits_summary_global_by_event_name("
- "EVENT_NAME VARCHAR(128) not null,"
- "COUNT_STAR BIGINT unsigned not null,"
- "SUM_TIMER_WAIT BIGINT unsigned not null,"
- "MIN_TIMER_WAIT BIGINT unsigned not null,"
- "AVG_TIMER_WAIT BIGINT unsigned not null,"
- "MAX_TIMER_WAIT BIGINT unsigned not null"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE FILE_INSTANCES
---
-
-SET @cmd="CREATE TABLE performance_schema.file_instances("
- "FILE_NAME VARCHAR(512) not null,"
- "EVENT_NAME VARCHAR(128) not null,"
- "OPEN_COUNT INTEGER unsigned not null"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE FILE_SUMMARY_BY_EVENT_NAME
---
-
-SET @cmd="CREATE TABLE performance_schema.file_summary_by_event_name("
- "EVENT_NAME VARCHAR(128) not null,"
- "COUNT_STAR BIGINT unsigned not null,"
- "SUM_TIMER_WAIT BIGINT unsigned not null,"
- "MIN_TIMER_WAIT BIGINT unsigned not null,"
- "AVG_TIMER_WAIT BIGINT unsigned not null,"
- "MAX_TIMER_WAIT BIGINT unsigned not null,"
- "COUNT_READ BIGINT unsigned not null,"
- "SUM_TIMER_READ BIGINT unsigned not null,"
- "MIN_TIMER_READ BIGINT unsigned not null,"
- "AVG_TIMER_READ BIGINT unsigned not null,"
- "MAX_TIMER_READ BIGINT unsigned not null,"
- "SUM_NUMBER_OF_BYTES_READ BIGINT not null,"
- "COUNT_WRITE BIGINT unsigned not null,"
- "SUM_TIMER_WRITE BIGINT unsigned not null,"
- "MIN_TIMER_WRITE BIGINT unsigned not null,"
- "AVG_TIMER_WRITE BIGINT unsigned not null,"
- "MAX_TIMER_WRITE BIGINT unsigned not null,"
- "SUM_NUMBER_OF_BYTES_WRITE BIGINT not null,"
- "COUNT_MISC BIGINT unsigned not null,"
- "SUM_TIMER_MISC BIGINT unsigned not null,"
- "MIN_TIMER_MISC BIGINT unsigned not null,"
- "AVG_TIMER_MISC BIGINT unsigned not null,"
- "MAX_TIMER_MISC BIGINT unsigned not null"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE FILE_SUMMARY_BY_INSTANCE
---
-
-SET @cmd="CREATE TABLE performance_schema.file_summary_by_instance("
- "FILE_NAME VARCHAR(512) not null,"
- "EVENT_NAME VARCHAR(128) not null,"
- "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null,"
- "COUNT_STAR BIGINT unsigned not null,"
- "SUM_TIMER_WAIT BIGINT unsigned not null,"
- "MIN_TIMER_WAIT BIGINT unsigned not null,"
- "AVG_TIMER_WAIT BIGINT unsigned not null,"
- "MAX_TIMER_WAIT BIGINT unsigned not null,"
- "COUNT_READ BIGINT unsigned not null,"
- "SUM_TIMER_READ BIGINT unsigned not null,"
- "MIN_TIMER_READ BIGINT unsigned not null,"
- "AVG_TIMER_READ BIGINT unsigned not null,"
- "MAX_TIMER_READ BIGINT unsigned not null,"
- "SUM_NUMBER_OF_BYTES_READ BIGINT not null,"
- "COUNT_WRITE BIGINT unsigned not null,"
- "SUM_TIMER_WRITE BIGINT unsigned not null,"
- "MIN_TIMER_WRITE BIGINT unsigned not null,"
- "AVG_TIMER_WRITE BIGINT unsigned not null,"
- "MAX_TIMER_WRITE BIGINT unsigned not null,"
- "SUM_NUMBER_OF_BYTES_WRITE BIGINT not null,"
- "COUNT_MISC BIGINT unsigned not null,"
- "SUM_TIMER_MISC BIGINT unsigned not null,"
- "MIN_TIMER_MISC BIGINT unsigned not null,"
- "AVG_TIMER_MISC BIGINT unsigned not null,"
- "MAX_TIMER_MISC BIGINT unsigned not null"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
-
---
--- TABLE SOCKET_INSTANCES
---
-
-SET @cmd="CREATE TABLE performance_schema.socket_instances("
- "EVENT_NAME VARCHAR(128) not null,"
- "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null,"
- "THREAD_ID BIGINT unsigned,"
- "SOCKET_ID INTEGER not null,"
- "IP VARCHAR(64) not null,"
- "PORT INTEGER not null,"
- "STATE ENUM('IDLE','ACTIVE') not null"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE SOCKET_SUMMARY_BY_INSTANCE
---
-
-SET @cmd="CREATE TABLE performance_schema.socket_summary_by_instance("
- "EVENT_NAME VARCHAR(128) not null,"
- "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null,"
- "COUNT_STAR BIGINT unsigned not null,"
- "SUM_TIMER_WAIT BIGINT unsigned not null,"
- "MIN_TIMER_WAIT BIGINT unsigned not null,"
- "AVG_TIMER_WAIT BIGINT unsigned not null,"
- "MAX_TIMER_WAIT BIGINT unsigned not null,"
- "COUNT_READ BIGINT unsigned not null,"
- "SUM_TIMER_READ BIGINT unsigned not null,"
- "MIN_TIMER_READ BIGINT unsigned not null,"
- "AVG_TIMER_READ BIGINT unsigned not null,"
- "MAX_TIMER_READ BIGINT unsigned not null,"
- "SUM_NUMBER_OF_BYTES_READ BIGINT unsigned not null,"
- "COUNT_WRITE BIGINT unsigned not null,"
- "SUM_TIMER_WRITE BIGINT unsigned not null,"
- "MIN_TIMER_WRITE BIGINT unsigned not null,"
- "AVG_TIMER_WRITE BIGINT unsigned not null,"
- "MAX_TIMER_WRITE BIGINT unsigned not null,"
- "SUM_NUMBER_OF_BYTES_WRITE BIGINT unsigned not null,"
- "COUNT_MISC BIGINT unsigned not null,"
- "SUM_TIMER_MISC BIGINT unsigned not null,"
- "MIN_TIMER_MISC BIGINT unsigned not null,"
- "AVG_TIMER_MISC BIGINT unsigned not null,"
- "MAX_TIMER_MISC BIGINT unsigned not null"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE SOCKET_SUMMARY_BY_INSTANCE
---
-
-SET @cmd="CREATE TABLE performance_schema.socket_summary_by_event_name("
- "EVENT_NAME VARCHAR(128) not null,"
- "COUNT_STAR BIGINT unsigned not null,"
- "SUM_TIMER_WAIT BIGINT unsigned not null,"
- "MIN_TIMER_WAIT BIGINT unsigned not null,"
- "AVG_TIMER_WAIT BIGINT unsigned not null,"
- "MAX_TIMER_WAIT BIGINT unsigned not null,"
- "COUNT_READ BIGINT unsigned not null,"
- "SUM_TIMER_READ BIGINT unsigned not null,"
- "MIN_TIMER_READ BIGINT unsigned not null,"
- "AVG_TIMER_READ BIGINT unsigned not null,"
- "MAX_TIMER_READ BIGINT unsigned not null,"
- "SUM_NUMBER_OF_BYTES_READ BIGINT unsigned not null,"
- "COUNT_WRITE BIGINT unsigned not null,"
- "SUM_TIMER_WRITE BIGINT unsigned not null,"
- "MIN_TIMER_WRITE BIGINT unsigned not null,"
- "AVG_TIMER_WRITE BIGINT unsigned not null,"
- "MAX_TIMER_WRITE BIGINT unsigned not null,"
- "SUM_NUMBER_OF_BYTES_WRITE BIGINT unsigned not null,"
- "COUNT_MISC BIGINT unsigned not null,"
- "SUM_TIMER_MISC BIGINT unsigned not null,"
- "MIN_TIMER_MISC BIGINT unsigned not null,"
- "AVG_TIMER_MISC BIGINT unsigned not null,"
- "MAX_TIMER_MISC BIGINT unsigned not null"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE HOST_CACHE
---
-
-SET @cmd="CREATE TABLE performance_schema.host_cache("
- "IP VARCHAR(64) not null,"
- "HOST VARCHAR(255) collate utf8_bin,"
- "HOST_VALIDATED ENUM ('YES', 'NO') not null,"
- "SUM_CONNECT_ERRORS BIGINT not null,"
- "COUNT_HOST_BLOCKED_ERRORS BIGINT not null,"
- "COUNT_NAMEINFO_TRANSIENT_ERRORS BIGINT not null,"
- "COUNT_NAMEINFO_PERMANENT_ERRORS BIGINT not null,"
- "COUNT_FORMAT_ERRORS BIGINT not null,"
- "COUNT_ADDRINFO_TRANSIENT_ERRORS BIGINT not null,"
- "COUNT_ADDRINFO_PERMANENT_ERRORS BIGINT not null,"
- "COUNT_FCRDNS_ERRORS BIGINT not null,"
- "COUNT_HOST_ACL_ERRORS BIGINT not null,"
- "COUNT_NO_AUTH_PLUGIN_ERRORS BIGINT not null,"
- "COUNT_AUTH_PLUGIN_ERRORS BIGINT not null,"
- "COUNT_HANDSHAKE_ERRORS BIGINT not null,"
- "COUNT_PROXY_USER_ERRORS BIGINT not null,"
- "COUNT_PROXY_USER_ACL_ERRORS BIGINT not null,"
- "COUNT_AUTHENTICATION_ERRORS BIGINT not null,"
- "COUNT_SSL_ERRORS BIGINT not null,"
- "COUNT_MAX_USER_CONNECTIONS_ERRORS BIGINT not null,"
- "COUNT_MAX_USER_CONNECTIONS_PER_HOUR_ERRORS BIGINT not null,"
- "COUNT_DEFAULT_DATABASE_ERRORS BIGINT not null,"
- "COUNT_INIT_CONNECT_ERRORS BIGINT not null,"
- "COUNT_LOCAL_ERRORS BIGINT not null,"
- "COUNT_UNKNOWN_ERRORS BIGINT not null,"
- "FIRST_SEEN TIMESTAMP(0) NOT NULL default 0,"
- "LAST_SEEN TIMESTAMP(0) NOT NULL default 0,"
- "FIRST_ERROR_SEEN TIMESTAMP(0) null default 0,"
- "LAST_ERROR_SEEN TIMESTAMP(0) null default 0"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE MUTEX_INSTANCES
---
-
-SET @cmd="CREATE TABLE performance_schema.mutex_instances("
- "NAME VARCHAR(128) not null,"
- "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null,"
- "LOCKED_BY_THREAD_ID BIGINT unsigned"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE OBJECTS_SUMMARY_GLOBAL_BY_TYPE
---
-
-SET @cmd="CREATE TABLE performance_schema.objects_summary_global_by_type("
- "OBJECT_TYPE VARCHAR(64),"
- "OBJECT_SCHEMA VARCHAR(64),"
- "OBJECT_NAME VARCHAR(64),"
- "COUNT_STAR BIGINT unsigned not null,"
- "SUM_TIMER_WAIT BIGINT unsigned not null,"
- "MIN_TIMER_WAIT BIGINT unsigned not null,"
- "AVG_TIMER_WAIT BIGINT unsigned not null,"
- "MAX_TIMER_WAIT BIGINT unsigned not null"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE PERFORMANCE_TIMERS
---
-
-SET @cmd="CREATE TABLE performance_schema.performance_timers("
- "TIMER_NAME ENUM ('CYCLE', 'NANOSECOND', 'MICROSECOND', 'MILLISECOND', 'TICK') not null,"
- "TIMER_FREQUENCY BIGINT,"
- "TIMER_RESOLUTION BIGINT,"
- "TIMER_OVERHEAD BIGINT"
- ") ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE RWLOCK_INSTANCES
---
-
-SET @cmd="CREATE TABLE performance_schema.rwlock_instances("
- "NAME VARCHAR(128) not null,"
- "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null,"
- "WRITE_LOCKED_BY_THREAD_ID BIGINT unsigned,"
- "READ_LOCKED_BY_COUNT INTEGER unsigned not null"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE SETUP_ACTORS
---
-
-SET @cmd="CREATE TABLE performance_schema.setup_actors("
- "HOST CHAR(60) collate utf8_bin default '%' not null,"
- "USER CHAR(16) collate utf8_bin default '%' not null,"
- "ROLE CHAR(16) collate utf8_bin default '%' not null"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE SETUP_CONSUMERS
---
-
-SET @cmd="CREATE TABLE performance_schema.setup_consumers("
- "NAME VARCHAR(64) not null,"
- "ENABLED ENUM ('YES', 'NO') not null"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE SETUP_INSTRUMENTS
---
-
-SET @cmd="CREATE TABLE performance_schema.setup_instruments("
- "NAME VARCHAR(128) not null,"
- "ENABLED ENUM ('YES', 'NO') not null,"
- "TIMED ENUM ('YES', 'NO') not null"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE SETUP_OBJECTS
---
-
-SET @cmd="CREATE TABLE performance_schema.setup_objects("
- "OBJECT_TYPE ENUM ('TABLE') not null default 'TABLE',"
- "OBJECT_SCHEMA VARCHAR(64) default '%',"
- "OBJECT_NAME VARCHAR(64) not null default '%',"
- "ENABLED ENUM ('YES', 'NO') not null default 'YES',"
- "TIMED ENUM ('YES', 'NO') not null default 'YES'"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE SETUP_TIMERS
---
-
-SET @cmd="CREATE TABLE performance_schema.setup_timers("
- "NAME VARCHAR(64) not null,"
- "TIMER_NAME ENUM ('CYCLE', 'NANOSECOND', 'MICROSECOND', 'MILLISECOND', 'TICK') not null"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE TABLE_IO_WAITS_SUMMARY_BY_INDEX_USAGE
---
-
-SET @cmd="CREATE TABLE performance_schema.table_io_waits_summary_by_index_usage("
- "OBJECT_TYPE VARCHAR(64),"
- "OBJECT_SCHEMA VARCHAR(64),"
- "OBJECT_NAME VARCHAR(64),"
- "INDEX_NAME VARCHAR(64),"
- "COUNT_STAR BIGINT unsigned not null,"
- "SUM_TIMER_WAIT BIGINT unsigned not null,"
- "MIN_TIMER_WAIT BIGINT unsigned not null,"
- "AVG_TIMER_WAIT BIGINT unsigned not null,"
- "MAX_TIMER_WAIT BIGINT unsigned not null,"
- "COUNT_READ BIGINT unsigned not null,"
- "SUM_TIMER_READ BIGINT unsigned not null,"
- "MIN_TIMER_READ BIGINT unsigned not null,"
- "AVG_TIMER_READ BIGINT unsigned not null,"
- "MAX_TIMER_READ BIGINT unsigned not null,"
- "COUNT_WRITE BIGINT unsigned not null,"
- "SUM_TIMER_WRITE BIGINT unsigned not null,"
- "MIN_TIMER_WRITE BIGINT unsigned not null,"
- "AVG_TIMER_WRITE BIGINT unsigned not null,"
- "MAX_TIMER_WRITE BIGINT unsigned not null,"
- "COUNT_FETCH BIGINT unsigned not null,"
- "SUM_TIMER_FETCH BIGINT unsigned not null,"
- "MIN_TIMER_FETCH BIGINT unsigned not null,"
- "AVG_TIMER_FETCH BIGINT unsigned not null,"
- "MAX_TIMER_FETCH BIGINT unsigned not null,"
- "COUNT_INSERT BIGINT unsigned not null,"
- "SUM_TIMER_INSERT BIGINT unsigned not null,"
- "MIN_TIMER_INSERT BIGINT unsigned not null,"
- "AVG_TIMER_INSERT BIGINT unsigned not null,"
- "MAX_TIMER_INSERT BIGINT unsigned not null,"
- "COUNT_UPDATE BIGINT unsigned not null,"
- "SUM_TIMER_UPDATE BIGINT unsigned not null,"
- "MIN_TIMER_UPDATE BIGINT unsigned not null,"
- "AVG_TIMER_UPDATE BIGINT unsigned not null,"
- "MAX_TIMER_UPDATE BIGINT unsigned not null,"
- "COUNT_DELETE BIGINT unsigned not null,"
- "SUM_TIMER_DELETE BIGINT unsigned not null,"
- "MIN_TIMER_DELETE BIGINT unsigned not null,"
- "AVG_TIMER_DELETE BIGINT unsigned not null,"
- "MAX_TIMER_DELETE BIGINT unsigned not null"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE TABLE_IO_WAITS_SUMMARY_BY_TABLE
---
-
-SET @cmd="CREATE TABLE performance_schema.table_io_waits_summary_by_table("
- "OBJECT_TYPE VARCHAR(64),"
- "OBJECT_SCHEMA VARCHAR(64),"
- "OBJECT_NAME VARCHAR(64),"
- "COUNT_STAR BIGINT unsigned not null,"
- "SUM_TIMER_WAIT BIGINT unsigned not null,"
- "MIN_TIMER_WAIT BIGINT unsigned not null,"
- "AVG_TIMER_WAIT BIGINT unsigned not null,"
- "MAX_TIMER_WAIT BIGINT unsigned not null,"
- "COUNT_READ BIGINT unsigned not null,"
- "SUM_TIMER_READ BIGINT unsigned not null,"
- "MIN_TIMER_READ BIGINT unsigned not null,"
- "AVG_TIMER_READ BIGINT unsigned not null,"
- "MAX_TIMER_READ BIGINT unsigned not null,"
- "COUNT_WRITE BIGINT unsigned not null,"
- "SUM_TIMER_WRITE BIGINT unsigned not null,"
- "MIN_TIMER_WRITE BIGINT unsigned not null,"
- "AVG_TIMER_WRITE BIGINT unsigned not null,"
- "MAX_TIMER_WRITE BIGINT unsigned not null,"
- "COUNT_FETCH BIGINT unsigned not null,"
- "SUM_TIMER_FETCH BIGINT unsigned not null,"
- "MIN_TIMER_FETCH BIGINT unsigned not null,"
- "AVG_TIMER_FETCH BIGINT unsigned not null,"
- "MAX_TIMER_FETCH BIGINT unsigned not null,"
- "COUNT_INSERT BIGINT unsigned not null,"
- "SUM_TIMER_INSERT BIGINT unsigned not null,"
- "MIN_TIMER_INSERT BIGINT unsigned not null,"
- "AVG_TIMER_INSERT BIGINT unsigned not null,"
- "MAX_TIMER_INSERT BIGINT unsigned not null,"
- "COUNT_UPDATE BIGINT unsigned not null,"
- "SUM_TIMER_UPDATE BIGINT unsigned not null,"
- "MIN_TIMER_UPDATE BIGINT unsigned not null,"
- "AVG_TIMER_UPDATE BIGINT unsigned not null,"
- "MAX_TIMER_UPDATE BIGINT unsigned not null,"
- "COUNT_DELETE BIGINT unsigned not null,"
- "SUM_TIMER_DELETE BIGINT unsigned not null,"
- "MIN_TIMER_DELETE BIGINT unsigned not null,"
- "AVG_TIMER_DELETE BIGINT unsigned not null,"
- "MAX_TIMER_DELETE BIGINT unsigned not null"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE TABLE_LOCK_WAITS_SUMMARY_BY_TABLE
---
-
-SET @cmd="CREATE TABLE performance_schema.table_lock_waits_summary_by_table("
- "OBJECT_TYPE VARCHAR(64),"
- "OBJECT_SCHEMA VARCHAR(64),"
- "OBJECT_NAME VARCHAR(64),"
- "COUNT_STAR BIGINT unsigned not null,"
- "SUM_TIMER_WAIT BIGINT unsigned not null,"
- "MIN_TIMER_WAIT BIGINT unsigned not null,"
- "AVG_TIMER_WAIT BIGINT unsigned not null,"
- "MAX_TIMER_WAIT BIGINT unsigned not null,"
- "COUNT_READ BIGINT unsigned not null,"
- "SUM_TIMER_READ BIGINT unsigned not null,"
- "MIN_TIMER_READ BIGINT unsigned not null,"
- "AVG_TIMER_READ BIGINT unsigned not null,"
- "MAX_TIMER_READ BIGINT unsigned not null,"
- "COUNT_WRITE BIGINT unsigned not null,"
- "SUM_TIMER_WRITE BIGINT unsigned not null,"
- "MIN_TIMER_WRITE BIGINT unsigned not null,"
- "AVG_TIMER_WRITE BIGINT unsigned not null,"
- "MAX_TIMER_WRITE BIGINT unsigned not null,"
- "COUNT_READ_NORMAL BIGINT unsigned not null,"
- "SUM_TIMER_READ_NORMAL BIGINT unsigned not null,"
- "MIN_TIMER_READ_NORMAL BIGINT unsigned not null,"
- "AVG_TIMER_READ_NORMAL BIGINT unsigned not null,"
- "MAX_TIMER_READ_NORMAL BIGINT unsigned not null,"
- "COUNT_READ_WITH_SHARED_LOCKS BIGINT unsigned not null,"
- "SUM_TIMER_READ_WITH_SHARED_LOCKS BIGINT unsigned not null,"
- "MIN_TIMER_READ_WITH_SHARED_LOCKS BIGINT unsigned not null,"
- "AVG_TIMER_READ_WITH_SHARED_LOCKS BIGINT unsigned not null,"
- "MAX_TIMER_READ_WITH_SHARED_LOCKS BIGINT unsigned not null,"
- "COUNT_READ_HIGH_PRIORITY BIGINT unsigned not null,"
- "SUM_TIMER_READ_HIGH_PRIORITY BIGINT unsigned not null,"
- "MIN_TIMER_READ_HIGH_PRIORITY BIGINT unsigned not null,"
- "AVG_TIMER_READ_HIGH_PRIORITY BIGINT unsigned not null,"
- "MAX_TIMER_READ_HIGH_PRIORITY BIGINT unsigned not null,"
- "COUNT_READ_NO_INSERT BIGINT unsigned not null,"
- "SUM_TIMER_READ_NO_INSERT BIGINT unsigned not null,"
- "MIN_TIMER_READ_NO_INSERT BIGINT unsigned not null,"
- "AVG_TIMER_READ_NO_INSERT BIGINT unsigned not null,"
- "MAX_TIMER_READ_NO_INSERT BIGINT unsigned not null,"
- "COUNT_READ_EXTERNAL BIGINT unsigned not null,"
- "SUM_TIMER_READ_EXTERNAL BIGINT unsigned not null,"
- "MIN_TIMER_READ_EXTERNAL BIGINT unsigned not null,"
- "AVG_TIMER_READ_EXTERNAL BIGINT unsigned not null,"
- "MAX_TIMER_READ_EXTERNAL BIGINT unsigned not null,"
- "COUNT_WRITE_ALLOW_WRITE BIGINT unsigned not null,"
- "SUM_TIMER_WRITE_ALLOW_WRITE BIGINT unsigned not null,"
- "MIN_TIMER_WRITE_ALLOW_WRITE BIGINT unsigned not null,"
- "AVG_TIMER_WRITE_ALLOW_WRITE BIGINT unsigned not null,"
- "MAX_TIMER_WRITE_ALLOW_WRITE BIGINT unsigned not null,"
- "COUNT_WRITE_CONCURRENT_INSERT BIGINT unsigned not null,"
- "SUM_TIMER_WRITE_CONCURRENT_INSERT BIGINT unsigned not null,"
- "MIN_TIMER_WRITE_CONCURRENT_INSERT BIGINT unsigned not null,"
- "AVG_TIMER_WRITE_CONCURRENT_INSERT BIGINT unsigned not null,"
- "MAX_TIMER_WRITE_CONCURRENT_INSERT BIGINT unsigned not null,"
- "COUNT_WRITE_DELAYED BIGINT unsigned not null,"
- "SUM_TIMER_WRITE_DELAYED BIGINT unsigned not null,"
- "MIN_TIMER_WRITE_DELAYED BIGINT unsigned not null,"
- "AVG_TIMER_WRITE_DELAYED BIGINT unsigned not null,"
- "MAX_TIMER_WRITE_DELAYED BIGINT unsigned not null,"
- "COUNT_WRITE_LOW_PRIORITY BIGINT unsigned not null,"
- "SUM_TIMER_WRITE_LOW_PRIORITY BIGINT unsigned not null,"
- "MIN_TIMER_WRITE_LOW_PRIORITY BIGINT unsigned not null,"
- "AVG_TIMER_WRITE_LOW_PRIORITY BIGINT unsigned not null,"
- "MAX_TIMER_WRITE_LOW_PRIORITY BIGINT unsigned not null,"
- "COUNT_WRITE_NORMAL BIGINT unsigned not null,"
- "SUM_TIMER_WRITE_NORMAL BIGINT unsigned not null,"
- "MIN_TIMER_WRITE_NORMAL BIGINT unsigned not null,"
- "AVG_TIMER_WRITE_NORMAL BIGINT unsigned not null,"
- "MAX_TIMER_WRITE_NORMAL BIGINT unsigned not null,"
- "COUNT_WRITE_EXTERNAL BIGINT unsigned not null,"
- "SUM_TIMER_WRITE_EXTERNAL BIGINT unsigned not null,"
- "MIN_TIMER_WRITE_EXTERNAL BIGINT unsigned not null,"
- "AVG_TIMER_WRITE_EXTERNAL BIGINT unsigned not null,"
- "MAX_TIMER_WRITE_EXTERNAL BIGINT unsigned not null"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE THREADS
---
-
-SET @cmd="CREATE TABLE performance_schema.threads("
- "THREAD_ID BIGINT unsigned not null,"
- "NAME VARCHAR(128) not null,"
- "TYPE VARCHAR(10) not null,"
- "PROCESSLIST_ID BIGINT unsigned,"
- "PROCESSLIST_USER VARCHAR(16),"
- "PROCESSLIST_HOST VARCHAR(60),"
- "PROCESSLIST_DB VARCHAR(64),"
- "PROCESSLIST_COMMAND VARCHAR(16),"
- "PROCESSLIST_TIME BIGINT,"
- "PROCESSLIST_STATE VARCHAR(64),"
- "PROCESSLIST_INFO LONGTEXT,"
- "PARENT_THREAD_ID BIGINT unsigned,"
- "ROLE VARCHAR(64),"
- "INSTRUMENTED ENUM ('YES', 'NO') not null"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE EVENTS_STAGES_CURRENT
---
-
-SET @cmd="CREATE TABLE performance_schema.events_stages_current("
- "THREAD_ID BIGINT unsigned not null,"
- "EVENT_ID BIGINT unsigned not null,"
- "END_EVENT_ID BIGINT unsigned,"
- "EVENT_NAME VARCHAR(128) not null,"
- "SOURCE VARCHAR(64),"
- "TIMER_START BIGINT unsigned,"
- "TIMER_END BIGINT unsigned,"
- "TIMER_WAIT BIGINT unsigned,"
- "NESTING_EVENT_ID BIGINT unsigned,"
- "NESTING_EVENT_TYPE ENUM('STATEMENT', 'STAGE', 'WAIT')"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE EVENTS_STAGES_HISTORY
---
-
-SET @cmd="CREATE TABLE performance_schema.events_stages_history("
- "THREAD_ID BIGINT unsigned not null,"
- "EVENT_ID BIGINT unsigned not null,"
- "END_EVENT_ID BIGINT unsigned,"
- "EVENT_NAME VARCHAR(128) not null,"
- "SOURCE VARCHAR(64),"
- "TIMER_START BIGINT unsigned,"
- "TIMER_END BIGINT unsigned,"
- "TIMER_WAIT BIGINT unsigned,"
- "NESTING_EVENT_ID BIGINT unsigned,"
- "NESTING_EVENT_TYPE ENUM('STATEMENT', 'STAGE', 'WAIT')"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE EVENTS_STAGES_HISTORY_LONG
---
-
-SET @cmd="CREATE TABLE performance_schema.events_stages_history_long("
- "THREAD_ID BIGINT unsigned not null,"
- "EVENT_ID BIGINT unsigned not null,"
- "END_EVENT_ID BIGINT unsigned,"
- "EVENT_NAME VARCHAR(128) not null,"
- "SOURCE VARCHAR(64),"
- "TIMER_START BIGINT unsigned,"
- "TIMER_END BIGINT unsigned,"
- "TIMER_WAIT BIGINT unsigned,"
- "NESTING_EVENT_ID BIGINT unsigned,"
- "NESTING_EVENT_TYPE ENUM('STATEMENT', 'STAGE', 'WAIT')"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE EVENTS_STAGES_SUMMARY_BY_THREAD_BY_EVENT_NAME
---
-
-SET @cmd="CREATE TABLE performance_schema.events_stages_summary_by_thread_by_event_name("
- "THREAD_ID BIGINT unsigned not null,"
- "EVENT_NAME VARCHAR(128) not null,"
- "COUNT_STAR BIGINT unsigned not null,"
- "SUM_TIMER_WAIT BIGINT unsigned not null,"
- "MIN_TIMER_WAIT BIGINT unsigned not null,"
- "AVG_TIMER_WAIT BIGINT unsigned not null,"
- "MAX_TIMER_WAIT BIGINT unsigned not null"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE EVENTS_STAGES_SUMMARY_BY_HOST_BY_EVENT_NAME
---
-
-SET @cmd="CREATE TABLE performance_schema.events_stages_summary_by_host_by_event_name("
- "HOST CHAR(60) collate utf8_bin default null,"
- "EVENT_NAME VARCHAR(128) not null,"
- "COUNT_STAR BIGINT unsigned not null,"
- "SUM_TIMER_WAIT BIGINT unsigned not null,"
- "MIN_TIMER_WAIT BIGINT unsigned not null,"
- "AVG_TIMER_WAIT BIGINT unsigned not null,"
- "MAX_TIMER_WAIT BIGINT unsigned not null"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE EVENTS_STAGES_SUMMARY_BY_USER_BY_EVENT_NAME
---
-
-SET @cmd="CREATE TABLE performance_schema.events_stages_summary_by_user_by_event_name("
- "USER CHAR(16) collate utf8_bin default null,"
- "EVENT_NAME VARCHAR(128) not null,"
- "COUNT_STAR BIGINT unsigned not null,"
- "SUM_TIMER_WAIT BIGINT unsigned not null,"
- "MIN_TIMER_WAIT BIGINT unsigned not null,"
- "AVG_TIMER_WAIT BIGINT unsigned not null,"
- "MAX_TIMER_WAIT BIGINT unsigned not null"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE EVENTS_STAGES_SUMMARY_BY_ACCOUNT_BY_EVENT_NAME
---
-
-SET @cmd="CREATE TABLE performance_schema.events_stages_summary_by_account_by_event_name("
- "USER CHAR(16) collate utf8_bin default null,"
- "HOST CHAR(60) collate utf8_bin default null,"
- "EVENT_NAME VARCHAR(128) not null,"
- "COUNT_STAR BIGINT unsigned not null,"
- "SUM_TIMER_WAIT BIGINT unsigned not null,"
- "MIN_TIMER_WAIT BIGINT unsigned not null,"
- "AVG_TIMER_WAIT BIGINT unsigned not null,"
- "MAX_TIMER_WAIT BIGINT unsigned not null"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE EVENTS_STAGES_SUMMARY_GLOBAL_BY_EVENT_NAME
---
-
-SET @cmd="CREATE TABLE performance_schema.events_stages_summary_global_by_event_name("
- "EVENT_NAME VARCHAR(128) not null,"
- "COUNT_STAR BIGINT unsigned not null,"
- "SUM_TIMER_WAIT BIGINT unsigned not null,"
- "MIN_TIMER_WAIT BIGINT unsigned not null,"
- "AVG_TIMER_WAIT BIGINT unsigned not null,"
- "MAX_TIMER_WAIT BIGINT unsigned not null"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE EVENTS_STATEMENTS_CURRENT
---
-
-SET @cmd="CREATE TABLE performance_schema.events_statements_current("
- "THREAD_ID BIGINT unsigned not null,"
- "EVENT_ID BIGINT unsigned not null,"
- "END_EVENT_ID BIGINT unsigned,"
- "EVENT_NAME VARCHAR(128) not null,"
- "SOURCE VARCHAR(64),"
- "TIMER_START BIGINT unsigned,"
- "TIMER_END BIGINT unsigned,"
- "TIMER_WAIT BIGINT unsigned,"
- "LOCK_TIME bigint unsigned not null,"
- "SQL_TEXT LONGTEXT,"
- "DIGEST VARCHAR(32),"
- "DIGEST_TEXT LONGTEXT,"
- "CURRENT_SCHEMA VARCHAR(64),"
- "OBJECT_TYPE VARCHAR(64),"
- "OBJECT_SCHEMA VARCHAR(64),"
- "OBJECT_NAME VARCHAR(64),"
- "OBJECT_INSTANCE_BEGIN BIGINT unsigned,"
- "MYSQL_ERRNO INTEGER,"
- "RETURNED_SQLSTATE VARCHAR(5),"
- "MESSAGE_TEXT VARCHAR(128),"
- "ERRORS BIGINT unsigned not null,"
- "WARNINGS BIGINT unsigned not null,"
- "ROWS_AFFECTED BIGINT unsigned not null,"
- "ROWS_SENT BIGINT unsigned not null,"
- "ROWS_EXAMINED BIGINT unsigned not null,"
- "CREATED_TMP_DISK_TABLES BIGINT unsigned not null,"
- "CREATED_TMP_TABLES BIGINT unsigned not null,"
- "SELECT_FULL_JOIN BIGINT unsigned not null,"
- "SELECT_FULL_RANGE_JOIN BIGINT unsigned not null,"
- "SELECT_RANGE BIGINT unsigned not null,"
- "SELECT_RANGE_CHECK BIGINT unsigned not null,"
- "SELECT_SCAN BIGINT unsigned not null,"
- "SORT_MERGE_PASSES BIGINT unsigned not null,"
- "SORT_RANGE BIGINT unsigned not null,"
- "SORT_ROWS BIGINT unsigned not null,"
- "SORT_SCAN BIGINT unsigned not null,"
- "NO_INDEX_USED BIGINT unsigned not null,"
- "NO_GOOD_INDEX_USED BIGINT unsigned not null,"
- "NESTING_EVENT_ID BIGINT unsigned,"
- "NESTING_EVENT_TYPE ENUM('STATEMENT', 'STAGE', 'WAIT')"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE EVENTS_STATEMENTS_HISTORY
---
-
-SET @cmd="CREATE TABLE performance_schema.events_statements_history("
- "THREAD_ID BIGINT unsigned not null,"
- "EVENT_ID BIGINT unsigned not null,"
- "END_EVENT_ID BIGINT unsigned,"
- "EVENT_NAME VARCHAR(128) not null,"
- "SOURCE VARCHAR(64),"
- "TIMER_START BIGINT unsigned,"
- "TIMER_END BIGINT unsigned,"
- "TIMER_WAIT BIGINT unsigned,"
- "LOCK_TIME bigint unsigned not null,"
- "SQL_TEXT LONGTEXT,"
- "DIGEST VARCHAR(32),"
- "DIGEST_TEXT LONGTEXT,"
- "CURRENT_SCHEMA VARCHAR(64),"
- "OBJECT_TYPE VARCHAR(64),"
- "OBJECT_SCHEMA VARCHAR(64),"
- "OBJECT_NAME VARCHAR(64),"
- "OBJECT_INSTANCE_BEGIN BIGINT unsigned,"
- "MYSQL_ERRNO INTEGER,"
- "RETURNED_SQLSTATE VARCHAR(5),"
- "MESSAGE_TEXT VARCHAR(128),"
- "ERRORS BIGINT unsigned not null,"
- "WARNINGS BIGINT unsigned not null,"
- "ROWS_AFFECTED BIGINT unsigned not null,"
- "ROWS_SENT BIGINT unsigned not null,"
- "ROWS_EXAMINED BIGINT unsigned not null,"
- "CREATED_TMP_DISK_TABLES BIGINT unsigned not null,"
- "CREATED_TMP_TABLES BIGINT unsigned not null,"
- "SELECT_FULL_JOIN BIGINT unsigned not null,"
- "SELECT_FULL_RANGE_JOIN BIGINT unsigned not null,"
- "SELECT_RANGE BIGINT unsigned not null,"
- "SELECT_RANGE_CHECK BIGINT unsigned not null,"
- "SELECT_SCAN BIGINT unsigned not null,"
- "SORT_MERGE_PASSES BIGINT unsigned not null,"
- "SORT_RANGE BIGINT unsigned not null,"
- "SORT_ROWS BIGINT unsigned not null,"
- "SORT_SCAN BIGINT unsigned not null,"
- "NO_INDEX_USED BIGINT unsigned not null,"
- "NO_GOOD_INDEX_USED BIGINT unsigned not null,"
- "NESTING_EVENT_ID BIGINT unsigned,"
- "NESTING_EVENT_TYPE ENUM('STATEMENT', 'STAGE', 'WAIT')"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE EVENTS_STATEMENTS_HISTORY_LONG
---
-
-SET @cmd="CREATE TABLE performance_schema.events_statements_history_long("
- "THREAD_ID BIGINT unsigned not null,"
- "EVENT_ID BIGINT unsigned not null,"
- "END_EVENT_ID BIGINT unsigned,"
- "EVENT_NAME VARCHAR(128) not null,"
- "SOURCE VARCHAR(64),"
- "TIMER_START BIGINT unsigned,"
- "TIMER_END BIGINT unsigned,"
- "TIMER_WAIT BIGINT unsigned,"
- "LOCK_TIME bigint unsigned not null,"
- "SQL_TEXT LONGTEXT,"
- "DIGEST VARCHAR(32),"
- "DIGEST_TEXT LONGTEXT,"
- "CURRENT_SCHEMA VARCHAR(64),"
- "OBJECT_TYPE VARCHAR(64),"
- "OBJECT_SCHEMA VARCHAR(64),"
- "OBJECT_NAME VARCHAR(64),"
- "OBJECT_INSTANCE_BEGIN BIGINT unsigned,"
- "MYSQL_ERRNO INTEGER,"
- "RETURNED_SQLSTATE VARCHAR(5),"
- "MESSAGE_TEXT VARCHAR(128),"
- "ERRORS BIGINT unsigned not null,"
- "WARNINGS BIGINT unsigned not null,"
- "ROWS_AFFECTED BIGINT unsigned not null,"
- "ROWS_SENT BIGINT unsigned not null,"
- "ROWS_EXAMINED BIGINT unsigned not null,"
- "CREATED_TMP_DISK_TABLES BIGINT unsigned not null,"
- "CREATED_TMP_TABLES BIGINT unsigned not null,"
- "SELECT_FULL_JOIN BIGINT unsigned not null,"
- "SELECT_FULL_RANGE_JOIN BIGINT unsigned not null,"
- "SELECT_RANGE BIGINT unsigned not null,"
- "SELECT_RANGE_CHECK BIGINT unsigned not null,"
- "SELECT_SCAN BIGINT unsigned not null,"
- "SORT_MERGE_PASSES BIGINT unsigned not null,"
- "SORT_RANGE BIGINT unsigned not null,"
- "SORT_ROWS BIGINT unsigned not null,"
- "SORT_SCAN BIGINT unsigned not null,"
- "NO_INDEX_USED BIGINT unsigned not null,"
- "NO_GOOD_INDEX_USED BIGINT unsigned not null,"
- "NESTING_EVENT_ID BIGINT unsigned,"
- "NESTING_EVENT_TYPE ENUM('STATEMENT', 'STAGE', 'WAIT')"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE EVENTS_STATEMENTS_SUMMARY_BY_THREAD_BY_EVENT_NAME
---
-
-SET @cmd="CREATE TABLE performance_schema.events_statements_summary_by_thread_by_event_name("
- "THREAD_ID BIGINT unsigned not null,"
- "EVENT_NAME VARCHAR(128) not null,"
- "COUNT_STAR BIGINT unsigned not null,"
- "SUM_TIMER_WAIT BIGINT unsigned not null,"
- "MIN_TIMER_WAIT BIGINT unsigned not null,"
- "AVG_TIMER_WAIT BIGINT unsigned not null,"
- "MAX_TIMER_WAIT BIGINT unsigned not null,"
- "SUM_LOCK_TIME BIGINT unsigned not null,"
- "SUM_ERRORS BIGINT unsigned not null,"
- "SUM_WARNINGS BIGINT unsigned not null,"
- "SUM_ROWS_AFFECTED BIGINT unsigned not null,"
- "SUM_ROWS_SENT BIGINT unsigned not null,"
- "SUM_ROWS_EXAMINED BIGINT unsigned not null,"
- "SUM_CREATED_TMP_DISK_TABLES BIGINT unsigned not null,"
- "SUM_CREATED_TMP_TABLES BIGINT unsigned not null,"
- "SUM_SELECT_FULL_JOIN BIGINT unsigned not null,"
- "SUM_SELECT_FULL_RANGE_JOIN BIGINT unsigned not null,"
- "SUM_SELECT_RANGE BIGINT unsigned not null,"
- "SUM_SELECT_RANGE_CHECK BIGINT unsigned not null,"
- "SUM_SELECT_SCAN BIGINT unsigned not null,"
- "SUM_SORT_MERGE_PASSES BIGINT unsigned not null,"
- "SUM_SORT_RANGE BIGINT unsigned not null,"
- "SUM_SORT_ROWS BIGINT unsigned not null,"
- "SUM_SORT_SCAN BIGINT unsigned not null,"
- "SUM_NO_INDEX_USED BIGINT unsigned not null,"
- "SUM_NO_GOOD_INDEX_USED BIGINT unsigned not null"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE EVENTS_STATEMENTS_SUMMARY_BY_HOST_BY_EVENT_NAME
---
-
-SET @cmd="CREATE TABLE performance_schema.events_statements_summary_by_host_by_event_name("
- "HOST CHAR(60) collate utf8_bin default null,"
- "EVENT_NAME VARCHAR(128) not null,"
- "COUNT_STAR BIGINT unsigned not null,"
- "SUM_TIMER_WAIT BIGINT unsigned not null,"
- "MIN_TIMER_WAIT BIGINT unsigned not null,"
- "AVG_TIMER_WAIT BIGINT unsigned not null,"
- "MAX_TIMER_WAIT BIGINT unsigned not null,"
- "SUM_LOCK_TIME BIGINT unsigned not null,"
- "SUM_ERRORS BIGINT unsigned not null,"
- "SUM_WARNINGS BIGINT unsigned not null,"
- "SUM_ROWS_AFFECTED BIGINT unsigned not null,"
- "SUM_ROWS_SENT BIGINT unsigned not null,"
- "SUM_ROWS_EXAMINED BIGINT unsigned not null,"
- "SUM_CREATED_TMP_DISK_TABLES BIGINT unsigned not null,"
- "SUM_CREATED_TMP_TABLES BIGINT unsigned not null,"
- "SUM_SELECT_FULL_JOIN BIGINT unsigned not null,"
- "SUM_SELECT_FULL_RANGE_JOIN BIGINT unsigned not null,"
- "SUM_SELECT_RANGE BIGINT unsigned not null,"
- "SUM_SELECT_RANGE_CHECK BIGINT unsigned not null,"
- "SUM_SELECT_SCAN BIGINT unsigned not null,"
- "SUM_SORT_MERGE_PASSES BIGINT unsigned not null,"
- "SUM_SORT_RANGE BIGINT unsigned not null,"
- "SUM_SORT_ROWS BIGINT unsigned not null,"
- "SUM_SORT_SCAN BIGINT unsigned not null,"
- "SUM_NO_INDEX_USED BIGINT unsigned not null,"
- "SUM_NO_GOOD_INDEX_USED BIGINT unsigned not null"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE EVENTS_STATEMENTS_SUMMARY_BY_USER_BY_EVENT_NAME
---
-
-SET @cmd="CREATE TABLE performance_schema.events_statements_summary_by_user_by_event_name("
- "USER CHAR(16) collate utf8_bin default null,"
- "EVENT_NAME VARCHAR(128) not null,"
- "COUNT_STAR BIGINT unsigned not null,"
- "SUM_TIMER_WAIT BIGINT unsigned not null,"
- "MIN_TIMER_WAIT BIGINT unsigned not null,"
- "AVG_TIMER_WAIT BIGINT unsigned not null,"
- "MAX_TIMER_WAIT BIGINT unsigned not null,"
- "SUM_LOCK_TIME BIGINT unsigned not null,"
- "SUM_ERRORS BIGINT unsigned not null,"
- "SUM_WARNINGS BIGINT unsigned not null,"
- "SUM_ROWS_AFFECTED BIGINT unsigned not null,"
- "SUM_ROWS_SENT BIGINT unsigned not null,"
- "SUM_ROWS_EXAMINED BIGINT unsigned not null,"
- "SUM_CREATED_TMP_DISK_TABLES BIGINT unsigned not null,"
- "SUM_CREATED_TMP_TABLES BIGINT unsigned not null,"
- "SUM_SELECT_FULL_JOIN BIGINT unsigned not null,"
- "SUM_SELECT_FULL_RANGE_JOIN BIGINT unsigned not null,"
- "SUM_SELECT_RANGE BIGINT unsigned not null,"
- "SUM_SELECT_RANGE_CHECK BIGINT unsigned not null,"
- "SUM_SELECT_SCAN BIGINT unsigned not null,"
- "SUM_SORT_MERGE_PASSES BIGINT unsigned not null,"
- "SUM_SORT_RANGE BIGINT unsigned not null,"
- "SUM_SORT_ROWS BIGINT unsigned not null,"
- "SUM_SORT_SCAN BIGINT unsigned not null,"
- "SUM_NO_INDEX_USED BIGINT unsigned not null,"
- "SUM_NO_GOOD_INDEX_USED BIGINT unsigned not null"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE EVENTS_STATEMENTS_SUMMARY_BY_ACCOUNT_BY_EVENT_NAME
---
-
-SET @cmd="CREATE TABLE performance_schema.events_statements_summary_by_account_by_event_name("
- "USER CHAR(16) collate utf8_bin default null,"
- "HOST CHAR(60) collate utf8_bin default null,"
- "EVENT_NAME VARCHAR(128) not null,"
- "COUNT_STAR BIGINT unsigned not null,"
- "SUM_TIMER_WAIT BIGINT unsigned not null,"
- "MIN_TIMER_WAIT BIGINT unsigned not null,"
- "AVG_TIMER_WAIT BIGINT unsigned not null,"
- "MAX_TIMER_WAIT BIGINT unsigned not null,"
- "SUM_LOCK_TIME BIGINT unsigned not null,"
- "SUM_ERRORS BIGINT unsigned not null,"
- "SUM_WARNINGS BIGINT unsigned not null,"
- "SUM_ROWS_AFFECTED BIGINT unsigned not null,"
- "SUM_ROWS_SENT BIGINT unsigned not null,"
- "SUM_ROWS_EXAMINED BIGINT unsigned not null,"
- "SUM_CREATED_TMP_DISK_TABLES BIGINT unsigned not null,"
- "SUM_CREATED_TMP_TABLES BIGINT unsigned not null,"
- "SUM_SELECT_FULL_JOIN BIGINT unsigned not null,"
- "SUM_SELECT_FULL_RANGE_JOIN BIGINT unsigned not null,"
- "SUM_SELECT_RANGE BIGINT unsigned not null,"
- "SUM_SELECT_RANGE_CHECK BIGINT unsigned not null,"
- "SUM_SELECT_SCAN BIGINT unsigned not null,"
- "SUM_SORT_MERGE_PASSES BIGINT unsigned not null,"
- "SUM_SORT_RANGE BIGINT unsigned not null,"
- "SUM_SORT_ROWS BIGINT unsigned not null,"
- "SUM_SORT_SCAN BIGINT unsigned not null,"
- "SUM_NO_INDEX_USED BIGINT unsigned not null,"
- "SUM_NO_GOOD_INDEX_USED BIGINT unsigned not null"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE EVENTS_STATEMENTS_SUMMARY_GLOBAL_BY_EVENT_NAME
---
-
-SET @cmd="CREATE TABLE performance_schema.events_statements_summary_global_by_event_name("
- "EVENT_NAME VARCHAR(128) not null,"
- "COUNT_STAR BIGINT unsigned not null,"
- "SUM_TIMER_WAIT BIGINT unsigned not null,"
- "MIN_TIMER_WAIT BIGINT unsigned not null,"
- "AVG_TIMER_WAIT BIGINT unsigned not null,"
- "MAX_TIMER_WAIT BIGINT unsigned not null,"
- "SUM_LOCK_TIME BIGINT unsigned not null,"
- "SUM_ERRORS BIGINT unsigned not null,"
- "SUM_WARNINGS BIGINT unsigned not null,"
- "SUM_ROWS_AFFECTED BIGINT unsigned not null,"
- "SUM_ROWS_SENT BIGINT unsigned not null,"
- "SUM_ROWS_EXAMINED BIGINT unsigned not null,"
- "SUM_CREATED_TMP_DISK_TABLES BIGINT unsigned not null,"
- "SUM_CREATED_TMP_TABLES BIGINT unsigned not null,"
- "SUM_SELECT_FULL_JOIN BIGINT unsigned not null,"
- "SUM_SELECT_FULL_RANGE_JOIN BIGINT unsigned not null,"
- "SUM_SELECT_RANGE BIGINT unsigned not null,"
- "SUM_SELECT_RANGE_CHECK BIGINT unsigned not null,"
- "SUM_SELECT_SCAN BIGINT unsigned not null,"
- "SUM_SORT_MERGE_PASSES BIGINT unsigned not null,"
- "SUM_SORT_RANGE BIGINT unsigned not null,"
- "SUM_SORT_ROWS BIGINT unsigned not null,"
- "SUM_SORT_SCAN BIGINT unsigned not null,"
- "SUM_NO_INDEX_USED BIGINT unsigned not null,"
- "SUM_NO_GOOD_INDEX_USED BIGINT unsigned not null"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE HOSTS
---
-
-SET @cmd="CREATE TABLE performance_schema.hosts("
- "HOST CHAR(60) collate utf8_bin default null,"
- "CURRENT_CONNECTIONS bigint not null,"
- "TOTAL_CONNECTIONS bigint not null"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE USERS
---
-
-SET @cmd="CREATE TABLE performance_schema.users("
- "USER CHAR(16) collate utf8_bin default null,"
- "CURRENT_CONNECTIONS bigint not null,"
- "TOTAL_CONNECTIONS bigint not null"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE ACCOUNTS
---
-
-SET @cmd="CREATE TABLE performance_schema.accounts("
- "USER CHAR(16) collate utf8_bin default null,"
- "HOST CHAR(60) collate utf8_bin default null,"
- "CURRENT_CONNECTIONS bigint not null,"
- "TOTAL_CONNECTIONS bigint not null"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE EVENTS_STATEMENTS_SUMMARY_BY_DIGEST
---
-
-SET @cmd="CREATE TABLE performance_schema.events_statements_summary_by_digest("
- "SCHEMA_NAME VARCHAR(64),"
- "DIGEST VARCHAR(32),"
- "DIGEST_TEXT LONGTEXT,"
- "COUNT_STAR BIGINT unsigned not null,"
- "SUM_TIMER_WAIT BIGINT unsigned not null,"
- "MIN_TIMER_WAIT BIGINT unsigned not null,"
- "AVG_TIMER_WAIT BIGINT unsigned not null,"
- "MAX_TIMER_WAIT BIGINT unsigned not null,"
- "SUM_LOCK_TIME BIGINT unsigned not null,"
- "SUM_ERRORS BIGINT unsigned not null,"
- "SUM_WARNINGS BIGINT unsigned not null,"
- "SUM_ROWS_AFFECTED BIGINT unsigned not null,"
- "SUM_ROWS_SENT BIGINT unsigned not null,"
- "SUM_ROWS_EXAMINED BIGINT unsigned not null,"
- "SUM_CREATED_TMP_DISK_TABLES BIGINT unsigned not null,"
- "SUM_CREATED_TMP_TABLES BIGINT unsigned not null,"
- "SUM_SELECT_FULL_JOIN BIGINT unsigned not null,"
- "SUM_SELECT_FULL_RANGE_JOIN BIGINT unsigned not null,"
- "SUM_SELECT_RANGE BIGINT unsigned not null,"
- "SUM_SELECT_RANGE_CHECK BIGINT unsigned not null,"
- "SUM_SELECT_SCAN BIGINT unsigned not null,"
- "SUM_SORT_MERGE_PASSES BIGINT unsigned not null,"
- "SUM_SORT_RANGE BIGINT unsigned not null,"
- "SUM_SORT_ROWS BIGINT unsigned not null,"
- "SUM_SORT_SCAN BIGINT unsigned not null,"
- "SUM_NO_INDEX_USED BIGINT unsigned not null,"
- "SUM_NO_GOOD_INDEX_USED BIGINT unsigned not null,"
- "FIRST_SEEN TIMESTAMP(0) NOT NULL default 0,"
- "LAST_SEEN TIMESTAMP(0) NOT NULL default 0"
- ")ENGINE=PERFORMANCE_SCHEMA;";
-
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE SESSION_CONNECT_ATTRS
---
-
-SET @cmd="CREATE TABLE performance_schema.session_connect_attrs("
- "PROCESSLIST_ID INT NOT NULL,"
- "ATTR_NAME VARCHAR(32) NOT NULL,"
- "ATTR_VALUE VARCHAR(1024),"
- "ORDINAL_POSITION INT"
- ")ENGINE=PERFORMANCE_SCHEMA CHARACTER SET utf8 COLLATE utf8_bin;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
-
---
--- TABLE SESSION_ACCOUNT_CONNECT_ATTRS
---
-
-SET @cmd="CREATE TABLE performance_schema.session_account_connect_attrs "
- " LIKE performance_schema.session_connect_attrs;";
-
-SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-DROP PREPARE stmt;
diff --git a/scripts/mysql_setpermission.sh b/scripts/mysql_setpermission.sh
index 4416551eadd..1d67ff82f3b 100644
--- a/scripts/mysql_setpermission.sh
+++ b/scripts/mysql_setpermission.sh
@@ -77,7 +77,7 @@ else
if ($opt_password eq '')
{
system "stty -echo";
- print "Password for user $opt_user to connect to MySQL: ";
+ print "Password for user $opt_user to connect to MariaDB: ";
$opt_password = <STDIN>;
chomp($opt_password);
system "stty echo";
@@ -85,7 +85,7 @@ if ($opt_password eq '')
}
-# make the connection to MySQL
+# make the connection to MariaDB
$dbh= DBI->connect("DBI:mysql:mysql:host=$sqlhost:port=$opt_port:mysql_socket=$opt_socket",$opt_user,$opt_password, {PrintError => 0}) ||
die("Can't make a connection to the mysql server.\n The error: $DBI::errstr");
@@ -105,7 +105,7 @@ sub q1 { # first question ...
while (! $end) {
print "#"x70;
print "\n";
- print "## Welcome to the permission setter $version for MySQL.\n";
+ print "## Welcome to the permission setter $version for MariaDB.\n";
print "## made by Luuk de Boer\n";
print "#"x70;
print "\n";
@@ -633,17 +633,17 @@ sub usage
{
print <<EOL;
----------------------------------------------------------------------
- The permission setter for MySQL.
+ The permission setter for MariaDB.
version: $version
made by: Luuk de Boer <luuk\@wxs.nl>
----------------------------------------------------------------------
The permission setter is a little program which can help you add users
-or databases or change passwords in MySQL. Keep in mind that we don't
-check permissions which already been set in MySQL. So if you can't
-connect to MySQL using the permission you just added, take a look at
-the permissions which have already been set in MySQL.
+or databases or change passwords in MariaDB. Keep in mind that we don't
+check permissions which already been set in MariaDB. So if you can't
+connect to MariaDB using the permission you just added, take a look at
+the permissions which have already been set in MariaDB.
The permission setter first reads your .my.cnf file in your Home
directory if it exists.
@@ -652,7 +652,7 @@ Options for the permission setter:
--help : print this help message and exit.
-The options shown below are used for making the connection to the MySQL
+The options shown below are used for making the connection to the MariaDB
server. Keep in mind that the permissions for the user specified via
these options must be sufficient to add users / create databases / set
passwords.
diff --git a/scripts/mysql_system_tables.sql b/scripts/mysql_system_tables.sql
index ab4ea6dfe41..f7d277544de 100644
--- a/scripts/mysql_system_tables.sql
+++ b/scripts/mysql_system_tables.sql
@@ -33,7 +33,7 @@ set @had_db_table= @@warning_count != 0;
CREATE TABLE IF NOT EXISTS host ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, PRIMARY KEY Host (Host,Db) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Host privileges; Merged with database privileges';
-CREATE TABLE IF NOT EXISTS user ( Host char(60) binary DEFAULT '' NOT NULL, User char(80) binary DEFAULT '' NOT NULL, Password char(41) character set latin1 collate latin1_bin DEFAULT '' NOT NULL, Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Reload_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Shutdown_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Process_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, File_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_db_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Super_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Repl_slave_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Repl_client_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_user_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Event_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tablespace_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, ssl_type enum('','ANY','X509', 'SPECIFIED') COLLATE utf8_general_ci DEFAULT '' NOT NULL, ssl_cipher BLOB NOT NULL, x509_issuer BLOB NOT NULL, x509_subject BLOB NOT NULL, max_questions int(11) unsigned DEFAULT 0 NOT NULL, max_updates int(11) unsigned DEFAULT 0 NOT NULL, max_connections int(11) unsigned DEFAULT 0 NOT NULL, max_user_connections int(11) DEFAULT 0 NOT NULL, plugin char(64) CHARACTER SET latin1 DEFAULT '' NOT NULL, authentication_string TEXT NOT NULL, password_expired ENUM('N', 'Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, is_role enum('N', 'Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, PRIMARY KEY Host (Host,User) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Users and global privileges';
+CREATE TABLE IF NOT EXISTS user ( Host char(60) binary DEFAULT '' NOT NULL, User char(80) binary DEFAULT '' NOT NULL, Password char(41) character set latin1 collate latin1_bin DEFAULT '' NOT NULL, Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Reload_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Shutdown_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Process_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, File_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_db_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Super_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Repl_slave_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Repl_client_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_user_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Event_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tablespace_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, ssl_type enum('','ANY','X509', 'SPECIFIED') COLLATE utf8_general_ci DEFAULT '' NOT NULL, ssl_cipher BLOB NOT NULL, x509_issuer BLOB NOT NULL, x509_subject BLOB NOT NULL, max_questions int(11) unsigned DEFAULT 0 NOT NULL, max_updates int(11) unsigned DEFAULT 0 NOT NULL, max_connections int(11) unsigned DEFAULT 0 NOT NULL, max_user_connections int(11) DEFAULT 0 NOT NULL, plugin char(64) CHARACTER SET latin1 DEFAULT '' NOT NULL, authentication_string TEXT NOT NULL, password_expired ENUM('N', 'Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, is_role enum('N', 'Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, default_role char(80) binary DEFAULT '' NOT NULL, max_statement_time decimal(12,6) DEFAULT 0 NOT NULL, PRIMARY KEY Host (Host,User) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Users and global privileges';
-- Remember for later if user table already existed
set @had_user_table= @@warning_count != 0;
@@ -95,7 +95,7 @@ DROP PREPARE stmt;
-- Create slow_log if CSV is enabled.
-SET @str = IF (@have_csv = 'YES', 'CREATE TABLE IF NOT EXISTS slow_log (start_time TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, user_host MEDIUMTEXT NOT NULL, query_time TIME(6) NOT NULL, lock_time TIME(6) NOT NULL, rows_sent INTEGER NOT NULL, rows_examined INTEGER NOT NULL, db VARCHAR(512) NOT NULL, last_insert_id INTEGER NOT NULL, insert_id INTEGER NOT NULL, server_id INTEGER UNSIGNED NOT NULL, sql_text MEDIUMTEXT NOT NULL, thread_id BIGINT(21) UNSIGNED NOT NULL) engine=CSV CHARACTER SET utf8 comment="Slow log"', 'SET @dummy = 0');
+SET @str = IF (@have_csv = 'YES', 'CREATE TABLE IF NOT EXISTS slow_log (start_time TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, user_host MEDIUMTEXT NOT NULL, query_time TIME(6) NOT NULL, lock_time TIME(6) NOT NULL, rows_sent INTEGER NOT NULL, rows_examined INTEGER NOT NULL, db VARCHAR(512) NOT NULL, last_insert_id INTEGER NOT NULL, insert_id INTEGER NOT NULL, server_id INTEGER UNSIGNED NOT NULL, sql_text MEDIUMTEXT NOT NULL, thread_id BIGINT(21) UNSIGNED NOT NULL, rows_affected INTEGER NOT NULL) engine=CSV CHARACTER SET utf8 comment="Slow log"', 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
diff --git a/scripts/mysql_system_tables_data.sql b/scripts/mysql_system_tables_data.sql
index 38e6a547c1d..9556e7ba160 100644
--- a/scripts/mysql_system_tables_data.sql
+++ b/scripts/mysql_system_tables_data.sql
@@ -38,15 +38,24 @@ DROP TABLE tmp_db;
-- Fill "user" table with default users allowing root access
-- from local machine if "user" table didn't exist before
-CREATE TEMPORARY TABLE tmp_user LIKE user;
-INSERT INTO tmp_user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0,'','','N', 'N');
-REPLACE INTO tmp_user SELECT @current_hostname,'root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0,'','','N','N' FROM dual WHERE @current_hostname != 'localhost';
-REPLACE INTO tmp_user VALUES ('127.0.0.1','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0,'','','N','N');
-REPLACE INTO tmp_user VALUES ('::1','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0,'','','N','N');
-INSERT INTO tmp_user (host,user) VALUES ('localhost','');
-INSERT INTO tmp_user (host,user) SELECT @current_hostname,'' FROM dual WHERE @current_hostname != 'localhost';
-INSERT INTO user SELECT * FROM tmp_user WHERE @had_user_table=0;
-DROP TABLE tmp_user;
+CREATE TEMPORARY TABLE tmp_user_nopasswd LIKE user;
+CREATE TEMPORARY TABLE tmp_user_socket LIKE user;
+CREATE TEMPORARY TABLE tmp_user_anonymous LIKE user;
+-- Classic passwordless root account.
+INSERT INTO tmp_user_nopasswd VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0,'','','N', 'N','', 0);
+REPLACE INTO tmp_user_nopasswd SELECT @current_hostname,'root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0,'','','N','N','',0 FROM dual WHERE @current_hostname != 'localhost';
+REPLACE INTO tmp_user_nopasswd VALUES ('127.0.0.1','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0,'','','N','N','',0);
+REPLACE INTO tmp_user_nopasswd VALUES ('::1','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0,'','','N','N', '', 0);
+-- More secure root account using unix sucket auth.
+INSERT INTO tmp_user_socket VALUES ('localhost',IFNULL(@auth_root_socket, 'root'),'','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0,'unix_socket','','N', 'N','', 0);
+-- Anonymous user with no privileges.
+INSERT INTO tmp_user_anonymous (host,user) VALUES ('localhost','');
+INSERT INTO tmp_user_anonymous (host,user) SELECT @current_hostname,'' FROM dual WHERE @current_hostname != 'localhost';
+
+INSERT INTO user SELECT * FROM tmp_user_nopasswd WHERE @had_user_table=0 AND @skip_auth_root_nopasswd IS NULL;
+INSERT INTO user SELECT * FROM tmp_user_socket WHERE @had_user_table=0 AND @auth_root_socket IS NOT NULL;
+INSERT INTO user SELECT * FROM tmp_user_anonymous WHERE @had_user_table=0 AND @skip_auth_anonymous IS NULL;
+DROP TABLE tmp_user_nopasswd, tmp_user_socket, tmp_user_anonymous;
CREATE TEMPORARY TABLE tmp_proxies_priv LIKE proxies_priv;
INSERT INTO tmp_proxies_priv VALUES ('localhost', 'root', '', '', TRUE, '', now());
diff --git a/scripts/mysql_system_tables_fix.sql b/scripts/mysql_system_tables_fix.sql
index 9d4318ad101..df545897813 100644
--- a/scripts/mysql_system_tables_fix.sql
+++ b/scripts/mysql_system_tables_fix.sql
@@ -26,6 +26,7 @@
set sql_mode='';
set storage_engine=MyISAM;
+set enforce_storage_engine=NULL;
ALTER TABLE user add File_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
@@ -260,6 +261,8 @@ SET GLOBAL slow_query_log = 'OFF';
ALTER TABLE slow_log
ADD COLUMN thread_id BIGINT(21) UNSIGNED NOT NULL AFTER sql_text;
ALTER TABLE slow_log
+ ADD COLUMN rows_affected INTEGER NOT NULL AFTER thread_id;
+ALTER TABLE slow_log
MODIFY start_time TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
MODIFY user_host MEDIUMTEXT NOT NULL,
MODIFY query_time TIME(6) NOT NULL,
@@ -641,6 +644,8 @@ ALTER TABLE user MODIFY plugin char(64) CHARACTER SET latin1 DEFAULT '' NOT NULL
MODIFY authentication_string TEXT NOT NULL;
ALTER TABLE user ADD password_expired ENUM('N', 'Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
ALTER TABLE user ADD is_role enum('N', 'Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
+ALTER TABLE user ADD default_role char(80) binary DEFAULT '' NOT NULL;
+ALTER TABLE user ADD max_statement_time decimal(12,6) DEFAULT 0 NOT NULL;
-- Somewhere above, we ran ALTER TABLE user .... CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin.
-- we want password_expired column to have collation utf8_general_ci.
ALTER TABLE user MODIFY password_expired ENUM('N', 'Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
@@ -689,6 +694,11 @@ set @str=if(@have_innodb <> 0, @str, "set @dummy = 0");
prepare stmt from @str;
execute stmt;
+set @str="alter table mysql.innodb_table_stats modify last_update timestamp not null default current_timestamp on update current_timestamp";
+set @str=if(@have_innodb <> 0, @str, "set @dummy = 0");
+prepare stmt from @str;
+execute stmt;
+
set @str=replace(@str, "innodb_index_stats", "innodb_table_stats");
prepare stmt from @str;
execute stmt;
diff --git a/scripts/mysql_to_mariadb.sql b/scripts/mysql_to_mariadb.sql
new file mode 100644
index 00000000000..4ee3f3a4214
--- /dev/null
+++ b/scripts/mysql_to_mariadb.sql
@@ -0,0 +1,22 @@
+-- Script that changes MySQL 5.7 privilege tables to MariaDB 10.x
+-- This should be run first with
+-- mysql --force mysql < mysql_to_mariadb.sql
+-- It's ok to ignore any errors, as these usually means that the tables are
+-- already fixed.
+
+-- After this script s run, one should run at least:
+-- mysql_upgrade --upgrade-system-tables
+-- to get the other tables in the mysql database fixed.
+
+-- Drop not existing columnms
+alter table mysql.user drop column `password_last_changed`, drop column `password_lifetime`, drop column `account_locked`;
+
+-- Change existing columns
+alter table mysql.user change column `authentication_string` `auth_string` text COLLATE utf8_bin NOT NULL;
+
+-- Add new columns
+alter table mysql.user add column `Password` char(41) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '' after `user`, add column `is_role` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N' after `auth_string`;
+alter table mysql.user add column `default_role` char(80) COLLATE utf8_bin NOT NULL DEFAULT '', add column `max_statement_time` decimal(12,6) NOT NULL DEFAULT '0.000000';
+
+-- Fix passwords
+update mysql.user set `password`=`auth_string`, plugin='' where plugin="mysql_native_password";
diff --git a/scripts/mysql_zap.sh b/scripts/mysql_zap.sh
index 725a4e247a4..a2ee225c0c6 100644
--- a/scripts/mysql_zap.sh
+++ b/scripts/mysql_zap.sh
@@ -14,8 +14,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-# This is a utility for MySQL. It is not needed by any standard part
-# of MySQL.
+# This is a utility for MariaDB. It is not needed by any standard part
+# of MariaDB.
# Usage: mysql_zap [-signal] [-f] [-t] pattern
diff --git a/scripts/mysqlaccess.sh b/scripts/mysqlaccess.sh
index e1872bd0cf8..e7c1f8d1fd6 100644
--- a/scripts/mysqlaccess.sh
+++ b/scripts/mysqlaccess.sh
@@ -34,7 +34,7 @@ BEGIN {
$script_log = $ENV{'HOME'}."/$script.log";
# ****************************
- # information on MySQL
+ # information on MariaDB
$MYSQL = '@bindir@/mysql'; # path to mysql executable
$SERVER = '3.21';
$MYSQL_OPT = ' --batch --unbuffered';
@@ -97,8 +97,8 @@ Usage: $script [host [user [db]]] OPTIONS
-U, --superuser=# connect as superuser
-P, --spassword=# password for superuser
- -H, --rhost=# remote MySQL-server to connect to
- --old_server connect to old MySQL-server (before v3.21) which
+ -H, --rhost=# remote MariaDB-server to connect to
+ --old_server connect to old MariaDB-server (before v3.21) which
does not yet know how to handle full where clauses.
-b, --brief single-line tabular report
diff --git a/scripts/mysqld_multi.sh b/scripts/mysqld_multi.sh
index de8bc25afce..2ab70cdd4c3 100644
--- a/scripts/mysqld_multi.sh
+++ b/scripts/mysqld_multi.sh
@@ -22,7 +22,7 @@ use Getopt::Long;
use POSIX qw(strftime getcwd);
$|=1;
-$VER="2.16";
+$VER="2.20";
my @defaults_options; # Leading --no-defaults, --defaults-file, etc.
@@ -38,6 +38,7 @@ $opt_user = "root";
$opt_version = 0;
$opt_silent = 0;
$opt_verbose = 0;
+$opt_wsrep_new_cluster = 0;
my $my_print_defaults_exists= 1;
my $logdir= undef();
@@ -87,7 +88,7 @@ sub main
print "WARNING: my_print_defaults command not found.\n";
print "Please make sure you have this command available and\n";
print "in your path. The command is available from the latest\n";
- print "MySQL distribution.\n";
+ print "MariaDB distribution.\n";
$my_print_defaults_exists= 0;
}
@@ -110,7 +111,7 @@ sub main
# We've already handled --no-defaults, --defaults-file, etc.
if (!GetOptions("help", "example", "version", "mysqld=s", "mysqladmin=s",
"user=s", "password=s", "log=s", "no-log",
- "tcp-ip", "silent", "verbose"))
+ "tcp-ip", "silent", "verbose", "wsrep-new-cluster"))
{
$flag_exit= 1;
}
@@ -122,6 +123,7 @@ sub main
print "will be disabled\nand some will be enabled.\n\n";
}
+ init_log() if (!defined($opt_log));
$groupids = $ARGV[1];
if ($opt_version)
{
@@ -137,7 +139,7 @@ sub main
if (!defined(my_which(my_print_defaults)))
{
print "ABORT: Can't find command 'my_print_defaults'.\n";
- print "This command is available from the latest MySQL\n";
+ print "This command is available from the latest MariaDB\n";
print "distribution. Please make sure you have the command\n";
print "in your PATH.\n";
exit(1);
@@ -147,7 +149,6 @@ sub main
!($ARGV[0] =~ m/^stop$/i) &&
!($ARGV[0] =~ m/^report$/i)));
- init_log() if (!defined($opt_log));
if (!$opt_no_log)
{
w2log("$my_progname log file version $VER; run: ",
@@ -202,6 +203,10 @@ sub quote_shell_word
return $option;
}
+####
+#### get options for a group
+####
+
sub defaults_for_group
{
my ($group) = @_;
@@ -249,17 +254,17 @@ sub init_log
}
####
-#### Report living and not running MySQL servers
+#### Report living and not running MariaDB servers
####
sub report_mysqlds
{
my (@groups, $com, $i, @options, $pec);
- print "Reporting MySQL servers\n";
+ print "Reporting MariaDB servers\n";
if (!$opt_no_log)
{
- w2log("\nReporting MySQL servers","$opt_log",0,0);
+ w2log("\nReporting MariaDB servers","$opt_log",0,0);
}
@groups = &find_groups($groupids);
for ($i = 0; defined($groups[$i]); $i++)
@@ -270,19 +275,19 @@ sub report_mysqlds
$pec = $? >> 8;
if ($pec)
{
- print "MySQL server from group: $groups[$i] is not running\n";
+ print "MariaDB server from group: $groups[$i] is not running\n";
if (!$opt_no_log)
{
- w2log("MySQL server from group: $groups[$i] is not running",
+ w2log("MariaDB server from group: $groups[$i] is not running",
"$opt_log", 0, 0);
}
}
else
{
- print "MySQL server from group: $groups[$i] is running\n";
+ print "MariaDB server from group: $groups[$i] is running\n";
if (!$opt_no_log)
{
- w2log("MySQL server from group: $groups[$i] is running",
+ w2log("MariaDB server from group: $groups[$i] is running",
"$opt_log", 0, 0);
}
}
@@ -307,11 +312,11 @@ sub start_mysqlds()
if (!$opt_no_log)
{
- w2log("\nStarting MySQL servers\n","$opt_log",0,0);
+ w2log("\nStarting MariaDB servers\n","$opt_log",0,0);
}
else
{
- print "\nStarting MySQL servers\n";
+ print "\nStarting MariaDB servers\n";
}
@groups = &find_groups($groupids);
for ($i = 0; defined($groups[$i]); $i++)
@@ -358,6 +363,11 @@ sub start_mysqlds()
$info_sent= 1;
}
$com.= $tmp;
+
+ if ($opt_wsrep_new_cluster) {
+ $com.= " --wsrep-new-cluster";
+ }
+
$com.= " >> $opt_log 2>&1" if (!$opt_no_log);
$com.= " &";
if (!$mysqld_found)
@@ -382,7 +392,7 @@ sub start_mysqlds()
}
if (!$i && !$opt_no_log)
{
- w2log("No MySQL servers to be started (check your GNRs)",
+ w2log("No MariaDB servers to be started (check your GNRs)",
"$opt_log", 0, 0);
}
}
@@ -397,11 +407,11 @@ sub stop_mysqlds()
if (!$opt_no_log)
{
- w2log("\nStopping MySQL servers\n","$opt_log",0,0);
+ w2log("\nStopping MariaDB servers\n","$opt_log",0,0);
}
else
{
- print "\nStopping MySQL servers\n";
+ print "\nStopping MariaDB servers\n";
}
@groups = &find_groups($groupids);
for ($i = 0; defined($groups[$i]); $i++)
@@ -414,7 +424,7 @@ sub stop_mysqlds()
}
if (!$i && !$opt_no_log)
{
- w2log("No MySQL servers to be stopped (check your GNRs)",
+ w2log("No MariaDB servers to be stopped (check your GNRs)",
"$opt_log", 0, 0);
}
}
@@ -634,23 +644,23 @@ sub example
#
# 1.COMMON USER
#
-# Make sure that the MySQL user, who is stopping the mysqld services, has
-# the same password to all MySQL servers being accessed by $my_progname.
+# Make sure that the MariaDB user, who is stopping the mysqld services, has
+# the same password to all MariaDB servers being accessed by $my_progname.
# This user needs to have the 'Shutdown_priv' -privilege, but for security
# reasons should have no other privileges. It is advised that you create a
-# common 'multi_admin' user for all MySQL servers being controlled by
+# common 'multi_admin' user for all MariaDB servers being controlled by
# $my_progname. Here is an example how to do it:
#
# GRANT SHUTDOWN ON *.* TO multi_admin\@localhost IDENTIFIED BY 'password'
#
-# You will need to apply the above to all MySQL servers that are being
+# You will need to apply the above to all MariaDB servers that are being
# controlled by $my_progname. 'multi_admin' will shutdown the servers
# using 'mysqladmin' -binary, when '$my_progname stop' is being called.
#
# 2.PID-FILE
#
# If you are using mysqld_safe to start mysqld, make sure that every
-# MySQL server has a separate pid-file. In order to use mysqld_safe
+# MariaDB server has a separate pid-file. In order to use mysqld_safe
# via $my_progname, you need to use two options:
#
# mysqld=/path/to/mysqld_safe
@@ -663,7 +673,7 @@ sub example
#
# 3.DATA DIRECTORY
#
-# It is NOT advised to run many MySQL servers within the same data directory.
+# It is NOT advised to run many MariaDB servers within the same data directory.
# You can do so, but please make sure to understand and deal with the
# underlying caveats. In short they are:
# - Speed penalty
@@ -684,7 +694,7 @@ sub example
# intentionally left out. You may have 'gaps' in the config file. This
# gives you more flexibility.
#
-# 6.MySQL Server User
+# 6.MariaDB Server User
#
# You can pass the user=... option inside [mysqld#] groups. This
# can be very handy in some cases, but then you need to run $my_progname
@@ -692,7 +702,7 @@ sub example
#
# 7.A Start-up Manage Script for $my_progname
#
-# In the recent MySQL distributions you can find a file called
+# In the recent MariaDB distributions you can find a file called
# mysqld_multi.server.sh. It is a wrapper for $my_progname. This can
# be used to start and stop multiple servers during boot and shutdown.
#
@@ -705,7 +715,7 @@ sub example
# or /root/.my.cnf and add the [mysqld_multi] and [mysqld#] groups.
#
# The script can be found from support-files/mysqld_multi.server.sh
-# in MySQL distribution. (Verify the script before using)
+# in MariaDB distribution. (Verify the script before using)
#
[mysqld_multi]
@@ -824,7 +834,7 @@ Using: @{[join ' ', @defaults_options]}
file is turned on.
--password=... Password for mysqladmin user.
--silent Disable warnings.
---tcp-ip Connect to the MySQL server(s) via the TCP/IP port instead
+--tcp-ip Connect to the MariaDB server(s) via the TCP/IP port instead
of the UNIX socket. This affects stopping and reporting.
If a socket file is missing, the server may still be
running, but can be accessed only via the TCP/IP port.
@@ -832,6 +842,7 @@ Using: @{[join ' ', @defaults_options]}
--user=... mysqladmin user. Using: $opt_user
--verbose Be more verbose.
--version Print the version number and exit.
+--wsrep-new-cluster Bootstrap a cluster.
EOF
exit(0);
}
diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh
index c7280036a1e..f21e697953f 100644
--- a/scripts/mysqld_safe.sh
+++ b/scripts/mysqld_safe.sh
@@ -21,6 +21,8 @@ mysqld_ld_library_path=
flush_caches=0
numa_interleave=0
unsafe_my_cnf=0
+wsrep_on=0
+dry_run=0
# Initial logging status: error log is not open, and not using syslog
logging=init
@@ -81,6 +83,7 @@ Usage: $0 [OPTIONS]
--malloc-lib=LIB Preload shared library LIB if available
--mysqld=FILE Use the specified file as mysqld
--mysqld-version=VERSION Use "mysqld-VERSION" as mysqld
+ --dry-run Simulate the start to detect errors but don't start
--nice=NICE Set the scheduling priority of mysqld
--no-auto-restart Exit after starting mysqld
--nowatch Exit after starting mysqld
@@ -143,6 +146,7 @@ find_in_bin() {
}
log_generic () {
+ [ $dry_run -eq 1 ] && return
priority="$1"
shift
@@ -168,7 +172,7 @@ log_notice () {
}
eval_log_error () {
- cmd="$1"
+ local cmd="$1"
case $logging in
file) cmd="$cmd 2>&1 | "`shell_quote_string "$helper"`" $user log "`shell_quote_string "$err_log"` ;;
syslog)
@@ -204,6 +208,89 @@ shell_quote_string() {
echo "$1" | sed -e 's,\([^a-zA-Z0-9/_.=-]\),\\\1,g'
}
+wsrep_pick_url() {
+ [ $# -eq 0 ] && return 0
+
+ log_error "WSREP: 'wsrep_urls' is DEPRECATED! Use wsrep_cluster_address to specify multiple addresses instead."
+
+ if ! which nc >/dev/null; then
+ log_error "ERROR: nc tool not found in PATH! Make sure you have it installed."
+ return 1
+ fi
+
+ local url
+ # Assuming URL in the form scheme://host:port
+ # If host and port are not NULL, the liveness of URL is assumed to be tested
+ # If port part is absent, the url is returned literally and unconditionally
+ # If every URL has port but none is reachable, nothing is returned
+ for url in `echo $@ | sed s/,/\ /g` 0; do
+ local host=`echo $url | cut -d \: -f 2 | sed s/^\\\/\\\///`
+ local port=`echo $url | cut -d \: -f 3`
+ [ -z "$port" ] && break
+ nc -z "$host" $port >/dev/null && break
+ done
+
+ if [ "$url" == "0" ]; then
+ log_error "ERROR: none of the URLs in '$@' is reachable."
+ return 1
+ fi
+
+ echo $url
+}
+
+# Run mysqld with --wsrep-recover and parse recovered position from log.
+# Position will be stored in wsrep_start_position_opt global.
+wsrep_start_position_opt=""
+wsrep_recover_position() {
+ local mysqld_cmd="$@"
+ local euid=$(id -u)
+ local ret=0
+
+ local wr_logfile=$(mktemp /tmp/wsrep_recovery.XXXXXX)
+
+ # safety checks
+ if [ -z $wr_logfile ]; then
+ log_error "WSREP: mktemp failed"
+ return 1
+ fi
+
+ if [ -f $wr_logfile ]; then
+ [ "$euid" = "0" ] && chown $user $wr_logfile
+ chmod 600 $wr_logfile
+ else
+ log_error "WSREP: mktemp failed"
+ return 1
+ fi
+
+ local wr_pidfile="$DATADIR/"`@HOSTNAME@`"-recover.pid"
+
+ local wr_options="--disable-log-error --pid-file='$wr_pidfile'"
+
+ log_notice "WSREP: Running position recovery with $wr_options"
+
+ eval "$mysqld_cmd --wsrep_recover $wr_options 2> $wr_logfile"
+
+ local rp="$(grep 'WSREP: Recovered position:' $wr_logfile)"
+ if [ -z "$rp" ]; then
+ local skipped="$(grep WSREP $wr_logfile | grep 'skipping position recovery')"
+ if [ -z "$skipped" ]; then
+ log_error "WSREP: Failed to recover position: '`cat $wr_logfile`'"
+ ret=1
+ else
+ log_notice "WSREP: Position recovery skipped"
+ fi
+ else
+ local start_pos="$(echo $rp | sed 's/.*WSREP\:\ Recovered\ position://' \
+ | sed 's/^[ \t]*//')"
+ log_notice "WSREP: Recovered position $start_pos"
+ wsrep_start_position_opt="--wsrep_start_position=$start_pos"
+ fi
+
+ [ $ret -eq 0 ] && rm $wr_logfile
+
+ return $ret
+}
+
check_executable_location() {
if test "$unsafe_my_cnf" = 1 -a "$unrecognized_handling" != collect; then
log_error "Cannot accept $1 from a config file, when my.cnf is in the datadir"
@@ -255,6 +342,7 @@ parse_arguments() {
MYSQLD="mysqld"
fi
;;
+ --dry[-_]run) dry_run=1 ;;
--nice=*) niceness="$val" ;;
--nowatch|--no[-_]watch|--no[-_]auto[-_]restart) nowatch=1 ;;
--open[-_]files[-_]limit=*) open_files="$val" ;;
@@ -265,6 +353,30 @@ parse_arguments() {
--timezone=*) TZ="$val"; export TZ; ;;
--flush[-_]caches) flush_caches=1 ;;
--numa[-_]interleave) numa_interleave=1 ;;
+ --wsrep[-_]on)
+ wsrep_on=1
+ append_arg_to_args "$arg"
+ ;;
+ --skip[-_]wsrep[-_]on)
+ wsrep_on=0
+ append_arg_to_args "$arg"
+ ;;
+ --wsrep[-_]on=*)
+ if echo $val | grep -iq '\(ON\|1\)'; then
+ wsrep_on=1
+ else
+ wsrep_on=0
+ fi
+ append_arg_to_args "$arg"
+ ;;
+ --wsrep[-_]urls=*) wsrep_urls="$val"; ;;
+ --wsrep[-_]provider=*)
+ if test -n "$val" && test "$val" != "none"
+ then
+ wsrep_restart=1
+ fi
+ append_arg_to_args "$arg"
+ ;;
--help) usage ;;
@@ -749,7 +861,7 @@ fi
#
# If there exists an old pid file, check if the daemon is already running
# Note: The switches to 'ps' may depend on your operating system
-if test -f "$pid_file"
+if test -f "$pid_file" && [ $dry_run -eq 0 ]
then
PID=`cat "$pid_file"`
if @CHECK_PID@
@@ -825,6 +937,7 @@ fi
#fi
cmd="`mysqld_ld_preload_text`$NOHUP_NICENESS"
+[ $dry_run -eq 1 ] && cmd=''
#
# Set mysqld's memory interleave policy.
@@ -844,7 +957,7 @@ then
fi
# Launch mysqld with numactl.
- cmd="$cmd numactl --interleave=all"
+ [ $dry_run -eq 0 ] && cmd="$cmd numactl --interleave=all"
elif test $numa_interleave -eq 1
then
log_error "--numa-interleave is not supported on this platform"
@@ -857,6 +970,8 @@ do
cmd="$cmd "`shell_quote_string "$i"`
done
cmd="$cmd $args"
+[ $dry_run -eq 1 ] && return
+
# Avoid 'nohup: ignoring input' warning
test -n "$NOHUP_NICENESS" && cmd="$cmd < /dev/null"
@@ -878,13 +993,34 @@ else
exec 2>/dev/null
fi
+# maximum number of wsrep restarts
+max_wsrep_restarts=0
+
while true
do
rm -f "$pid_file" # Some extra safety
start_time=`date +%M%S`
- eval_log_error "$cmd"
+ # Perform wsrep position recovery if wsrep_on=1, skip otherwise.
+ if test $wsrep_on -eq 1
+ then
+ # this sets wsrep_start_position_opt
+ wsrep_recover_position "$cmd"
+
+ [ $? -ne 0 ] && exit 1 #
+
+ [ -n "$wsrep_urls" ] && url=`wsrep_pick_url $wsrep_urls` # check connect address
+
+ if [ -z "$url" ]
+ then
+ eval_log_error "$cmd $wsrep_start_position_opt"
+ else
+ eval_log_error "$cmd $wsrep_start_position_opt --wsrep_cluster_address=$url"
+ fi
+ else
+ eval_log_error "$cmd"
+ fi
end_time=`date +%M%S`
if test ! -f "$pid_file" # This is removed if normal shutdown
@@ -947,6 +1083,20 @@ do
I=`expr $I + 1`
done
fi
+
+ if [ -n "$wsrep_restart" ]
+ then
+ if [ $wsrep_restart -le $max_wsrep_restarts ]
+ then
+ wsrep_restart=`expr $wsrep_restart + 1`
+ log_notice "WSREP: sleeping 15 seconds before restart"
+ sleep 15
+ else
+ log_notice "WSREP: not restarting wsrep node automatically"
+ break
+ fi
+ fi
+
log_notice "mysqld restarted"
if test -n "$crash_script"
then
diff --git a/scripts/mysqldumpslow.sh b/scripts/mysqldumpslow.sh
index a7d064904a5..98241da3cba 100644
--- a/scripts/mysqldumpslow.sh
+++ b/scripts/mysqldumpslow.sh
@@ -26,8 +26,8 @@
use strict;
use Getopt::Long;
-# t=time, l=lock time, r=rows
-# at, al, and ar are the corresponding averages
+# t=time, l=lock time, r=rows, a=rows affected
+# at, al, ar and aa are the corresponding averages
my %opt = (
s => 'at',
@@ -109,9 +109,11 @@ while ( defined($_ = shift @pending) or defined($_ = <>) ) {
s/^#? Time: \d{6}\s+\d+:\d+:\d+.*\n//;
my ($user,$host) = s/^#? User\@Host:\s+(\S+)\s+\@\s+(\S+).*\n// ? ($1,$2) : ('','');
- s/^# Thread_id: [0-9]+\s+Schema: [^\n]+\n//;
+ s/^# Thread_id: [0-9]+\s+Schema: .*\s+QC_hit:.*[^\n]+\n//;
s/^# Query_time: ([0-9.]+)\s+Lock_time: ([0-9.]+)\s+Rows_sent: ([0-9.]+)\s+Rows_examined: ([0-9.]+).*\n//;
my ($t, $l, $r, $e) = ($1, $2, $3, $4);
+ s/^# Rows_affected: ([0-9.]+).*\n//;
+ my ($a) = ($1);
$t -= $l unless $opt{l};
@@ -155,6 +157,7 @@ while ( defined($_ = shift @pending) or defined($_ = <>) ) {
$s->{l} += $l;
$s->{r} += $r;
$s->{e} += $e;
+ $s->{a} += $a;
$s->{users}->{$user}++ if $user;
$s->{hosts}->{$host}++ if $host;
@@ -163,11 +166,12 @@ while ( defined($_ = shift @pending) or defined($_ = <>) ) {
foreach (keys %stmt) {
my $v = $stmt{$_} || die;
- my ($c, $t, $l, $r, $e) = @{ $v }{qw(c t l r e)};
+ my ($c, $t, $l, $r, $e, $a) = @{ $v }{qw(c t l r e a)};
$v->{at} = $t / $c;
$v->{al} = $l / $c;
$v->{ar} = $r / $c;
$v->{ae} = $e / $c;
+ $v->{aa} = $a / $c;
}
my @sorted = sort { $stmt{$b}->{$opt{s}} <=> $stmt{$a}->{$opt{s}} } keys %stmt;
@@ -176,13 +180,13 @@ my @sorted = sort { $stmt{$b}->{$opt{s}} <=> $stmt{$a}->{$opt{s}} } keys %stmt;
foreach (@sorted) {
my $v = $stmt{$_} || die;
- my ($c, $t,$at, $l,$al, $r,$ar,$e, $ae) = @{ $v }{qw(c t at l al r ar e ae)};
+ my ($c, $t, $at, $l, $al, $r, $ar, $e, $ae, $a, $aa) = @{ $v }{qw(c t at l al r ar e ae a aa)};
my @users = keys %{$v->{users}};
my $user = (@users==1) ? $users[0] : sprintf "%dusers",scalar @users;
my @hosts = keys %{$v->{hosts}};
my $host = (@hosts==1) ? $hosts[0] : sprintf "%dhosts",scalar @hosts;
- printf "Count: %d Time=%.2fs (%ds) Lock=%.2fs (%ds) Rows_sent=%.1f (%d), Rows_examined=%.1f (%d), $user\@$host\n%s\n\n",
- $c, $at,$t, $al,$l, $ar,$r, $ae, $e, $_;
+ printf "Count: %d Time=%.2fs (%ds) Lock=%.2fs (%ds) Rows_sent=%.1f (%d), Rows_examined=%.1f (%d), Rows_affected=%.1f (%d), $user\@$host\n%s\n\n",
+ $c, $at,$t, $al,$l, $ar,$r, $ae, $e, $aa, $a, $_;
}
sub usage {
@@ -202,6 +206,7 @@ Parse and summarize the MySQL slow query log. Options are
al: average lock time
ar: average rows sent
at: average query time
+ aa: average rows affected
c: count
l: lock time
r: rows sent
diff --git a/scripts/mytop.sh b/scripts/mytop.sh
index 0619f996549..3ef0a59f27f 100644
--- a/scripts/mytop.sh
+++ b/scripts/mytop.sh
@@ -6,7 +6,7 @@
=head1 NAME
-mytop - display MySQL server performance info like `top'
+mytop - display MariaDB server performance info like `top'
=cut
@@ -256,7 +256,7 @@ my $dbh = DBI->connect($dsn, $config{user}, $config{pass},
if (not ref $dbh)
{
my $Error = <<EODIE
-Cannot connect to MySQL server. Please check the:
+Cannot connect to MariaDB server. Please check the:
* database you specified "$config{db}" (default is "test")
* username you specified "$config{user}" (default is "root")
@@ -1886,12 +1886,11 @@ pick up Term::ReadKey here:
http://search.cpan.org/search?dist=TermReadKey
-And you obviously need access to a MySQL server (version 3.22.x or
-3.23.x) with the necessary security to run the I<SHOW PROCESSLIST> and
-I<SHOW STATUS> commands.
+And you obviously need access to a MariaDB server with the necessary
+security to run the I<SHOW PROCESSLIST> and I<SHOW STATUS> commands.
If you are a Windows user, using ActiveState's Perl, you can use PPM
-(the Perl Package Manager) to install the MySQL and Term::ReadKey
+(the Perl Package Manager) to install the MariaDB/MySQL and Term::ReadKey
modules.
=head2 Optional Color Support
@@ -1943,24 +1942,24 @@ B<mytop> was inspired by the system monitoring tool B<top>. I
routinely use B<top> on Linux, FreeBSD, and Solaris. You are likely to
notice features from each of them here.
-B<mytop> will connect to a MySQL server and periodically run the
+B<mytop> will connect to a MariaDB server and periodically run the
I<SHOW PROCESSLIST> and I<SHOW STATUS> commands and attempt to
summarize the information from them in a useful format.
=head2 The Display
The B<mytop> display screen is really broken into two parts. The top 4
-lines (header) contain summary information about your MySQL
+lines (header) contain summary information about your MariaDB
server. For example, you might see something like:
-MySQL on localhost (4.0.13-log) up 1+11:13:00 [23:29:11]
+MariaDB on localhost (10.0.13-log) up 1+11:13:00 [23:29:11]
Queries: 19.3M qps: 160 Slow: 1.0 Se/In/Up/De(%): 00/80/03/17
qps now: 219 Slow qps: 0.0 Threads: 1 ( 1/ 16) 00/74/00/25
Key Efficiency: 99.3% Bps in/out: 30.5k/162.8 Now in/out: 32.7k/ 3.3k
The first line identifies the hostname of the server (localhost) and
-the version of MySQL it is running. The right had side shows the
-uptime of the MySQL server process in days+hours:minutes:seconds
+the version of MariaDB it is running. The right had side shows the
+uptime of the MariaDB server process in days+hours:minutes:seconds
format (much like FreeBSD's top) as well as the current time.
The second line displays the total number of queries the server has
@@ -1974,7 +1973,7 @@ on the previous line).
And the fourth line displays key buffer efficiency (how often keys are
read from the buffer rather than disk) and the number of bytes that
-MySQL has sent and received, both over all and in the last cycle.
+MariaDB has sent and received, both over all and in the last cycle.
You can toggle the header by hitting B<h> when running B<mytop>.
@@ -2020,21 +2019,21 @@ have two dashes `--'. Short arguments only have one '-'.
=item B<-u> or B<-user> username
-Username to use when logging in to the MySQL server. Default: ``root''.
+Username to use when logging in to the MariaDB server. Default: ``root''.
=item B<-p> or B<-pass> or B<-password> password
-Password to use when logging in to the MySQL server. Default: none.
+Password to use when logging in to the MariaDB server. Default: none.
=item B<-h> or B<--host> hostname[:port]
-Hostname of the MySQL server. The hostname may be followed by an
+Hostname of the MariaDB server. The hostname may be followed by an
option port number. Note that the port is specified separate from the
host when using a config file. Default: ``localhost''.
=item B<--port> or B<-P> port
-If you're running MySQL on a non-standard port, use this to specify
+If you're running MariaDB on a non-standard port, use this to specify
the port number. Default: 3306.
=item B<-s> or B<--delay> seconds
@@ -2052,15 +2051,15 @@ In batch mode, mytop runs only once, does not clear the screen, and
places no limit on the number of lines it will print. This is suitable
for running periodically (perhaps from cron) to capture the
information into a file for later viewing. You might use batch mode in
-a CGI script to occasionally display your MySQL server status on the
+a CGI script to occasionally display your MariaDB server status on the
web.
Default: unset.
=item B<-S> or B<--socket> /path/to/socket
-If you're running B<mytop> on the same host as MySQL, you may wish to
-have it use the MySQL socket directly rather than a standard TCP/IP
+If you're running B<mytop> on the same host as MariaDB, you may wish to
+have it use the MariaDB socket directly rather than a standard TCP/IP
connection. If you do,just specify one.
Note that specifying a socket will make B<mytop> ignore any host
@@ -2106,7 +2105,7 @@ Default: noprompt.
=item B<--resolve>
-If you have skip-resolve set on MySQL (to keep it from doing a reverse
+If you have skip-resolve set on MariaDB (to keep it from doing a reverse
DNS lookup on each inbound connection), mytop can replace IP addresses
with hostnames but toggling this option.
diff --git a/scripts/wsrep_sst_common.sh b/scripts/wsrep_sst_common.sh
new file mode 100644
index 00000000000..976f0e0cf2d
--- /dev/null
+++ b/scripts/wsrep_sst_common.sh
@@ -0,0 +1,306 @@
+# 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
+# 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
+# MA 02110-1301 USA.
+
+# 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=""
+WSREP_SST_OPT_BINLOG_INDEX=""
+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_DEFAULT=""
+WSREP_SST_OPT_EXTRA_DEFAULT=""
+WSREP_SST_OPT_SUFFIX_DEFAULT=""
+WSREP_SST_OPT_SUFFIX_VALUE=""
+INNODB_DATA_HOME_DIR_ARG=""
+
+while [ $# -gt 0 ]; do
+case "$1" in
+ '--address')
+ readonly WSREP_SST_OPT_ADDR="$2"
+ #
+ # Break address string into host:port/path parts
+ #
+ 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}]"
+ readonly WSREP_SST_OPT_HOST_ESCAPED="\\[${WSREP_SST_OPT_HOST_UNESCAPED}\\]"
+ ;;
+ *)
+ 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
+ ;;
+ esac
+ remain=${WSREP_SST_OPT_ADDR#${WSREP_SST_OPT_HOST_ESCAPED}}
+ remain=${remain#:}
+ readonly WSREP_SST_OPT_ADDR_PORT=${remain%%/*}
+ remain=${remain#*/}
+ readonly WSREP_SST_OPT_MODULE=${remain%%/*}
+ readonly WSREP_SST_OPT_PATH=${WSREP_SST_OPT_ADDR#*/}
+ remain=${WSREP_SST_OPT_PATH#*/}
+ 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
+ shift
+ ;;
+ '--bypass')
+ WSREP_SST_OPT_BYPASS=1
+ ;;
+ '--datadir')
+ readonly WSREP_SST_OPT_DATA="$2"
+ shift
+ ;;
+ '--innodb-data-home-dir')
+ readonly INNODB_DATA_HOME_DIR_ARG="$2"
+ shift
+ ;;
+ '--defaults-file')
+ readonly WSREP_SST_OPT_DEFAULT="$1=$2"
+ shift
+ ;;
+ '--defaults-extra-file')
+ readonly WSREP_SST_OPT_EXTRA_DEFAULT="$1=$2"
+ shift
+ ;;
+ '--defaults-group-suffix')
+ readonly WSREP_SST_OPT_SUFFIX_DEFAULT="$1=$2"
+ readonly WSREP_SST_OPT_SUFFIX_VALUE="$2"
+ shift
+ ;;
+ '--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
+ ;;
+ '--binlog-index')
+ WSREP_SST_OPT_BINLOG_INDEX="$2"
+ shift
+ ;;
+ '--gtid-domain-id')
+ readonly WSREP_SST_OPT_GTID_DOMAIN_ID="$2"
+ shift
+ ;;
+ *) # must be command
+ # usage
+ # exit 1
+ ;;
+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
+fi
+
+# 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
+
+readonly WSREP_SST_OPT_CONF="$WSREP_SST_OPT_DEFAULT $WSREP_SST_OPT_EXTRA_DEFAULT $WSREP_SST_OPT_SUFFIX_DEFAULT"
+readonly 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 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
+ 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)"
+ echo "WSREP_SST: $* ($tst)" >&2
+}
+
+wsrep_log_error()
+{
+ wsrep_log "[ERROR] $*"
+}
+
+wsrep_log_warning()
+{
+ wsrep_log "[WARNING] $*"
+}
+
+wsrep_log_info()
+{
+ wsrep_log "[INFO] $*"
+}
+
+wsrep_cleanup_progress_file()
+{
+ [ -n "${SST_PROGRESS_FILE:-}" ] && rm -f "$SST_PROGRESS_FILE" 2>/dev/null || true
+}
+
+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
+}
+
+#
+# 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()
+{
+ 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
+ fi
+ echo $reval
+}
diff --git a/scripts/wsrep_sst_mariabackup.sh b/scripts/wsrep_sst_mariabackup.sh
new file mode 100644
index 00000000000..4891ade7c3c
--- /dev/null
+++ b/scripts/wsrep_sst_mariabackup.sh
@@ -0,0 +1,1148 @@
+#!/bin/bash -ue
+# Copyright (C) 2013 Percona Inc
+# Copyright (C) 2017 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
+# 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
+# MA 02110-1301 USA.
+
+# Documentation:
+# http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html
+# Make sure to read that before proceeding!
+
+. $(dirname $0)/wsrep_sst_common
+
+ealgo=""
+ekey=""
+ekeyfile=""
+encrypt=0
+nproc=1
+ecode=0
+ssyslog=""
+ssystag=""
+XTRABACKUP_PID=""
+SST_PORT=""
+REMOTEIP=""
+tcert=""
+tpem=""
+tkey=""
+sockopt=""
+progress=""
+ttime=0
+totime=0
+lsn=""
+ecmd=""
+rlimit=""
+# Initially
+stagemsg="${WSREP_SST_OPT_ROLE}"
+cpat=""
+speciald=1
+ib_home_dir=""
+ib_log_dir=""
+ib_undo_dir=""
+
+sfmt="tar"
+strmcmd=""
+tfmt=""
+tcmd=""
+rebuild=0
+rebuildcmd=""
+payload=0
+pvformat="-F '%N => Rate:%r Avg:%a Elapsed:%t %e Bytes: %b %p' "
+pvopts="-f -i 10 -N $WSREP_SST_OPT_ROLE "
+STATDIR=""
+uextra=0
+disver=""
+
+tmpopts=""
+itmpdir=""
+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
+pcmd="pv $pvopts"
+declare -a RC
+
+INNOBACKUPEX_BIN=mariabackup
+XBSTREAM_BIN=mbstream
+XBCRYPT_BIN=xbcrypt # Not available in MariaBackup
+
+DATA="${WSREP_SST_OPT_DATA}"
+INFO_FILE="xtrabackup_galera_info"
+IST_FILE="xtrabackup_ist"
+MAGIC_FILE="${DATA}/${INFO_FILE}"
+INNOAPPLYLOG="${DATA}/mariabackup.prepare.log"
+INNOMOVELOG="${DATA}/mariabackup.move.log"
+INNOBACKUPLOG="${DATA}/mariabackup.backup.log"
+
+# Setting the path for ss and ip
+export PATH="/usr/sbin:/sbin:$PATH"
+
+timeit(){
+ local stage=$1
+ shift
+ local cmd="$@"
+ local x1 x2 took extcode
+
+ if [[ $ttime -eq 1 ]];then
+ x1=$(date +%s)
+ wsrep_log_info "Evaluating $cmd"
+ eval "$cmd"
+ extcode=$?
+ x2=$(date +%s)
+ took=$(( x2-x1 ))
+ wsrep_log_info "NOTE: $stage took $took seconds"
+ totime=$(( totime+took ))
+ else
+ wsrep_log_info "Evaluating $cmd"
+ eval "$cmd"
+ extcode=$?
+ fi
+ return $extcode
+}
+
+get_keys()
+{
+ # $encrypt -eq 1 is for internal purposes only
+ if [[ $encrypt -ge 2 || $encrypt -eq -1 ]];then
+ return
+ fi
+
+ if [[ $encrypt -eq 0 ]];then
+ if $MY_PRINT_DEFAULTS xtrabackup | grep -q encrypt;then
+ wsrep_log_error "Unexpected option combination. SST may fail. Refer to http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html "
+ fi
+ return
+ fi
+
+ if [[ $sfmt == 'tar' ]];then
+ wsrep_log_info "NOTE: Xtrabackup-based encryption - encrypt=1 - cannot be enabled with tar format"
+ encrypt=-1
+ return
+ fi
+
+ wsrep_log_info "Xtrabackup based encryption enabled in my.cnf - Supported only from Xtrabackup 2.1.4"
+
+ if [[ -z $ealgo ]];then
+ wsrep_log_error "FATAL: Encryption algorithm empty from my.cnf, bailing out"
+ exit 3
+ fi
+
+ if [[ -z $ekey && ! -r $ekeyfile ]];then
+ wsrep_log_error "FATAL: Either key or keyfile must be readable"
+ exit 3
+ fi
+
+ if [[ -z $ekey ]];then
+ ecmd="${XBCRYPT_BIN} --encrypt-algo=$ealgo --encrypt-key-file=$ekeyfile"
+ else
+ ecmd="${XBCRYPT_BIN} --encrypt-algo=$ealgo --encrypt-key=$ekey"
+ fi
+
+ if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
+ ecmd+=" -d"
+ fi
+
+ stagemsg+="-XB-Encrypted"
+}
+
+get_transfer()
+{
+ if [[ -z $SST_PORT ]];then
+ TSST_PORT=4444
+ else
+ TSST_PORT=$SST_PORT
+ fi
+
+ if [[ $tfmt == 'nc' ]];then
+ if [[ ! -x `which nc` ]];then
+ wsrep_log_error "nc(netcat) not found in path: $PATH"
+ exit 2
+ fi
+ wsrep_log_info "Using netcat as streamer"
+ if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
+ if nc -h 2>&1 | grep -q ncat;then
+ # Ncat
+ tcmd="nc -l ${TSST_PORT}"
+ elif nc -h 2>&1 | grep -q -- '-d\>';then
+ # Debian netcat
+ tcmd="nc -dl ${TSST_PORT}"
+ else
+ # traditional netcat
+ tcmd="nc -l -p ${TSST_PORT}"
+ fi
+ else
+ if nc -h 2>&1 | grep -q ncat;then
+ # Ncat
+ tcmd="nc ${REMOTEIP} ${TSST_PORT}"
+ elif nc -h 2>&1 | grep -q -- '-d\>';then
+ # Debian netcat
+ tcmd="nc ${REMOTEIP} ${TSST_PORT}"
+ else
+ # traditional netcat
+ tcmd="nc -q0 ${REMOTEIP} ${TSST_PORT}"
+ fi
+ fi
+ else
+ tfmt='socat'
+ wsrep_log_info "Using socat as streamer"
+ if [[ ! -x `which socat` ]];then
+ wsrep_log_error "socat not found in path: $PATH"
+ exit 2
+ fi
+
+ if [[ $encrypt -eq 2 || $encrypt -eq 3 ]] && ! socat -V | grep -q "WITH_OPENSSL 1";then
+ wsrep_log_error "Encryption requested, but socat is not OpenSSL enabled (encrypt=$encrypt)"
+ exit 2
+ fi
+
+ if [[ $encrypt -eq 2 ]];then
+ wsrep_log_info "Using openssl based encryption with socat: with crt and pem"
+ if [[ -z $tpem || -z $tcert ]];then
+ wsrep_log_error "Both PEM and CRT files required"
+ exit 22
+ fi
+ stagemsg+="-OpenSSL-Encrypted-2"
+ if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
+ wsrep_log_info "Decrypting with cert=${tpem}, cafile=${tcert}"
+ tcmd="socat -u openssl-listen:${TSST_PORT},reuseaddr,cert=${tpem},cafile=${tcert}${sockopt} stdio"
+ else
+ wsrep_log_info "Encrypting with cert=${tpem}, cafile=${tcert}"
+ tcmd="socat -u stdio openssl-connect:${REMOTEIP}:${TSST_PORT},cert=${tpem},cafile=${tcert}${sockopt}"
+ fi
+ elif [[ $encrypt -eq 3 ]];then
+ wsrep_log_info "Using openssl based encryption with socat: with key and crt"
+ if [[ -z $tpem || -z $tkey ]];then
+ wsrep_log_error "Both certificate and key files required"
+ exit 22
+ fi
+ stagemsg+="-OpenSSL-Encrypted-3"
+ if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
+ if [[ -z $tcert ]];then
+ wsrep_log_info "Decrypting with cert=${tpem}, key=${tkey}, verify=0"
+ tcmd="socat -u openssl-listen:${TSST_PORT},reuseaddr,cert=${tpem},key=${tkey},verify=0${sockopt} stdio"
+ else
+ wsrep_log_info "Decrypting with cert=${tpem}, key=${tkey}, cafile=${tcert}"
+ tcmd="socat -u openssl-listen:${TSST_PORT},reuseaddr,cert=${tpem},key=${tkey},cafile=${tcert}${sockopt} stdio"
+ fi
+ else
+ if [[ -z $tcert ]];then
+ wsrep_log_info "Encrypting with cert=${tpem}, key=${tkey}, verify=0"
+ tcmd="socat -u stdio openssl-connect:${REMOTEIP}:${TSST_PORT},cert=${tpem},key=${tkey},verify=0${sockopt}"
+ else
+ wsrep_log_info "Encrypting with cert=${tpem}, key=${tkey}, cafile=${tcert}"
+ tcmd="socat -u stdio openssl-connect:${REMOTEIP}:${TSST_PORT},cert=${tpem},key=${tkey},cafile=${tcert}${sockopt}"
+ fi
+ fi
+
+ else
+ if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
+ tcmd="socat -u TCP-LISTEN:${TSST_PORT},reuseaddr${sockopt} stdio"
+ else
+ tcmd="socat -u stdio TCP:${REMOTEIP}:${TSST_PORT}${sockopt}"
+ fi
+ fi
+ fi
+
+}
+
+parse_cnf()
+{
+ local group=$1
+ local var=$2
+ # print the default settings for given group using my_print_default.
+ # normalize the variable names specified in cnf file (user can use _ or - for example log-bin or log_bin)
+ # then grep 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 -F= '{if ($1 ~ /_/) { gsub(/_/,"-",$1); print $1"="$2 } else { print $0 }}' | grep -- "--$var=" | cut -d= -f2- | tail -1)
+ if [[ -z $reval ]];then
+ [[ -n $3 ]] && reval=$3
+ fi
+ echo $reval
+}
+
+get_footprint()
+{
+ pushd $WSREP_SST_OPT_DATA 1>/dev/null
+ payload=$(find . -regex '.*\.ibd$\|.*\.MYI$\|.*\.MYD$\|.*ibdata1$' -type f -print0 | du --files0-from=- --block-size=1 -c | awk 'END { print $1 }')
+ if $MY_PRINT_DEFAULTS xtrabackup | grep -q -- "--compress";then
+ # QuickLZ has around 50% compression ratio
+ # When compression/compaction used, the progress is only an approximate.
+ payload=$(( payload*1/2 ))
+ fi
+ popd 1>/dev/null
+ pcmd+=" -s $payload"
+ adjust_progress
+}
+
+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"
+ else
+ pcmd+=" 2>$progress"
+ fi
+ elif [[ -z $progress && -n $rlimit ]];then
+ # When rlimit is non-zero
+ pcmd="pv -q"
+ fi
+
+ if [[ -n $rlimit && "$WSREP_SST_OPT_ROLE" == "donor" ]];then
+ wsrep_log_info "Rate-limiting SST to $rlimit"
+ pcmd+=" -L \$rlimit"
+ fi
+}
+
+read_cnf()
+{
+ sfmt=$(parse_cnf sst streamfmt "xbstream")
+ tfmt=$(parse_cnf sst transferfmt "socat")
+ tcert=$(parse_cnf sst tca "")
+ tpem=$(parse_cnf sst tcert "")
+ tkey=$(parse_cnf sst tkey "")
+ encrypt=$(parse_cnf sst encrypt 0)
+ sockopt=$(parse_cnf sst sockopt "")
+ 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$\|.*\.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 "")
+ scomp=$(parse_cnf sst compressor "")
+ sdecomp=$(parse_cnf sst decompressor "")
+
+ # Refer to http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html
+ if [[ -z $ealgo ]];then
+ ealgo=$(parse_cnf sst encrypt-algo "")
+ ekey=$(parse_cnf sst encrypt-key "")
+ ekeyfile=$(parse_cnf sst encrypt-key-file "")
+ fi
+
+ rlimit=$(parse_cnf sst rlimit "")
+ uextra=$(parse_cnf sst use-extra 0)
+ speciald=$(parse_cnf sst sst-special-dirs 1)
+ iopts=$(parse_cnf sst inno-backup-opts "")
+ 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+="-"
+ sstlogarchive=$(parse_cnf sst sst-log-archive 1)
+ sstlogarchivedir=$(parse_cnf sst sst-log-archive-dir "/tmp/sst_log_archive")
+
+ 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
+
+ if [[ $encrypt -eq 1 ]]; then
+ wsrep_log_error "Xtrabackup-based encryption is currently not" \
+ "supported with MariaBackup"
+ exit 2
+ fi
+}
+
+get_stream()
+{
+ if [[ $sfmt == 'xbstream' ]];then
+ wsrep_log_info "Streaming with xbstream"
+ if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
+ strmcmd="${XBSTREAM_BIN} -x"
+ else
+ strmcmd="${XBSTREAM_BIN} -c \${INFO_FILE}"
+ fi
+ else
+ sfmt="tar"
+ wsrep_log_info "Streaming with tar"
+ if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
+ strmcmd="tar xfi - "
+ else
+ strmcmd="tar cf - \${INFO_FILE} "
+ fi
+
+ fi
+}
+
+get_proc()
+{
+ set +e
+ nproc=$(grep -c processor /proc/cpuinfo)
+ [[ -z $nproc || $nproc -eq 0 ]] && nproc=1
+ set -e
+}
+
+sig_joiner_cleanup()
+{
+ wsrep_log_error "Removing $MAGIC_FILE file due to signal"
+ rm -f "$MAGIC_FILE"
+}
+
+cleanup_joiner()
+{
+ # Since this is invoked just after exit NNN
+ local estatus=$?
+ if [[ $estatus -ne 0 ]];then
+ wsrep_log_error "Cleanup after exit with status:$estatus"
+ elif [ "${WSREP_SST_OPT_ROLE}" = "joiner" ];then
+ wsrep_log_info "Removing the sst_in_progress file"
+ wsrep_cleanup_progress_file
+ fi
+ if [[ -n $progress && -p $progress ]];then
+ wsrep_log_info "Cleaning up fifo file $progress"
+ rm $progress
+ fi
+ 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()
+{
+ local pid_file="$1"
+ [ -r "$pid_file" ] && ps -p $(cat "$pid_file") >/dev/null 2>&1
+}
+
+cleanup_donor()
+{
+ # Since this is invoked just after exit NNN
+ local estatus=$?
+ if [[ $estatus -ne 0 ]];then
+ wsrep_log_error "Cleanup after exit with status:$estatus"
+ fi
+
+ if [[ -n ${XTRABACKUP_PID:-} ]];then
+ if check_pid $XTRABACKUP_PID
+ then
+ wsrep_log_error "xtrabackup process is still running. Killing... "
+ kill_xtrabackup
+ fi
+
+ fi
+ rm -f ${DATA}/${IST_FILE} || true
+
+ if [[ -n $progress && -p $progress ]];then
+ wsrep_log_info "Cleaning up fifo file $progress"
+ rm -f $progress || true
+ fi
+
+ wsrep_log_info "Cleaning up temporary directories"
+
+ if [[ -n $xtmpdir ]];then
+ [[ -d $xtmpdir ]] && rm -rf $xtmpdir || true
+ fi
+
+ 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()
+{
+ local PID=$(cat $XTRABACKUP_PID)
+ [ -n "$PID" -a "0" != "$PID" ] && kill $PID && (kill $PID && kill -9 $PID) || :
+ wsrep_log_info "Removing xtrabackup pid file $XTRABACKUP_PID"
+ rm -f "$XTRABACKUP_PID" || true
+}
+
+setup_ports()
+{
+ if [[ "$WSREP_SST_OPT_ROLE" == "donor" ]];then
+ if [[ ${WSREP_SST_OPT_ADDR:0:1} == '[' ]];then
+ remain=$(echo $WSREP_SST_OPT_ADDR | awk -F '\\][:/]' '{ print $2 }')
+ REMOTEIP=$(echo $WSREP_SST_OPT_ADDR | awk -F '\\]:' '{ print $1 }')"]"
+ SST_PORT=$(echo $remain | awk -F '[:/]' '{ print $1 }')
+ lsn=$(echo $remain | awk -F '[:/]' '{ print $3 }')
+ sst_ver=$(echo $remain | awk -F '[:/]' '{ print $4 }')
+ else
+ 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 }')
+ fi
+ else
+ if [[ ${WSREP_SST_OPT_ADDR:0:1} == '[' ]];then
+ SST_PORT=$(echo ${WSREP_SST_OPT_ADDR} | awk -F '\\]:' '{ print $2 }')
+ else
+ SST_PORT=$(echo ${WSREP_SST_OPT_ADDR} | awk -F ':' '{ print $2 }')
+ fi
+ fi
+}
+
+# waits ~10 seconds for nc to open the port and then reports ready
+# (regardless of timeout)
+wait_for_listen()
+{
+ local PORT=$1
+ local ADDR=$2
+ local MODULE=$3
+ for i in {1..50}
+ do
+ ss -p state listening "( sport = :$PORT )" | grep -qE 'socat|nc' && break
+ sleep 0.2
+ done
+ echo "ready ${ADDR}/${MODULE}//$sst_ver"
+}
+
+check_extra()
+{
+ local use_socket=1
+ if [[ $uextra -eq 1 ]];then
+ if $MY_PRINT_DEFAULTS --mysqld | tr '_' '-' | grep -- "--thread-handling=" | grep -q 'pool-of-threads';then
+ local eport=$($MY_PRINT_DEFAULTS --mysqld | tr '_' '-' | grep -- "--extra-port=" | cut -d= -f2)
+ if [[ -n $eport ]];then
+ # Xtrabackup works only locally.
+ # Hence, setting host to 127.0.0.1 unconditionally.
+ wsrep_log_info "SST through extra_port $eport"
+ INNOEXTRA+=" --host=127.0.0.1 --port=$eport "
+ use_socket=0
+ else
+ wsrep_log_error "Extra port $eport null, failing"
+ exit 1
+ fi
+ else
+ wsrep_log_info "Thread pool not set, ignore the option use_extra"
+ fi
+ fi
+ if [[ $use_socket -eq 1 ]] && [[ -n "${WSREP_SST_OPT_SOCKET}" ]];then
+ INNOEXTRA+=" --socket=${WSREP_SST_OPT_SOCKET}"
+ fi
+}
+
+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
+
+ if [[ $tmt -gt 0 && -x `which timeout` ]];then
+ if timeout --help | grep -q -- '-k';then
+ ltcmd="timeout -k $(( tmt+10 )) $tmt $tcmd"
+ else
+ ltcmd="timeout -s9 $tmt $tcmd"
+ fi
+ timeit "$msg" "$ltcmd | $strmcmd; RC=( "\${PIPESTATUS[@]}" )"
+ else
+ timeit "$msg" "$tcmd | $strmcmd; RC=( "\${PIPESTATUS[@]}" )"
+ fi
+
+ set -e
+ popd 1>/dev/null
+
+ if [[ ${RC[0]} -eq 124 ]];then
+ wsrep_log_error "Possible timeout in receving first data from donor in gtid stage"
+ exit 32
+ fi
+
+ for ecode in "${RC[@]}";do
+ if [[ $ecode -ne 0 ]];then
+ wsrep_log_error "Error while getting data from donor node: " \
+ "exit codes: ${RC[@]}"
+ exit 32
+ fi
+ done
+
+ 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"
+ wsrep_log_info "$(ls -l ${dir}/*)"
+ exit 32
+ fi
+}
+
+
+send_donor()
+{
+ local dir=$1
+ local msg=$2
+
+ pushd ${dir} 1>/dev/null
+ set +e
+ timeit "$msg" "$strmcmd | $tcmd; RC=( "\${PIPESTATUS[@]}" )"
+ set -e
+ popd 1>/dev/null
+
+
+ for ecode in "${RC[@]}";do
+ if [[ $ecode -ne 0 ]];then
+ wsrep_log_error "Error while getting data from donor node: " \
+ "exit codes: ${RC[@]}"
+ exit 32
+ fi
+ done
+
+}
+
+monitor_process()
+{
+ local sst_stream_pid=$1
+
+ while true ; do
+
+ if ! ps --pid "${WSREP_SST_OPT_PARENT}" &>/dev/null; then
+ wsrep_log_error "Parent mysqld process (PID:${WSREP_SST_OPT_PARENT}) terminated unexpectedly."
+ kill -- -"${WSREP_SST_OPT_PARENT}"
+ exit 32
+ fi
+
+ if ! ps --pid "${sst_stream_pid}" &>/dev/null; then
+ break
+ fi
+
+ sleep 0.1
+
+ done
+}
+
+if [[ ! -x `which $INNOBACKUPEX_BIN` ]];then
+ wsrep_log_error "${INNOBACKUPEX_BIN} not in path: $PATH"
+ exit 2
+fi
+
+rm -f "${MAGIC_FILE}"
+
+if [[ ! ${WSREP_SST_OPT_ROLE} == 'joiner' && ! ${WSREP_SST_OPT_ROLE} == 'donor' ]];then
+ wsrep_log_error "Invalid role ${WSREP_SST_OPT_ROLE}"
+ exit 22
+fi
+
+read_cnf
+setup_ports
+
+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=""
+
+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} --innobackupex $disver $iapts --apply-log \$rebuildcmd \${DATA} 2>&1 | logger -p daemon.err -t ${ssystag}innobackupex-apply "
+ INNOMOVE="${INNOBACKUPEX_BIN} --innobackupex ${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} --innobackupex ${WSREP_SST_OPT_CONF} $disver $iopts \$tmpopts \$INNOEXTRA --galera-info --stream=\$sfmt \$itmpdir 2> >(logger -p daemon.err -t ${ssystag}innobackupex-backup)"
+ fi
+
+else
+
+if [[ "$sstlogarchive" -eq 1 ]]
+then
+ ARCHIVETIMESTAMP=$(date "+%Y.%m.%d-%H.%M.%S")
+ newfile=""
+
+ if [[ ! -z "$sstlogarchivedir" ]]
+ then
+ if [[ ! -d "$sstlogarchivedir" ]]
+ then
+ mkdir -p "$sstlogarchivedir"
+ fi
+ fi
+
+ if [ -e "${INNOAPPLYLOG}" ]
+ then
+ if [[ ! -z "$sstlogarchivedir" ]]
+ then
+ newfile=$sstlogarchivedir/$(basename "${INNOAPPLYLOG}").${ARCHIVETIMESTAMP}
+ else
+ newfile=${INNOAPPLYLOG}.${ARCHIVETIMESTAMP}
+ fi
+
+ wsrep_log_info "Moving ${INNOAPPLYLOG} to ${newfile}"
+ mv "${INNOAPPLYLOG}" "${newfile}"
+ gzip "${newfile}"
+ fi
+
+ if [ -e "${INNOMOVELOG}" ]
+ then
+ if [[ ! -z "$sstlogarchivedir" ]]
+ then
+ newfile=$sstlogarchivedir/$(basename "${INNOMOVELOG}").${ARCHIVETIMESTAMP}
+ else
+ newfile=${INNOMOVELOG}.${ARCHIVETIMESTAMP}
+ fi
+
+ wsrep_log_info "Moving ${INNOMOVELOG} to ${newfile}"
+ mv "${INNOMOVELOG}" "${newfile}"
+ gzip "${newfile}"
+ fi
+
+ if [ -e "${INNOBACKUPLOG}" ]
+ then
+ if [[ ! -z "$sstlogarchivedir" ]]
+ then
+ newfile=$sstlogarchivedir/$(basename "${INNOBACKUPLOG}").${ARCHIVETIMESTAMP}
+ else
+ newfile=${INNOBACKUPLOG}.${ARCHIVETIMESTAMP}
+ fi
+
+ wsrep_log_info "Moving ${INNOBACKUPLOG} to ${newfile}"
+ mv "${INNOBACKUPLOG}" "${newfile}"
+ gzip "${newfile}"
+ fi
+
+fi
+
+ INNOAPPLY="${INNOBACKUPEX_BIN} --innobackupex $disver $iapts --apply-log \$rebuildcmd \${DATA} &> ${INNOAPPLYLOG}"
+ INNOMOVE="${INNOBACKUPEX_BIN} --innobackupex ${WSREP_SST_OPT_CONF} $disver $impts --move-back --force-non-empty-directories \${DATA} &> ${INNOMOVELOG}"
+ INNOBACKUP="${INNOBACKUPEX_BIN} --innobackupex ${WSREP_SST_OPT_CONF} $disver $iopts \$tmpopts \$INNOEXTRA --galera-info --stream=\$sfmt \$itmpdir 2> ${INNOBACKUPLOG}"
+fi
+
+get_stream
+get_transfer
+
+if [ "$WSREP_SST_OPT_ROLE" = "donor" ]
+then
+ trap cleanup_donor EXIT
+
+ if [ $WSREP_SST_OPT_BYPASS -eq 0 ]
+ then
+ usrst=0
+ 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)
+ tmpopts=" --tmpdir=$xtmpdir "
+ wsrep_log_info "Using $xtmpdir as xtrabackup temporary directory"
+ fi
+
+ itmpdir=$(mktemp -d)
+ wsrep_log_info "Using $itmpdir as innobackupex temporary directory"
+
+ if [[ -n "${WSREP_SST_OPT_USER:-}" && "$WSREP_SST_OPT_USER" != "(null)" ]]; then
+ INNOEXTRA+=" --user=$WSREP_SST_OPT_USER"
+ usrst=1
+ fi
+
+ if [ -n "${WSREP_SST_OPT_PSWD:-}" ]; then
+ INNOEXTRA+=" --password=$WSREP_SST_OPT_PSWD"
+ elif [[ $usrst -eq 1 ]];then
+ # Empty password, used for testing, debugging etc.
+ INNOEXTRA+=" --password="
+ fi
+
+ get_keys
+ if [[ $encrypt -eq 1 ]];then
+ if [[ -n $ekey ]];then
+ INNOEXTRA+=" --encrypt=$ealgo --encrypt-key=$ekey "
+ else
+ INNOEXTRA+=" --encrypt=$ealgo --encrypt-key-file=$ekeyfile "
+ fi
+ fi
+
+
+ check_extra
+
+ wsrep_log_info "Streaming GTID file before SST"
+
+ # Store donor's wsrep GTID (state ID) and wsrep_gtid_domain_id
+ # (separated by a space).
+ echo "${WSREP_SST_OPT_GTID} ${WSREP_SST_OPT_GTID_DOMAIN_ID}" > "${MAGIC_FILE}"
+
+ ttcmd="$tcmd"
+
+ if [[ $encrypt -eq 1 ]];then
+ if [[ -n $scomp ]];then
+ tcmd=" $ecmd | $scomp | $tcmd "
+ else
+ tcmd=" $ecmd | $tcmd "
+ fi
+ elif [[ -n $scomp ]];then
+ tcmd=" $scomp | $tcmd "
+ fi
+
+
+ send_donor $DATA "${stagemsg}-gtid"
+
+ tcmd="$ttcmd"
+ if [[ -n $progress ]];then
+ get_footprint
+ tcmd="$pcmd | $tcmd"
+ elif [[ -n $rlimit ]];then
+ adjust_progress
+ tcmd="$pcmd | $tcmd"
+ fi
+
+ wsrep_log_info "Sleeping before data transfer for SST"
+ sleep 10
+
+ wsrep_log_info "Streaming the backup to joiner at ${REMOTEIP} ${SST_PORT:-4444}"
+
+ if [[ -n $scomp ]];then
+ tcmd="$scomp | $tcmd"
+ fi
+
+ set +e
+ timeit "${stagemsg}-SST" "$INNOBACKUP | $tcmd; RC=( "\${PIPESTATUS[@]}" )"
+ set -e
+
+ if [ ${RC[0]} -ne 0 ]; then
+ wsrep_log_error "${INNOBACKUPEX_BIN} finished with error: ${RC[0]}. " \
+ "Check syslog or ${INNOBACKUPLOG} for details"
+ exit 22
+ elif [[ ${RC[$(( ${#RC[@]}-1 ))]} -eq 1 ]];then
+ wsrep_log_error "$tcmd finished with error: ${RC[1]}"
+ exit 22
+ fi
+
+ # innobackupex implicitly writes PID to fixed location in $xtmpdir
+ XTRABACKUP_PID="$xtmpdir/xtrabackup_pid"
+
+
+ else # BYPASS FOR IST
+
+ wsrep_log_info "Bypassing the SST for IST"
+ echo "continue" # now server can resume updating data
+
+ # Store donor's wsrep GTID (state ID) and wsrep_gtid_domain_id
+ # (separated by a space).
+ echo "${WSREP_SST_OPT_GTID} ${WSREP_SST_OPT_GTID_DOMAIN_ID}" > "${MAGIC_FILE}"
+ echo "1" > "${DATA}/${IST_FILE}"
+ get_keys
+ if [[ $encrypt -eq 1 ]];then
+ if [[ -n $scomp ]];then
+ tcmd=" $ecmd | $scomp | $tcmd "
+ else
+ tcmd=" $ecmd | $tcmd "
+ fi
+ elif [[ -n $scomp ]];then
+ tcmd=" $scomp | $tcmd "
+ fi
+ strmcmd+=" \${IST_FILE}"
+
+ send_donor $DATA "${stagemsg}-IST"
+
+ fi
+
+ echo "done ${WSREP_SST_OPT_GTID}"
+ wsrep_log_info "Total time on donor: $totime seconds"
+
+elif [ "${WSREP_SST_OPT_ROLE}" = "joiner" ]
+then
+ [[ -e $SST_PROGRESS_FILE ]] && wsrep_log_info "Stale sst_in_progress file: $SST_PROGRESS_FILE"
+ [[ -n $SST_PROGRESS_FILE ]] && touch $SST_PROGRESS_FILE
+
+ 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"
+
+
+ sencrypted=1
+ nthreads=1
+
+ MODULE="xtrabackup_sst"
+
+ rm -f "${DATA}/${IST_FILE}"
+
+ # May need xtrabackup_checkpoints later on
+ rm -f ${DATA}/xtrabackup_binary ${DATA}/xtrabackup_galera_info ${DATA}/xtrabackup_logfile
+
+ ADDR=${WSREP_SST_OPT_ADDR}
+ if [ -z "${SST_PORT}" ]
+ then
+ SST_PORT=4444
+ if [[ ${ADDR:0:1} == '[' ]];then
+ ADDR="$(echo ${WSREP_SST_OPT_ADDR} | awk -F '\\]:' '{ print $1 }')]:${SST_PORT}"
+ else
+ ADDR="$(echo ${WSREP_SST_OPT_ADDR} | awk -F ':' '{ print $1 }'):${SST_PORT}"
+ fi
+ fi
+
+ wait_for_listen ${SST_PORT} ${ADDR} ${MODULE} &
+
+ trap sig_joiner_cleanup HUP PIPE INT TERM
+ trap cleanup_joiner EXIT
+
+ if [[ -n $progress ]];then
+ adjust_progress
+ tcmd+=" | $pcmd"
+ fi
+
+ get_keys
+ if [[ $encrypt -eq 1 && $sencrypted -eq 1 ]];then
+ if [[ -n $sdecomp ]];then
+ strmcmd=" $sdecomp | $ecmd | $strmcmd"
+ else
+ strmcmd=" $ecmd | $strmcmd"
+ fi
+ elif [[ -n $sdecomp ]];then
+ strmcmd=" $sdecomp | $strmcmd"
+ fi
+
+ STATDIR=$(mktemp -d)
+ MAGIC_FILE="${STATDIR}/${INFO_FILE}"
+ recv_joiner $STATDIR "${stagemsg}-gtid" $stimeout 1
+
+
+ if ! ps -p ${WSREP_SST_OPT_PARENT} &>/dev/null
+ then
+ wsrep_log_error "Parent mysqld process (PID:${WSREP_SST_OPT_PARENT}) terminated unexpectedly."
+ exit 32
+ fi
+
+ if [ ! -r "${STATDIR}/${IST_FILE}" ]
+ then
+
+ if [[ -d ${DATA}/.sst ]];then
+ wsrep_log_info "WARNING: Stale temporary SST directory: ${DATA}/.sst from previous state transfer. Removing"
+ rm -rf ${DATA}/.sst
+ fi
+ mkdir -p ${DATA}/.sst
+ (recv_joiner $DATA/.sst "${stagemsg}-SST" 0 0) &
+ jpid=$!
+ wsrep_log_info "Proceeding with SST"
+
+
+ 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
+
+
+
+ TDATA=${DATA}
+ DATA="${DATA}/.sst"
+
+
+ MAGIC_FILE="${DATA}/${INFO_FILE}"
+ wsrep_log_info "Waiting for SST streaming to complete!"
+ monitor_process $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"
+ rebuild=1
+ fi
+
+ if [[ $rebuild -eq 1 ]];then
+ nthreads=$(parse_cnf xtrabackup rebuild-threads $nproc)
+ wsrep_log_info "Rebuilding during prepare with $nthreads threads"
+ rebuildcmd="--rebuild-indexes --rebuild-threads=$nthreads"
+ fi
+
+ if test -n "$(find ${DATA} -maxdepth 1 -type f -name '*.qp' -print -quit)";then
+
+ wsrep_log_info "Compressed qpress files found"
+
+ if [[ ! -x `which qpress` ]];then
+ wsrep_log_error "qpress not found in path: $PATH"
+ exit 22
+ fi
+
+ if [[ -n $progress ]] && pv --help | grep -q 'line-mode';then
+ count=$(find ${DATA} -type f -name '*.qp' | wc -l)
+ count=$(( count*2 ))
+ if pv --help | grep -q FORMAT;then
+ pvopts="-f -s $count -l -N Decompression -F '%N => Rate:%r Elapsed:%t %e Progress: [%b/$count]'"
+ else
+ pvopts="-f -s $count -l -N Decompression"
+ fi
+ pcmd="pv $pvopts"
+ adjust_progress
+ dcmd="$pcmd | xargs -n 2 qpress -T${nproc}d"
+ else
+ dcmd="xargs -n 2 qpress -T${nproc}d"
+ fi
+
+
+ # Decompress the qpress files
+ wsrep_log_info "Decompression with $nproc threads"
+ timeit "Joiner-Decompression" "find ${DATA} -type f -name '*.qp' -printf '%p\n%h\n' | $dcmd"
+ extcode=$?
+
+ if [[ $extcode -eq 0 ]];then
+ wsrep_log_info "Removing qpress files after decompression"
+ find ${DATA} -type f -name '*.qp' -delete
+ if [[ $? -ne 0 ]];then
+ wsrep_log_error "Something went wrong with deletion of qpress files. Investigate"
+ fi
+ else
+ wsrep_log_error "Decompression failed. Exit code: $extcode"
+ exit 22
+ fi
+ fi
+
+
+ if [[ ! -z $WSREP_SST_OPT_BINLOG ]];then
+
+ BINLOG_DIRNAME=$(dirname $WSREP_SST_OPT_BINLOG)
+ BINLOG_FILENAME=$(basename $WSREP_SST_OPT_BINLOG)
+
+ # To avoid comparing data directory and BINLOG_DIRNAME
+ mv $DATA/${BINLOG_FILENAME}.* $BINLOG_DIRNAME/ 2>/dev/null || true
+
+ pushd $BINLOG_DIRNAME &>/dev/null
+ for bfiles in $(ls -1 ${BINLOG_FILENAME}.[0-9]*);do
+ echo ${BINLOG_DIRNAME}/${bfiles} >> ${BINLOG_FILENAME}.index
+ done
+ popd &> /dev/null
+
+ fi
+
+ wsrep_log_info "Preparing the backup at ${DATA}"
+ timeit "Xtrabackup prepare stage" "$INNOAPPLY"
+
+ if [ $? -ne 0 ];
+ then
+ wsrep_log_error "${INNOBACKUPEX_BIN} apply finished with errors. Check syslog or ${INNOAPPLYLOG} for details"
+ exit 22
+ fi
+
+ MAGIC_FILE="${TDATA}/${INFO_FILE}"
+ set +e
+ 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 syslog or ${INNOMOVELOG} for details"
+ exit 22
+ fi
+
+
+ else
+ wsrep_log_info "${IST_FILE} received from donor: Running IST"
+ fi
+
+ if [[ ! -r ${MAGIC_FILE} ]];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
+
+exit 0
diff --git a/scripts/wsrep_sst_mysqldump.sh b/scripts/wsrep_sst_mysqldump.sh
new file mode 100644
index 00000000000..faa3f10639b
--- /dev/null
+++ b/scripts/wsrep_sst_mysqldump.sh
@@ -0,0 +1,179 @@
+#!/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
+# 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
+# MA 02110-1301 USA.
+
+# This is a reference script for mysqldump-based state snapshot tansfer
+
+. $(dirname $0)/wsrep_sst_common
+PATH=$PATH:/usr/sbin:/usr/bin:/sbin:/bin
+
+EINVAL=22
+
+local_ip()
+{
+ [ "$1" = "127.0.0.1" ] && return 0
+ [ "$1" = "localhost" ] && return 0
+ [ "$1" = "[::1]" ] && return 0
+ [ "$1" = "$(hostname -s)" ] && return 0
+ [ "$1" = "$(hostname -f)" ] && return 0
+ [ "$1" = "$(hostname -d)" ] && return 0
+
+ # Now if ip program is not found in the path, we can't return 0 since
+ # it would block any address. Thankfully grep should fail in this case
+ ip route get "$1" | grep local >/dev/null && return 0
+
+ return 1
+}
+
+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
+if test -z "$WSREP_SST_OPT_SOCKET";then wsrep_log_error "SOCKET cannot be nil";exit $EINVAL; fi
+if test -z "$WSREP_SST_OPT_GTID"; then wsrep_log_error "GTID cannot be nil"; exit $EINVAL; fi
+
+if local_ip $WSREP_SST_OPT_HOST && \
+ [ "$WSREP_SST_OPT_PORT" = "$WSREP_SST_OPT_LPORT" ]
+then
+ wsrep_log_error \
+ "destination address '$WSREP_SST_OPT_HOST:$WSREP_SST_OPT_PORT' matches source address."
+ exit $EINVAL
+fi
+
+# Check client version
+if ! $MYSQL_CLIENT --version | grep 'Distrib 10\.[1-9]' >/dev/null
+then
+ $MYSQL_CLIENT --version >&2
+ wsrep_log_error "this operation requires MySQL client version 10.1 or newer"
+ exit $EINVAL
+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"
+
+STOP_WSREP="SET wsrep_on=OFF;"
+
+# mysqldump cannot restore CSV tables, fix this issue
+CSV_TABLES_FIX="
+set sql_mode='';
+
+USE mysql;
+
+SET @cond = (SELECT (SUPPORT = 'YES' or SUPPORT = 'DEFAULT') FROM INFORMATION_SCHEMA.ENGINES WHERE ENGINE = 'csv');
+
+SET @stmt = IF (@cond = '1', 'CREATE TABLE IF NOT EXISTS general_log ( event_time timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), user_host mediumtext NOT NULL, thread_id bigint(21) unsigned NOT NULL, server_id int(10) unsigned NOT NULL, command_type varchar(64) NOT NULL, argument mediumtext NOT NULL) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT=\"General log\"', 'SET @dummy = 0');
+
+PREPARE stmt FROM @stmt;
+EXECUTE stmt;
+DROP PREPARE stmt;
+
+SET @stmt = IF (@cond = '1', 'CREATE TABLE IF NOT EXISTS slow_log ( start_time timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), user_host mediumtext NOT NULL, query_time time(6) NOT NULL, lock_time time(6) NOT NULL, rows_sent int(11) NOT NULL, rows_examined int(11) NOT NULL, db varchar(512) NOT NULL, last_insert_id int(11) NOT NULL, insert_id int(11) NOT NULL, server_id int(10) unsigned NOT NULL, sql_text mediumtext NOT NULL, thread_id bigint(21) unsigned NOT NULL) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT=\"Slow log\"', 'SET @dummy = 0');
+
+PREPARE stmt FROM @stmt;
+EXECUTE stmt;
+DROP PREPARE stmt;"
+
+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;"
+fi
+
+MYSQL="$MYSQL_CLIENT $WSREP_SST_OPT_CONF "\
+"$AUTH -h${WSREP_SST_OPT_HOST_UNESCAPED} "\
+"-P$WSREP_SST_OPT_PORT --disable-reconnect --connect_timeout=10"
+
+# Check if binary logging is enabled on the joiner node.
+# Note: SELECT cannot be used at this point.
+LOG_BIN=$(echo "set statement wsrep_sync_wait=0 for SHOW VARIABLES LIKE 'log_bin'" | $MYSQL |\
+tail -1 | awk -F ' ' '{ print $2 }')
+
+# Check the joiner node's server version.
+SERVER_VERSION=$(echo "set statement wsrep_sync_wait=0 for SHOW VARIABLES LIKE 'version'" | $MYSQL |\
+tail -1 | awk -F ' ' '{ print $2 }')
+
+# Retrieve the donor's @@global.gtid_binlog_state.
+GTID_BINLOG_STATE=$(echo "SHOW GLOBAL VARIABLES LIKE 'gtid_binlog_state'" | $MYSQL |\
+tail -1 | awk -F ' ' '{ print $2 }')
+
+RESET_MASTER=""
+SET_GTID_BINLOG_STATE=""
+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="RESET MASTER;"
+ SET_GTID_BINLOG_STATE="SET @@global.gtid_binlog_state='$GTID_BINLOG_STATE';"
+ 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
+MYSQLDUMP="$MYSQLDUMP $WSREP_SST_OPT_CONF $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 --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"
+
+# commands to restore log settings
+RESTORE_GENERAL_LOG="SET GLOBAL GENERAL_LOG=$GENERAL_LOG_OPT;"
+RESTORE_SLOW_QUERY_LOG="SET GLOBAL SLOW_QUERY_LOG=$SLOW_LOG_OPT;"
+
+
+if [ $WSREP_SST_OPT_BYPASS -eq 0 ]
+then
+ (echo $STOP_WSREP && echo $RESET_MASTER && \
+ echo $SET_GTID_BINLOG_STATE && echo $SQL_LOG_BIN_OFF && \
+ echo $STOP_WSREP && $MYSQLDUMP && echo $CSV_TABLES_FIX && \
+ echo $RESTORE_GENERAL_LOG && echo $RESTORE_SLOW_QUERY_LOG && \
+ echo $SET_START_POSITION && echo $SET_WSREP_GTID_DOMAIN_ID \
+ || echo "SST failed to complete;") | $MYSQL
+else
+ wsrep_log_info "Bypassing state dump."
+ echo $SET_START_POSITION | $MYSQL
+fi
+
+#
diff --git a/scripts/wsrep_sst_rsync.sh b/scripts/wsrep_sst_rsync.sh
new file mode 100644
index 00000000000..1bded37a6b6
--- /dev/null
+++ b/scripts/wsrep_sst_rsync.sh
@@ -0,0 +1,498 @@
+#!/bin/bash -ue
+
+# Copyright (C) 2010-2014 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
+# 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
+# MA 02110-1301 USA.
+
+# This is a reference script for rsync-based state snapshot tansfer
+
+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
+
+# Setting the path for lsof on CentOS
+export PATH="/usr/sbin:/sbin:$PATH"
+
+. $(dirname $0)/wsrep_sst_common
+
+wsrep_check_programs rsync
+
+cleanup_joiner()
+{
+ 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 -f "$STUNNEL_CONF"
+ rm -f "$STUNNEL_PID"
+ rm -rf "$MAGIC_FILE"
+ rm -rf "$RSYNC_PID"
+ wsrep_log_info "Joiner cleanup done."
+ if [ "${WSREP_SST_OPT_ROLE}" = "joiner" ];then
+ wsrep_cleanup_progress_file
+ fi
+}
+
+# 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
+}
+
+check_pid_and_port()
+{
+ local pid_file=$1
+ local rsync_pid=$2
+ local rsync_port=$3
+
+ if ! which lsof > /dev/null; then
+ wsrep_log_error "lsof tool not found in PATH! Make sure you have it installed."
+ exit 2 # ENOENT
+ fi
+
+ if ! which lsof > /dev/null; 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 | \
+ grep -wE '^(rsync|stunnel)[[:space:]]+'"$rsync_pid" 2>/dev/null)
+
+ if [ -n "$port_info" -a -z "$is_rsync" ]; then
+ wsrep_log_error "rsync daemon port '$rsync_port' has been taken"
+ exit 16 # EBUSY
+ fi
+ check_pid $pid_file && \
+ [ -n "$port_info" ] && [ -n "$is_rsync" ] && \
+ [ $(cat $pid_file) -eq $rsync_pid ]
+}
+
+STUNNEL_CONF="$WSREP_SST_OPT_DATA/stunnel.conf"
+rm -f "$STUNNEL_CONF"
+
+STUNNEL_PID="$WSREP_SST_OPT_DATA/stunnel.pid"
+rm -f "$STUNNEL_PID"
+
+MAGIC_FILE="$WSREP_SST_OPT_DATA/rsync_sst_complete"
+rm -rf "$MAGIC_FILE"
+
+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)
+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)
+fi
+
+WSREP_LOG_DIR=${WSREP_LOG_DIR:-""}
+# if WSREP_LOG_DIR env. variable is not set, try to get it from my.cnf
+if [ -z "$WSREP_LOG_DIR" ]; then
+ WSREP_LOG_DIR=$(parse_cnf --mysqld innodb-log-group-home-dir '')
+fi
+
+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)
+else
+ # default to datadir
+ 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 INNODB_DATA_HOME_DIR env. 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 "")
+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)
+else
+ # default to datadir
+ INNODB_DATA_HOME_DIR=$(cd $WSREP_SST_OPT_DATA; pwd -P)
+fi
+
+# Old filter - include everything except selected
+# FILTER=(--exclude '*.err' --exclude '*.pid' --exclude '*.sock' \
+# --exclude '*.conf' --exclude core --exclude 'galera.*' \
+# --exclude grastate.txt --exclude '*.pem' \
+# --exclude '*.[0-9][0-9][0-9][0-9][0-9][0-9]' --exclude '*.index')
+
+# New filter - exclude everything except dirs (schemas) and innodb files
+FILTER=(-f '- /lost+found'
+ -f '- /.fseventsd'
+ -f '- /.Trashes'
+ -f '+ /wsrep_sst_binlog.tar'
+ -f '- $INNODB_DATA_HOME_DIR/ib_lru_dump'
+ -f '- $INNODB_DATA_HOME_DIR/ibdata*'
+ -f '+ /undo*'
+ -f '+ /*/'
+ -f '- /*')
+
+SSTKEY=$(parse_cnf sst tkey "")
+SSTCERT=$(parse_cnf sst tcert "")
+STUNNEL=""
+if [ -f "$SSTKEY" ] && [ -f "$SSTCERT" ] && wsrep_check_programs stunnel
+then
+ STUNNEL="stunnel ${STUNNEL_CONF}"
+fi
+
+if [ "$WSREP_SST_OPT_ROLE" = "donor" ]
+then
+
+cat << EOF > "$STUNNEL_CONF"
+CApath = ${SSTCERT%/*}
+foreground = yes
+pid = $STUNNEL_PID
+debug = warning
+client = yes
+connect = ${WSREP_SST_OPT_ADDR%/*}
+TIMEOUTclose = 0
+verifyPeer = yes
+EOF
+
+ if [ $WSREP_SST_OPT_BYPASS -eq 0 ]
+ then
+
+ FLUSHED="$WSREP_SST_OPT_DATA/tables_flushed"
+ ERROR="$WSREP_SST_OPT_DATA/sst_error"
+
+ rm -rf "$FLUSHED"
+ rm -rf "$ERROR"
+
+ # Use deltaxfer only for WAN
+ inv=$(basename $0)
+ [ "$inv" = "wsrep_sst_rsync_wan" ] && WHOLE_FILE_OPT="" \
+ || WHOLE_FILE_OPT="--whole-file"
+
+ echo "flush tables"
+
+ # Wait for :
+ # (a) Tables to be flushed, AND
+ # (b) Cluster state ID & wsrep_gtid_domain_id to be written to the file, OR
+ # (c) ERROR file, in case flush tables operation failed.
+
+ while [ ! -r "$FLUSHED" ] && ! grep -q ':' "$FLUSHED" >/dev/null 2>&1
+ do
+ # Check whether ERROR file exists.
+ if [ -f "$ERROR" ]
+ then
+ # Flush tables operation failed.
+ rm -rf "$ERROR"
+ exit 255
+ fi
+
+ sleep 0.2
+ done
+
+ STATE="$(cat $FLUSHED)"
+ rm -rf "$FLUSHED"
+
+ sync
+
+ if ! [ -z $WSREP_SST_OPT_BINLOG ]
+ then
+ # Prepare binlog files
+ OLD_PWD="$(pwd)"
+ cd $BINLOG_DIRNAME
+
+ if ! [ -z $WSREP_SST_OPT_BINLOG_INDEX ]
+ binlog_files_full=$(tail -n $BINLOG_N_FILES ${BINLOG_FILENAME}.index)
+ then
+ cd $BINLOG_INDEX_DIRNAME
+ binlog_files_full=$(tail -n $BINLOG_N_FILES ${BINLOG_INDEX_FILENAME}.index)
+ fi
+
+ cd $BINLOG_DIRNAME
+ binlog_files=""
+ for ii in $binlog_files_full
+ do
+ binlog_files="$binlog_files $(basename $ii)"
+ done
+
+ if ! [ -z "$binlog_files" ]
+ then
+ wsrep_log_info "Preparing binlog files for transfer:"
+ 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
+ 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
+ wsrep_log_error "rsync returned code $RC:"
+
+ case $RC in
+ 12) RC=71 # EPROTO
+ wsrep_log_error \
+ "rsync server on the other end has incompatible protocol. " \
+ "Make sure you have the same version of rsync on all nodes."
+ ;;
+ 22) RC=12 # ENOMEM
+ ;;
+ *) RC=255 # unknown error
+ ;;
+ esac
+ exit $RC
+ fi
+
+ # Transfer InnoDB data files
+ rsync ${STUNNEL:+--rsh="$STUNNEL"} \
+ --owner --group --perms --links --specials \
+ --ignore-times --inplace --dirs --delete --quiet \
+ $WHOLE_FILE_OPT -f '+ /ibdata*' -f '+ /ib_lru_dump' \
+ -f '- **' "$INNODB_DATA_HOME_DIR/" \
+ rsync://$WSREP_SST_OPT_ADDR-data_dir >&2 || RC=$?
+
+ if [ $RC -ne 0 ]; then
+ wsrep_log_error "rsync innodb_data_home_dir returned code $RC:"
+ exit 255 # unknown error
+ fi
+
+ # second, we transfer InnoDB log files
+ rsync ${STUNNEL:+--rsh="$STUNNEL"} \
+ --owner --group --perms --links --specials \
+ --ignore-times --inplace --dirs --delete --quiet \
+ $WHOLE_FILE_OPT -f '+ /ib_logfile[0-9]*' -f '- **' "$WSREP_LOG_DIR/" \
+ rsync://$WSREP_SST_OPT_ADDR-log_dir >&2 || RC=$?
+
+ if [ $RC -ne 0 ]; then
+ wsrep_log_error "rsync innodb_log_group_home_dir returned code $RC:"
+ exit 255 # unknown error
+ fi
+
+ # then, we parallelize the transfer of database directories, use . so that pathconcatenation works
+ OLD_PWD="$(pwd)"
+ cd $WSREP_SST_OPT_DATA
+
+ count=1
+ [ "$OS" == "Linux" ] && count=$(grep -c processor /proc/cpuinfo)
+ [ "$OS" == "Darwin" -o "$OS" == "FreeBSD" ] && count=$(sysctl -n hw.ncpu)
+
+ find . -maxdepth 1 -mindepth 1 -type d -not -name "lost+found" \
+ -print0 | xargs -I{} -0 -P $count \
+ rsync ${STUNNEL:+--rsh="$STUNNEL"} \
+ --owner --group --perms --links --specials \
+ --ignore-times --inplace --recursive --delete --quiet \
+ $WHOLE_FILE_OPT --exclude '*/ib_logfile*' "$WSREP_SST_OPT_DATA"/{}/ \
+ rsync://$WSREP_SST_OPT_ADDR/{} >&2 || RC=$?
+
+ cd "$OLD_PWD"
+
+ if [ $RC -ne 0 ]; then
+ wsrep_log_error "find/rsync returned code $RC:"
+ exit 255 # unknown error
+ 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"
+ rsync ${STUNNEL:+--rsh="$STUNNEL"} \
+ --archive --quiet --checksum "$MAGIC_FILE" rsync://$WSREP_SST_OPT_ADDR
+
+ echo "done $STATE"
+
+elif [ "$WSREP_SST_OPT_ROLE" = "joiner" ]
+then
+ wsrep_check_programs lsof
+
+ touch $SST_PROGRESS_FILE
+ MYSQLD_PID=$WSREP_SST_OPT_PARENT
+
+ MODULE="rsync_sst"
+
+ RSYNC_PID="$WSREP_SST_OPT_DATA/$MODULE.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:0:1} == '[' ]]; 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
+
+ trap "exit 32" HUP PIPE
+ trap "exit 3" INT TERM ABRT
+ trap cleanup_joiner EXIT
+
+ RSYNC_CONF="$WSREP_SST_OPT_DATA/$MODULE.conf"
+
+ if [ -n "${MYSQL_TMP_DIR:-}" ] ; then
+ SILENT="log file = $MYSQL_TMP_DIR/rsyncd.log"
+ else
+ SILENT=""
+ fi
+
+cat << EOF > "$RSYNC_CONF"
+pid file = $RSYNC_PID
+use chroot = no
+read only = no
+timeout = 300
+$SILENT
+[$MODULE]
+ path = $WSREP_SST_OPT_DATA
+[$MODULE-log_dir]
+ path = $WSREP_LOG_DIR
+[$MODULE-data_dir]
+ path = $INNODB_DATA_HOME_DIR
+EOF
+
+# rm -rf "$DATA"/ib_logfile* # we don't want old logs around
+
+ # listen at all interfaces (for firewalled setups)
+ readonly RSYNC_PORT=${WSREP_SST_OPT_PORT:-4444}
+
+cat << EOF > "$STUNNEL_CONF"
+key = $SSTKEY
+cert = $SSTCERT
+foreground = yes
+pid = $STUNNEL_PID
+debug = warning
+client = no
+[rsync]
+accept = $RSYNC_PORT
+exec = $(which rsync)
+execargs = rsync --server --daemon --config=$RSYNC_CONF .
+EOF
+
+ if [ -z "$STUNNEL" ]
+ then
+ # listen at all interfaces (for firewalled setups)
+ rsync --daemon --no-detach --port $RSYNC_PORT --config "$RSYNC_CONF" &
+ RSYNC_REAL_PID=$!
+ else
+ stunnel "$STUNNEL_CONF" &
+ RSYNC_REAL_PID=$!
+ RSYNC_PID=$STUNNEL_PID
+ fi
+
+ until check_pid_and_port $RSYNC_PID $RSYNC_REAL_PID $RSYNC_PORT
+ do
+ sleep 0.2
+ done
+
+ echo "ready $WSREP_SST_OPT_HOST:$RSYNC_PORT/$MODULE"
+
+ # wait for SST to complete by monitoring magic file
+ while [ ! -r "$MAGIC_FILE" ] && check_pid "$RSYNC_PID" && \
+ ps -p $MYSQLD_PID >/dev/null
+ do
+ sleep 1
+ done
+
+ if ! ps -p $MYSQLD_PID >/dev/null
+ then
+ wsrep_log_error \
+ "Parent mysqld process (PID:$MYSQLD_PID) terminated unexpectedly."
+ kill -- -"${MYSQLD_PID}"
+ sleep 1
+ exit 32
+ fi
+
+ if ! [ -z $WSREP_SST_OPT_BINLOG ]
+ then
+
+ OLD_PWD="$(pwd)"
+ cd $BINLOG_DIRNAME
+
+ if [ -f $BINLOG_TAR_FILE ]
+ then
+ # Clean up old binlog files first
+ rm -f ${BINLOG_FILENAME}.*
+ wsrep_log_info "Extracting binlog files:"
+ tar -xvf $BINLOG_TAR_FILE >&2
+ for ii in $(ls -1 ${BINLOG_FILENAME}.*)
+ do
+ if ! [ -z $WSREP_SST_OPT_BINLOG_INDEX ]
+ echo ${BINLOG_DIRNAME}/${ii} >> ${BINLOG_FILENAME}.index
+ then
+ echo ${BINLOG_DIRNAME}/${ii} >> ${BINLOG_INDEX_DIRNAME}/${BINLOG_INDEX_FILENAME}.index
+ fi
+ done
+ fi
+ cd "$OLD_PWD"
+ fi
+ if [ -r "$MAGIC_FILE" ]
+ then
+ # 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
+ wsrep_log_error "Unrecognized role: '$WSREP_SST_OPT_ROLE'"
+ exit 22 # EINVAL
+fi
+
+rm -f $BINLOG_TAR_FILE || :
+
+exit 0
diff --git a/scripts/wsrep_sst_xtrabackup-v2.sh b/scripts/wsrep_sst_xtrabackup-v2.sh
new file mode 100644
index 00000000000..5fad91df18b
--- /dev/null
+++ b/scripts/wsrep_sst_xtrabackup-v2.sh
@@ -0,0 +1,1269 @@
+#!/bin/bash -ue
+# Copyright (C) 2013 Percona Inc
+#
+# 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
+# MA 02110-1301 USA.
+
+# Documentation: http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html
+# Make sure to read that before proceeding!
+
+
+
+
+. $(dirname $0)/wsrep_sst_common
+
+ealgo=""
+ekey=""
+ekeyfile=""
+encrypt=0
+nproc=1
+ecode=0
+ssyslog=""
+ssystag=""
+XTRABACKUP_PID=""
+tca=""
+tcert=""
+tkey=""
+sockopt=""
+progress=""
+ttime=0
+totime=0
+ecmd=""
+rlimit=""
+# Initially
+stagemsg="${WSREP_SST_OPT_ROLE}"
+cpat=""
+ib_home_dir=""
+ib_log_dir=""
+ib_undo_dir=""
+
+sfmt="tar"
+strmcmd=""
+tfmt=""
+tcmd=""
+rebuild=0
+rebuildcmd=""
+payload=0
+pvformat="-F '%N => Rate:%r Avg:%a Elapsed:%t %e Bytes: %b %p' "
+pvopts="-f -i 10 -N $WSREP_SST_OPT_ROLE "
+STATDIR=""
+uextra=0
+disver=""
+
+tmpopts=""
+itmpdir=""
+xtmpdir=""
+
+scomp=""
+sdecomp=""
+ssl_dhparams=""
+
+ssl_cert=""
+ssl_ca=""
+ssl_key=""
+
+if which pv &>/dev/null && pv --help | grep -q FORMAT;then
+ pvopts+=$pvformat
+fi
+pcmd="pv $pvopts"
+declare -a RC
+
+INNOBACKUPEX_BIN=innobackupex
+DATA="${WSREP_SST_OPT_DATA}"
+INFO_FILE="xtrabackup_galera_info"
+IST_FILE="xtrabackup_ist"
+MAGIC_FILE="${DATA}/${INFO_FILE}"
+
+# Setting the path for ss and ip
+export PATH="/usr/sbin:/sbin:$PATH"
+
+OS=$(uname)
+
+if ! which lsof > /dev/null; then
+ wsrep_log_error "lsof tool not found in PATH! Make sure you have it installed."
+ exit 2 # ENOENT
+fi
+
+timeit(){
+ local stage=$1
+ shift
+ local cmd="$@"
+ local x1 x2 took extcode
+
+ if [[ $ttime -eq 1 ]];then
+ x1=$(date +%s)
+ wsrep_log_info "Evaluating $cmd"
+ eval "$cmd"
+ extcode=$?
+ x2=$(date +%s)
+ took=$(( x2-x1 ))
+ wsrep_log_info "NOTE: $stage took $took seconds"
+ totime=$(( totime+took ))
+ else
+ wsrep_log_info "Evaluating $cmd"
+ eval "$cmd"
+ extcode=$?
+ fi
+ return $extcode
+}
+
+get_keys()
+{
+ # $encrypt -eq 1 is for internal purposes only
+ if [[ $encrypt -ge 2 || $encrypt -eq -1 ]];then
+ return
+ fi
+
+ if [[ $encrypt -eq 0 ]];then
+ if $MY_PRINT_DEFAULTS xtrabackup | grep -q encrypt;then
+ wsrep_log_error "Unexpected option combination. SST may fail. Refer to http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html "
+ fi
+ return
+ fi
+
+ if [[ $sfmt == 'tar' ]];then
+ wsrep_log_info "NOTE: Xtrabackup-based encryption - encrypt=1 - cannot be enabled with tar format"
+ encrypt=-1
+ return
+ fi
+
+ wsrep_log_info "Xtrabackup based encryption enabled in my.cnf - Supported only from Xtrabackup 2.1.4"
+
+ if [[ -z $ealgo ]];then
+ wsrep_log_error "FATAL: Encryption algorithm empty from my.cnf, bailing out"
+ exit 3
+ fi
+
+ if [[ -z $ekey && ! -r $ekeyfile ]];then
+ wsrep_log_error "FATAL: Either key or keyfile must be readable"
+ exit 3
+ fi
+
+ if [[ -z $ekey ]];then
+ ecmd="xbcrypt --encrypt-algo=$ealgo --encrypt-key-file=$ekeyfile"
+ else
+ wsrep_log_warning "Using the 'encrypt-key' option causes the encryption key"
+ wsrep_log_warning "to be set via the command-line and is considered insecure."
+ wsrep_log_warning "It is recommended to use the 'encrypt-key-file' option instead."
+
+ ecmd="xbcrypt --encrypt-algo=$ealgo --encrypt-key=$ekey"
+ fi
+
+ if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
+ ecmd+=" -d"
+ fi
+
+ stagemsg+="-XB-Encrypted"
+}
+
+#
+# If the ssl_dhparams variable is already set, uses that as a source
+# of dh parameters for OpenSSL. Otherwise, looks for dhparams.pem in the
+# datadir, and creates it there if it can't find the file.
+# No input parameters
+#
+check_for_dhparams()
+{
+ if [[ -z "$ssl_dhparams" ]]; then
+ if ! [[ -r "$DATA/dhparams.pem" ]]; then
+ wsrep_check_programs openssl
+ wsrep_log_info "Could not find dhparams file, creating $DATA/dhparams.pem"
+
+ if ! openssl dhparam -out "$DATA/dhparams.pem" 2048 >/dev/null 2>&1
+ then
+ wsrep_log_error "******** FATAL ERROR ********************************* "
+ wsrep_log_error "* Could not create the dhparams.pem file with OpenSSL. "
+ wsrep_log_error "****************************************************** "
+ exit 22
+ fi
+ fi
+ ssl_dhparams="$DATA/dhparams.pem"
+ fi
+}
+
+#
+# verifies that the certificate matches the private key
+# doing this will save us having to wait for a timeout that would
+# otherwise occur.
+#
+# 1st param: path to the cert
+# 2nd param: path to the private key
+#
+verify_cert_matches_key()
+{
+ local cert_path=$1
+ local key_path=$2
+
+ wsrep_check_programs openssl diff
+
+ # generate the public key from the cert and the key
+ # they should match (otherwise we can't create an SSL connection)
+ if ! diff <(openssl x509 -in "$cert_path" -pubkey -noout) <(openssl rsa -in "$key_path" -pubout 2>/dev/null) >/dev/null 2>&1
+ then
+ wsrep_log_error "******** FATAL ERROR ************************* "
+ wsrep_log_error "* The certifcate and private key do not match. "
+ wsrep_log_error "* Please check your certificate and key files. "
+ wsrep_log_error "********************************************** "
+ exit 22
+ fi
+}
+
+# Checks to see if the file exists
+# If the file does not exist (or cannot be read), issues an error
+# and exits
+#
+# 1st param: file name to be checked (for read access)
+# 2nd param: 1st error message (header)
+# 3rd param: 2nd error message (footer, optional)
+#
+verify_file_exists()
+{
+ local file_path=$1
+ local error_message1=$2
+ local error_message2=$3
+
+ if ! [[ -r "$file_path" ]]; then
+ wsrep_log_error "******** FATAL ERROR ************************* "
+ wsrep_log_error "* $error_message1 "
+ wsrep_log_error "* Could not find/access : $file_path "
+
+ if ! [[ -z "$error_message2" ]]; then
+ wsrep_log_error "* $error_message2 "
+ fi
+
+ wsrep_log_error "********************************************** "
+ exit 22
+ fi
+}
+
+get_transfer()
+{
+ TSST_PORT=${WSREP_SST_OPT_PORT:-4444}
+
+ if [[ $tfmt == 'nc' ]];then
+ if [[ ! -x `which nc` ]];then
+ wsrep_log_error "nc(netcat) not found in path: $PATH"
+ exit 2
+ fi
+
+ if [[ $encrypt -eq 2 || $encrypt -eq 3 || $encrypt -eq 4 ]]; then
+ wsrep_log_error "******** FATAL ERROR *********************** "
+ wsrep_log_error "* Using SSL encryption (encrypt= 2, 3, or 4) "
+ wsrep_log_error "* is not supported when using nc(netcat). "
+ wsrep_log_error "******************************************** "
+ exit 22
+ fi
+
+ wsrep_log_info "Using netcat as streamer"
+ if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
+ if nc -h 2>&1 | grep -q ncat; then
+ # Ncat
+ tcmd="nc $sockopt -l ${TSST_PORT}"
+ elif nc -h 2>&1 | grep -q -- '-d\>';then
+ # Debian netcat
+ tcmd="nc $sockopt -dl ${TSST_PORT}"
+ else
+ # traditional netcat
+ tcmd="nc $sockopt -l -p ${TSST_PORT}"
+ fi
+ else
+ if nc -h 2>&1 | grep -q ncat;then
+ # Ncat
+ tcmd="nc ${WSREP_SST_OPT_HOST_UNESCAPED} ${TSST_PORT}"
+ elif nc -h 2>&1 | grep -q -- '-d\>';then
+ # Debian netcat
+ tcmd="nc ${WSREP_SST_OPT_HOST_UNESCAPED} ${TSST_PORT}"
+ else
+ # traditional netcat
+ tcmd="nc -q0 ${WSREP_SST_OPT_HOST_UNESCAPED} ${TSST_PORT}"
+ fi
+ fi
+ else
+ tfmt='socat'
+ wsrep_log_info "Using socat as streamer"
+ if [[ ! -x `which socat` ]];then
+ wsrep_log_error "socat not found in path: $PATH"
+ exit 2
+ fi
+
+ donor_extra=""
+ joiner_extra=""
+ if [[ $encrypt -eq 2 || $encrypt -eq 3 || $encrypt -eq 4 ]]; then
+ if ! socat -V | grep -q WITH_OPENSSL; then
+ wsrep_log_error "******** FATAL ERROR ****************** "
+ wsrep_log_error "* socat is not openssl enabled. "
+ wsrep_log_error "* Unable to encrypt SST communications. "
+ wsrep_log_error "*************************************** "
+ exit 2
+ fi
+
+ # Determine the socat version
+ SOCAT_VERSION=`socat -V 2>&1 | grep -oe '[0-9]\.[0-9][\.0-9]*' | head -n1`
+ if [[ -z "$SOCAT_VERSION" ]]; then
+ wsrep_log_error "******** FATAL ERROR **************** "
+ wsrep_log_error "* Cannot determine the socat version. "
+ wsrep_log_error "************************************* "
+ exit 2
+ fi
+
+ # socat versions < 1.7.3 will have 512-bit dhparams (too small)
+ # so create 2048-bit dhparams and send that as a parameter
+ # socat version >= 1.7.3, checks to see if the peername matches the hostname
+ # set commonname="" to disable the peername checks
+ #
+ if ! check_for_version "$SOCAT_VERSION" "1.7.3"; then
+ if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]]; then
+ # dhparams check (will create ssl_dhparams if needed)
+ check_for_dhparams
+ joiner_extra=",dhparam=$ssl_dhparams"
+ fi
+ fi
+ if check_for_version "$SOCAT_VERSION" "1.7.3"; then
+ donor_extra=',commonname=""'
+ fi
+ fi
+
+ if [[ $encrypt -eq 2 ]]; then
+ wsrep_log_warning "**** WARNING **** encrypt=2 is deprecated and will be removed in a future release"
+ wsrep_log_info "Using openssl based encryption with socat: with crt and ca"
+
+ verify_file_exists "$tcert" "Both certificate and CA files are required." \
+ "Please check the 'tcert' option. "
+ verify_file_exists "$tca" "Both certificate and CA files are required." \
+ "Please check the 'tca' option. "
+
+ stagemsg+="-OpenSSL-Encrypted-2"
+ if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
+ wsrep_log_info "Decrypting with CERT: $tcert, CA: $tca"
+ tcmd="socat -u openssl-listen:${TSST_PORT},reuseaddr,cert=${tcert},cafile=${tca}${joiner_extra}${sockopt} stdio"
+ else
+ wsrep_log_info "Encrypting with CERT: $tcert, CA: $tca"
+ tcmd="socat -u stdio openssl-connect:${WSREP_SST_OPT_HOST}:${TSST_PORT},cert=${tcert},cafile=${tca}${donor_extra}${sockopt}"
+ fi
+ elif [[ $encrypt -eq 3 ]];then
+ wsrep_log_warning "**** WARNING **** encrypt=3 is deprecated and will be removed in a future release"
+ wsrep_log_info "Using openssl based encryption with socat: with key and crt"
+
+ verify_file_exists "$tcert" "Both certificate and key files are required." \
+ "Please check the 'tcert' option. "
+ verify_file_exists "$tkey" "Both certificate and key files are required." \
+ "Please check the 'tkey' option. "
+
+ stagemsg+="-OpenSSL-Encrypted-3"
+ if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
+ wsrep_log_info "Decrypting with CERT: $tcert, KEY: $tkey"
+ tcmd="socat -u openssl-listen:${TSST_PORT},reuseaddr,cert=${tcert},key=${tkey},verify=0${joiner_extra}${sockopt} stdio"
+ else
+ wsrep_log_info "Encrypting with CERT: $tcert, KEY: $tkey"
+ tcmd="socat -u stdio openssl-connect:${WSREP_SST_OPT_HOST}:${TSST_PORT},cert=${tcert},key=${tkey},verify=0${sockopt}"
+ fi
+ elif [[ $encrypt -eq 4 ]]; then
+ wsrep_log_info "Using openssl based encryption with socat: with key, crt, and ca"
+
+ verify_file_exists "$ssl_ca" "CA, certificate, and key files are required." \
+ "Please check the 'ssl-ca' option. "
+ verify_file_exists "$ssl_cert" "CA, certificate, and key files are required." \
+ "Please check the 'ssl-cert' option. "
+ verify_file_exists "$ssl_key" "CA, certificate, and key files are required." \
+ "Please check the 'ssl-key' option. "
+
+ # Check to see that the key matches the cert
+ verify_cert_matches_key $ssl_cert $ssl_key
+
+ stagemsg+="-OpenSSL-Encrypted-4"
+ if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]]; then
+ wsrep_log_info "Decrypting with CERT: $ssl_cert, KEY: $ssl_key, CA: $ssl_ca"
+ tcmd="socat -u openssl-listen:${TSST_PORT},reuseaddr,cert=${ssl_cert},key=${ssl_key},cafile=${ssl_ca},verify=1${joiner_extra}${sockopt} stdio"
+ else
+ wsrep_log_info "Encrypting with CERT: $ssl_cert, KEY: $ssl_key, CA: $ssl_ca"
+ tcmd="socat -u stdio openssl-connect:${WSREP_SST_OPT_HOST}:${TSST_PORT},cert=${ssl_cert},key=${ssl_key},cafile=${ssl_ca},verify=1${donor_extra}${sockopt}"
+ fi
+
+ else
+ if [[ $encrypt -eq 1 ]]; then
+ wsrep_log_warning "**** WARNING **** encrypt=1 is deprecated and will be removed in a future release"
+ fi
+
+ if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]]; then
+ tcmd="socat -u TCP-LISTEN:${TSST_PORT},reuseaddr${sockopt} stdio"
+ else
+ tcmd="socat -u stdio TCP:${WSREP_SST_OPT_HOST}:${TSST_PORT}${sockopt}"
+ fi
+ fi
+ fi
+}
+
+get_footprint()
+{
+ pushd $WSREP_SST_OPT_DATA 1>/dev/null
+ payload=$(find . -regex '.*\.ibd$\|.*\.MYI$\|.*\.MYD$\|.*ibdata1$' -type f -print0 | du --files0-from=- --block-size=1 -c -s | awk 'END { print $1 }')
+ if $MY_PRINT_DEFAULTS xtrabackup | grep -q -- "--compress";then
+ # QuickLZ has around 50% compression ratio
+ # When compression/compaction used, the progress is only an approximate.
+ payload=$(( payload*1/2 ))
+ fi
+ popd 1>/dev/null
+ pcmd+=" -s $payload"
+ adjust_progress
+}
+
+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"
+ else
+ pcmd+=" 2>$progress"
+ fi
+ elif [[ -z $progress && -n $rlimit ]];then
+ # When rlimit is non-zero
+ pcmd="pv -q"
+ fi
+
+ if [[ -n $rlimit && "$WSREP_SST_OPT_ROLE" == "donor" ]];then
+ wsrep_log_info "Rate-limiting SST to $rlimit"
+ pcmd+=" -L \$rlimit"
+ fi
+}
+
+read_cnf()
+{
+ sfmt=$(parse_cnf sst streamfmt "xbstream")
+ tfmt=$(parse_cnf sst transferfmt "socat")
+ tca=$(parse_cnf sst tca "")
+ tcert=$(parse_cnf sst tcert "")
+ tkey=$(parse_cnf sst tkey "")
+ encrypt=$(parse_cnf sst encrypt 0)
+ sockopt=$(parse_cnf sst sockopt "")
+ progress=$(parse_cnf sst progress "")
+ rebuild=$(parse_cnf sst rebuild 0)
+ ttime=$(parse_cnf sst time 0)
+ if [ "${OS}" = "FreeBSD" ]; then
+ cpat=$(parse_cnf sst cpat '.*\.pem$|.*init\.ok$|.*galera\.cache$|.*sst_in_progress$|.*\.sst$|.*gvwstate\.dat$|.*grastate\.dat$|.*\.err$|.*\.log$|.*RPM_UPGRADE_MARKER$|.*RPM_UPGRADE_HISTORY$')
+ else
+ cpat=$(parse_cnf sst cpat '.*\.pem$\|.*init\.ok$\|.*galera\.cache$\|.*sst_in_progress$\|.*\.sst$\|.*gvwstate\.dat$\|.*grastate\.dat$\|.*\.err$\|.*\.log$\|.*RPM_UPGRADE_MARKER$\|.*RPM_UPGRADE_HISTORY$')
+ fi
+ ealgo=$(parse_cnf xtrabackup encrypt "")
+ ekey=$(parse_cnf xtrabackup encrypt-key "")
+ ekeyfile=$(parse_cnf xtrabackup encrypt-key-file "")
+ scomp=$(parse_cnf sst compressor "")
+ sdecomp=$(parse_cnf sst decompressor "")
+
+
+ # Refer to http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html
+ if [[ -z $ealgo ]];then
+ ealgo=$(parse_cnf sst encrypt-algo "")
+ ekey=$(parse_cnf sst encrypt-key "")
+ ekeyfile=$(parse_cnf sst encrypt-key-file "")
+ fi
+
+ # Pull the parameters needed for encrypt=4
+ ssl_ca=$(parse_cnf sst ssl-ca "")
+ if [[ -z "$ssl_ca" ]]; then
+ ssl_ca=$(parse_cnf --mysqld ssl-ca "")
+ fi
+ ssl_cert=$(parse_cnf sst ssl-cert "")
+ if [[ -z "$ssl_cert" ]]; then
+ ssl_cert=$(parse_cnf --mysqld ssl-cert "")
+ fi
+ ssl_key=$(parse_cnf sst ssl-key "")
+ if [[ -z "$ssl_key" ]]; then
+ ssl_key=$(parse_cnf --mysqld ssl-key "")
+ fi
+
+ rlimit=$(parse_cnf sst rlimit "")
+ uextra=$(parse_cnf sst use-extra 0)
+ iopts=$(parse_cnf sst inno-backup-opts "")
+ 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 [[ $ssyslog -ne -1 ]];then
+ if $MY_PRINT_DEFAULTS mysqld_safe | grep -q -- "--syslog";then
+ ssyslog=1
+ fi
+ fi
+}
+
+get_stream()
+{
+ if [[ $sfmt == 'xbstream' ]];then
+ wsrep_log_info "Streaming with xbstream"
+ if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
+ strmcmd="xbstream -x"
+ else
+ strmcmd="xbstream -c \${INFO_FILE}"
+ fi
+ else
+ sfmt="tar"
+ wsrep_log_info "Streaming with tar"
+ if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
+ strmcmd="tar xfi - "
+ else
+ strmcmd="tar cf - \${INFO_FILE} "
+ fi
+
+ fi
+}
+
+get_proc()
+{
+ set +e
+ nproc=$(grep -c processor /proc/cpuinfo)
+ [[ -z $nproc || $nproc -eq 0 ]] && nproc=1
+ set -e
+}
+
+sig_joiner_cleanup()
+{
+ wsrep_log_error "Removing $MAGIC_FILE file due to signal"
+ rm -f "$MAGIC_FILE"
+}
+
+cleanup_joiner()
+{
+ # Since this is invoked just after exit NNN
+ local estatus=$?
+ if [[ $estatus -ne 0 ]];then
+ wsrep_log_error "Cleanup after exit with status:$estatus"
+ elif [ "${WSREP_SST_OPT_ROLE}" = "joiner" ];then
+ wsrep_log_info "Removing the sst_in_progress file"
+ wsrep_cleanup_progress_file
+ fi
+ if [[ -n $progress && -p $progress ]];then
+ wsrep_log_info "Cleaning up fifo file $progress"
+ rm $progress
+ fi
+ 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()
+{
+ local pid_file="$1"
+ [ -r "$pid_file" ] && ps -p $(cat "$pid_file") >/dev/null 2>&1
+}
+
+cleanup_donor()
+{
+ # Since this is invoked just after exit NNN
+ local estatus=$?
+ if [[ $estatus -ne 0 ]];then
+ wsrep_log_error "Cleanup after exit with status:$estatus"
+ fi
+
+ if [[ -n ${XTRABACKUP_PID:-} ]];then
+ if check_pid $XTRABACKUP_PID
+ then
+ wsrep_log_error "xtrabackup process is still running. Killing... "
+ kill_xtrabackup
+ fi
+
+ fi
+ rm -f ${DATA}/${IST_FILE} || true
+
+ if [[ -n $progress && -p $progress ]];then
+ wsrep_log_info "Cleaning up fifo file $progress"
+ rm -f $progress || true
+ fi
+
+ wsrep_log_info "Cleaning up temporary directories"
+
+ if [[ -n $xtmpdir ]];then
+ [[ -d $xtmpdir ]] && rm -rf $xtmpdir || true
+ fi
+
+ 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()
+{
+ local PID=$(cat $XTRABACKUP_PID)
+ [ -n "$PID" -a "0" != "$PID" ] && kill $PID && (kill $PID && kill -9 $PID) || :
+ wsrep_log_info "Removing xtrabackup pid file $XTRABACKUP_PID"
+ rm -f "$XTRABACKUP_PID" || true
+}
+
+# waits ~1 minute for nc/socat to open the port and then reports ready
+# (regardless of timeout)
+wait_for_listen()
+{
+ local HOST=$1
+ local PORT=$2
+ local MODULE=$3
+ local LSOF_OUT
+
+ for i in {1..300}
+ do
+ LSOF_OUT=$(lsof -sTCP:LISTEN -i TCP:${PORT} -a -c nc -c socat -F c 2> /dev/null || :)
+ [ -n "${LSOF_OUT}" ] && break
+ sleep 0.2
+ done
+
+ echo "ready ${HOST}:${PORT}/${MODULE}//${WSREP_SST_OPT_SST_VER:-1}"
+}
+
+check_extra()
+{
+ local use_socket=1
+ if [[ $uextra -eq 1 ]];then
+ if [ $(parse_cnf --mysqld thread-handling) = 'pool-of-threads'];then
+ local eport=$(parse_cnf --mysqld extra-port)
+ if [[ -n $eport ]];then
+ # Xtrabackup works only locally.
+ # Hence, setting host to 127.0.0.1 unconditionally.
+ wsrep_log_info "SST through extra_port $eport"
+ INNOEXTRA+=" --host=127.0.0.1 --port=$eport "
+ use_socket=0
+ else
+ wsrep_log_error "Extra port $eport null, failing"
+ exit 1
+ fi
+ else
+ wsrep_log_info "Thread pool not set, ignore the option use_extra"
+ fi
+ fi
+ if [[ $use_socket -eq 1 ]] && [[ -n "${WSREP_SST_OPT_SOCKET}" ]];then
+ INNOEXTRA+=" --socket=${WSREP_SST_OPT_SOCKET}"
+ fi
+}
+
+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
+
+ if [[ $tmt -gt 0 && -x `which timeout` ]];then
+ if timeout --help | grep -q -- '-k';then
+ ltcmd="timeout -k $(( tmt+10 )) $tmt $tcmd"
+ else
+ ltcmd="timeout -s9 $tmt $tcmd"
+ fi
+ timeit "$msg" "$ltcmd | $strmcmd; RC=( "\${PIPESTATUS[@]}" )"
+ else
+ timeit "$msg" "$tcmd | $strmcmd; RC=( "\${PIPESTATUS[@]}" )"
+ fi
+
+ set -e
+ popd 1>/dev/null
+
+ if [[ ${RC[0]} -eq 124 ]];then
+ wsrep_log_error "Possible timeout in receving first data from donor in gtid stage"
+ exit 32
+ fi
+
+ for ecode in "${RC[@]}";do
+ if [[ $ecode -ne 0 ]];then
+ wsrep_log_error "Error while getting data from donor node: " \
+ "exit codes: ${RC[@]}"
+ exit 32
+ fi
+ done
+
+ 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"
+ wsrep_log_info "$(ls -l ${dir}/*)"
+ exit 32
+ fi
+}
+
+
+send_donor()
+{
+ local dir=$1
+ local msg=$2
+
+ pushd ${dir} 1>/dev/null
+ set +e
+ timeit "$msg" "$strmcmd | $tcmd; RC=( "\${PIPESTATUS[@]}" )"
+ set -e
+ popd 1>/dev/null
+
+
+ for ecode in "${RC[@]}";do
+ if [[ $ecode -ne 0 ]];then
+ wsrep_log_error "Error while getting data from donor node: " \
+ "exit codes: ${RC[@]}"
+ exit 32
+ fi
+ done
+
+}
+
+# Returns the version string in a standardized format
+# Input "1.2.3" => echoes "010203"
+# Wrongly formatted values => echoes "000000"
+normalize_version()
+{
+ local major=0
+ local minor=0
+ local patch=0
+
+ # Only parses purely numeric version numbers, 1.2.3
+ # Everything after the first three values are ignored
+ if [[ $1 =~ ^([0-9]+)\.([0-9]+)\.?([0-9]*)([\.0-9])*$ ]]; then
+ major=${BASH_REMATCH[1]}
+ minor=${BASH_REMATCH[2]}
+ patch=${BASH_REMATCH[3]}
+ fi
+
+ printf %02d%02d%02d $major $minor $patch
+}
+
+# Compares two version strings
+# The first parameter is the version to be checked
+# The second parameter is the minimum version required
+# Returns 1 (failure) if $1 >= $2, 0 (success) otherwise
+check_for_version()
+{
+ local local_version_str="$( normalize_version $1 )"
+ local required_version_str="$( normalize_version $2 )"
+
+ if [[ "$local_version_str" < "$required_version_str" ]]; then
+ return 1
+ else
+ return 0
+ fi
+}
+
+monitor_process()
+{
+ local sst_stream_pid=$1
+
+ while true ; do
+
+ if ! ps --pid "${WSREP_SST_OPT_PARENT}" &>/dev/null; then
+ wsrep_log_error "Parent mysqld process (PID:${WSREP_SST_OPT_PARENT}) terminated unexpectedly."
+ kill -- -"${WSREP_SST_OPT_PARENT}"
+ exit 32
+ fi
+
+ if ! ps --pid "${sst_stream_pid}" &>/dev/null; then
+ break
+ fi
+
+ sleep 0.1
+
+ done
+}
+
+
+if [[ ! -x `which $INNOBACKUPEX_BIN` ]];then
+ wsrep_log_error "innobackupex not in path: $PATH"
+ exit 2
+fi
+
+# check the version, we require XB-2.4 to ensure that we can pass the
+# datadir via the command-line option
+XB_REQUIRED_VERSION="2.3.5"
+
+XB_VERSION=`$INNOBACKUPEX_BIN --version 2>&1 | grep -oe '[0-9]\.[0-9][\.0-9]*' | head -n1`
+if [[ -z $XB_VERSION ]]; then
+ wsrep_log_error "FATAL: Cannot determine the $INNOBACKUPEX_BIN version. Needs xtrabackup-$XB_REQUIRED_VERSION or higher to perform SST"
+ exit 2
+fi
+
+if ! check_for_version $XB_VERSION $XB_REQUIRED_VERSION; then
+ wsrep_log_error "FATAL: The $INNOBACKUPEX_BIN version is $XB_VERSION. Needs xtrabackup-$XB_REQUIRED_VERSION or higher to perform SST"
+ exit 2
+fi
+
+
+rm -f "${MAGIC_FILE}"
+
+if [[ ! ${WSREP_SST_OPT_ROLE} == 'joiner' && ! ${WSREP_SST_OPT_ROLE} == 'donor' ]];then
+ wsrep_log_error "Invalid role ${WSREP_SST_OPT_ROLE}"
+ exit 22
+fi
+
+read_cnf
+
+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=""
+
+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="2>&1 | logger -p daemon.err -t ${ssystag}innobackupex-apply "
+ INNOMOVE="2>&1 | logger -p daemon.err -t ${ssystag}innobackupex-move "
+ INNOBACKUP="2> >(logger -p daemon.err -t ${ssystag}innobackupex-backup)"
+ fi
+
+else
+ INNOAPPLY="&>\${DATA}/innobackup.prepare.log"
+ INNOMOVE="&>\${DATA}/innobackup.move.log"
+ INNOBACKUP="2>\${DATA}/innobackup.backup.log"
+fi
+
+get_stream
+get_transfer
+
+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 INNODB_DATA_HOME_DIR env. 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 "")
+fi
+if [ ! -z "$INNODB_DATA_HOME_DIR" ]; then
+ INNOEXTRA+=" --innodb-data-home-dir=$INNODB_DATA_HOME_DIR"
+fi
+
+if [ -n "$INNODB_DATA_HOME_DIR" ]; then
+ # handle both relative and absolute paths
+ INNODB_DATA_HOME_DIR=$(cd $DATA; mkdir -p "$INNODB_DATA_HOME_DIR"; cd $INNODB_DATA_HOME_DIR; pwd -P)
+else
+ # default to datadir
+ INNODB_DATA_HOME_DIR=$(cd $DATA; pwd -P)
+fi
+
+INNOAPPLY="${INNOBACKUPEX_BIN} $disver $iapts \$INNOEXTRA --apply-log \$rebuildcmd \${DATA} ${INNOAPPLY}"
+INNOMOVE="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} $disver $impts --move-back --force-non-empty-directories \${DATA} ${INNOMOVE}"
+INNOBACKUP="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} $disver $iopts \$tmpopts \$INNOEXTRA --galera-info --stream=\$sfmt \$itmpdir ${INNOBACKUP}"
+
+if [ "$WSREP_SST_OPT_ROLE" = "donor" ]
+then
+ trap cleanup_donor EXIT
+
+ if [ $WSREP_SST_OPT_BYPASS -eq 0 ]
+ then
+ usrst=0
+ if [[ -z $WSREP_SST_OPT_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)
+ tmpopts=" --tmpdir=$xtmpdir "
+ wsrep_log_info "Using $xtmpdir as xtrabackup temporary directory"
+ fi
+
+ itmpdir=$(mktemp -d)
+ wsrep_log_info "Using $itmpdir as innobackupex temporary directory"
+
+ if [[ -n "${WSREP_SST_OPT_USER:-}" && "$WSREP_SST_OPT_USER" != "(null)" ]]; then
+ INNOEXTRA+=" --user=$WSREP_SST_OPT_USER"
+ usrst=1
+ fi
+
+ if [ -n "${WSREP_SST_OPT_PSWD:-}" ]; then
+ INNOEXTRA+=" --password=$WSREP_SST_OPT_PSWD"
+ elif [[ $usrst -eq 1 ]];then
+ # Empty password, used for testing, debugging etc.
+ INNOEXTRA+=" --password="
+ fi
+
+ get_keys
+ check_extra
+
+ wsrep_log_info "Streaming GTID file before SST"
+
+ # Store donor's wsrep GTID (state ID) and wsrep_gtid_domain_id
+ # (separated by a space).
+ echo "${WSREP_SST_OPT_GTID} ${WSREP_SST_OPT_GTID_DOMAIN_ID}" > "${MAGIC_FILE}"
+
+ ttcmd="$tcmd"
+
+ if [[ $encrypt -eq 1 ]];then
+ if [[ -n $scomp ]];then
+ tcmd=" \$ecmd | $scomp | $tcmd "
+ else
+ tcmd=" \$ecmd | $tcmd "
+ fi
+ elif [[ -n $scomp ]];then
+ tcmd=" $scomp | $tcmd "
+ fi
+
+ send_donor $DATA "${stagemsg}-gtid"
+
+ # Restore the transport commmand to its original state
+ tcmd="$ttcmd"
+ if [[ -n $progress ]];then
+ get_footprint
+ tcmd="$pcmd | $tcmd"
+ elif [[ -n $rlimit ]];then
+ adjust_progress
+ tcmd="$pcmd | $tcmd"
+ fi
+
+ wsrep_log_info "Sleeping before data transfer for SST"
+ sleep 10
+
+ wsrep_log_info "Streaming the backup to joiner at ${WSREP_SST_OPT_HOST} ${WSREP_SST_OPT_PORT:-4444}"
+
+ # Add compression to the head of the stream (if specified)
+ if [[ -n $scomp ]]; then
+ tcmd="$scomp | $tcmd"
+ fi
+
+ # Add encryption to the head of the stream (if specified)
+ if [[ $encrypt -eq 1 ]]; then
+ tcmd=" \$ecmd | $tcmd "
+ fi
+
+ set +e
+ timeit "${stagemsg}-SST" "$INNOBACKUP | $tcmd; RC=( "\${PIPESTATUS[@]}" )"
+ set -e
+
+ if [ ${RC[0]} -ne 0 ]; then
+ wsrep_log_error "${INNOBACKUPEX_BIN} finished with error: ${RC[0]}. " \
+ "Check ${DATA}/innobackup.backup.log"
+ exit 22
+ elif [[ ${RC[$(( ${#RC[@]}-1 ))]} -eq 1 ]];then
+ wsrep_log_error "$tcmd finished with error: ${RC[1]}"
+ exit 22
+ fi
+
+ # innobackupex implicitly writes PID to fixed location in $xtmpdir
+ XTRABACKUP_PID="$xtmpdir/xtrabackup_pid"
+
+
+ else # BYPASS FOR IST
+
+ wsrep_log_info "Bypassing the SST for IST"
+ echo "continue" # now server can resume updating data
+
+ # Store donor's wsrep GTID (state ID) and wsrep_gtid_domain_id
+ # (separated by a space).
+ echo "${WSREP_SST_OPT_GTID} ${WSREP_SST_OPT_GTID_DOMAIN_ID}" > "${MAGIC_FILE}"
+ echo "1" > "${DATA}/${IST_FILE}"
+ get_keys
+ if [[ $encrypt -eq 1 ]];then
+ if [[ -n $scomp ]];then
+ tcmd=" \$ecmd | $scomp | $tcmd "
+ else
+ tcmd=" \$ecmd | $tcmd "
+ fi
+ elif [[ -n $scomp ]];then
+ tcmd=" $scomp | $tcmd "
+ fi
+ strmcmd+=" \${IST_FILE}"
+
+ send_donor $DATA "${stagemsg}-IST"
+
+ fi
+
+ echo "done ${WSREP_SST_OPT_GTID}"
+ wsrep_log_info "Total time on donor: $totime seconds"
+
+elif [ "${WSREP_SST_OPT_ROLE}" = "joiner" ]
+then
+ [[ -e $SST_PROGRESS_FILE ]] && wsrep_log_info "Stale sst_in_progress file: $SST_PROGRESS_FILE"
+ [[ -n $SST_PROGRESS_FILE ]] && touch $SST_PROGRESS_FILE
+
+ ib_home_dir=$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"
+
+ sencrypted=1
+ nthreads=1
+
+ MODULE="xtrabackup_sst"
+
+ rm -f "${DATA}/${IST_FILE}"
+
+ # May need xtrabackup_checkpoints later on
+ rm -f ${DATA}/xtrabackup_binary ${DATA}/xtrabackup_galera_info ${DATA}/xtrabackup_logfile
+
+ wait_for_listen ${WSREP_SST_OPT_HOST} ${WSREP_SST_OPT_PORT:-4444} ${MODULE} &
+
+ trap sig_joiner_cleanup HUP PIPE INT TERM
+ trap cleanup_joiner EXIT
+
+ if [[ -n $progress ]];then
+ adjust_progress
+ tcmd+=" | $pcmd"
+ fi
+
+ get_keys
+ if [[ $encrypt -eq 1 && $sencrypted -eq 1 ]];then
+ if [[ -n $sdecomp ]];then
+ strmcmd=" $sdecomp | \$ecmd | $strmcmd"
+ else
+ strmcmd=" \$ecmd | $strmcmd"
+ fi
+ elif [[ -n $sdecomp ]];then
+ strmcmd=" $sdecomp | $strmcmd"
+ fi
+
+ STATDIR=$(mktemp -d)
+ MAGIC_FILE="${STATDIR}/${INFO_FILE}"
+ recv_joiner $STATDIR "${stagemsg}-gtid" $stimeout 1
+
+
+ if ! ps -p ${WSREP_SST_OPT_PARENT} &>/dev/null
+ then
+ wsrep_log_error "Parent mysqld process (PID:${WSREP_SST_OPT_PARENT}) terminated unexpectedly."
+ exit 32
+ fi
+
+ if [ ! -r "${STATDIR}/${IST_FILE}" ]
+ then
+
+ if [[ -d ${DATA}/.sst ]];then
+ wsrep_log_info "WARNING: Stale temporary SST directory: ${DATA}/.sst from previous state transfer. Removing"
+ rm -rf ${DATA}/.sst
+ fi
+ mkdir -p ${DATA}/.sst
+ (recv_joiner $DATA/.sst "${stagemsg}-SST" 0 0) &
+ jpid=$!
+ wsrep_log_info "Proceeding with SST"
+
+
+ wsrep_log_info "Cleaning the existing datadir and innodb-data/log directories"
+ if [ "${OS}" = "FreeBSD" ]; then
+ find -E $ib_home_dir $ib_log_dir $ib_undo_dir $DATA -mindepth 1 -prune -regex $cpat -o -exec rm -rfv {} 1>&2 \+
+ else
+ find $ib_home_dir $ib_log_dir $ib_undo_dir $DATA -mindepth 1 -prune -regex $cpat -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 \+ || true
+ rm $binlog_dir/*.index || true
+ fi
+ fi
+
+
+
+ TDATA=${DATA}
+ DATA="${DATA}/.sst"
+
+
+ MAGIC_FILE="${DATA}/${INFO_FILE}"
+ wsrep_log_info "Waiting for SST streaming to complete!"
+ monitor_process $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"
+ rebuild=1
+ fi
+
+ if [[ $rebuild -eq 1 ]];then
+ nthreads=$(parse_cnf xtrabackup rebuild-threads $nproc)
+ wsrep_log_info "Rebuilding during prepare with $nthreads threads"
+ rebuildcmd="--rebuild-indexes --rebuild-threads=$nthreads"
+ fi
+
+ if test -n "$(find ${DATA} -maxdepth 1 -type f -name '*.qp' -print -quit)";then
+
+ wsrep_log_info "Compressed qpress files found"
+
+ if [[ ! -x `which qpress` ]];then
+ wsrep_log_error "qpress not found in path: $PATH"
+ exit 22
+ fi
+
+ if [[ -n $progress ]] && pv --help | grep -q 'line-mode';then
+ count=$(find ${DATA} -type f -name '*.qp' | wc -l)
+ count=$(( count*2 ))
+ if pv --help | grep -q FORMAT;then
+ pvopts="-f -s $count -l -N Decompression -F '%N => Rate:%r Elapsed:%t %e Progress: [%b/$count]'"
+ else
+ pvopts="-f -s $count -l -N Decompression"
+ fi
+ pcmd="pv $pvopts"
+ adjust_progress
+ dcmd="$pcmd | xargs -n 2 qpress -T${nproc}d"
+ else
+ dcmd="xargs -n 2 qpress -T${nproc}d"
+ fi
+
+
+ # Decompress the qpress files
+ wsrep_log_info "Decompression with $nproc threads"
+ timeit "Joiner-Decompression" "find ${DATA} -type f -name '*.qp' -printf '%p\n%h\n' | $dcmd"
+ extcode=$?
+
+ if [[ $extcode -eq 0 ]];then
+ wsrep_log_info "Removing qpress files after decompression"
+ find ${DATA} -type f -name '*.qp' -delete
+ if [[ $? -ne 0 ]];then
+ wsrep_log_error "Something went wrong with deletion of qpress files. Investigate"
+ fi
+ else
+ wsrep_log_error "Decompression failed. Exit code: $extcode"
+ exit 22
+ fi
+ fi
+
+
+ if [[ ! -z $WSREP_SST_OPT_BINLOG ]];then
+
+ BINLOG_DIRNAME=$(dirname $WSREP_SST_OPT_BINLOG)
+ BINLOG_FILENAME=$(basename $WSREP_SST_OPT_BINLOG)
+
+ # To avoid comparing data directory and BINLOG_DIRNAME
+ mv $DATA/${BINLOG_FILENAME}.* $BINLOG_DIRNAME/ 2>/dev/null || true
+
+ pushd $BINLOG_DIRNAME &>/dev/null
+ for bfiles in $(ls -1 ${BINLOG_FILENAME}.[0-9]*);do
+ echo ${BINLOG_DIRNAME}/${bfiles} >> ${BINLOG_FILENAME}.index
+ done
+ popd &> /dev/null
+
+ fi
+
+ wsrep_log_info "Preparing the backup at ${DATA}"
+ timeit "Xtrabackup prepare stage" "$INNOAPPLY"
+
+ if [ $? -ne 0 ];
+ then
+ wsrep_log_error "${INNOBACKUPEX_BIN} apply finished with errors. Check ${DATA}/innobackup.prepare.log"
+ exit 22
+ 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
+
+
+ else
+ wsrep_log_info "${IST_FILE} received from donor: Running IST"
+ fi
+
+ if [[ ! -r ${MAGIC_FILE} ]];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
+
+exit 0
diff --git a/scripts/wsrep_sst_xtrabackup.sh b/scripts/wsrep_sst_xtrabackup.sh
new file mode 100644
index 00000000000..5bf380a8144
--- /dev/null
+++ b/scripts/wsrep_sst_xtrabackup.sh
@@ -0,0 +1,701 @@
+#!/bin/bash -ue
+# Copyright (C) 2013 Percona Inc
+#
+# 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
+# MA 02110-1301 USA.
+
+# Optional dependencies and options documented here: http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html
+# Make sure to read that before proceeding!
+
+
+
+
+. $(dirname $0)/wsrep_sst_common
+
+ealgo=""
+ekey=""
+ekeyfile=""
+encrypt=0
+nproc=1
+ecode=0
+XTRABACKUP_PID=""
+tcert=""
+tpem=""
+sockopt=""
+progress=""
+ttime=0
+totime=0
+lsn="${WSREP_SST_OPT_LSN}"
+incremental=0
+ecmd=""
+rlimit=""
+
+sfmt="tar"
+strmcmd=""
+tfmt=""
+tcmd=""
+rebuild=0
+rebuildcmd=""
+payload=0
+pvformat="-F '%N => Rate:%r Avg:%a Elapsed:%t %e Bytes: %b %p' "
+pvopts="-f -i 10 -N $WSREP_SST_OPT_ROLE "
+uextra=0
+
+if which pv &>/dev/null && pv --help | grep -q FORMAT;then
+ pvopts+=$pvformat
+fi
+pcmd="pv $pvopts"
+declare -a RC
+
+INNOBACKUPEX_BIN=innobackupex
+DATA="${WSREP_SST_OPT_DATA}"
+INFO_FILE="xtrabackup_galera_info"
+IST_FILE="xtrabackup_ist"
+MAGIC_FILE="${DATA}/${INFO_FILE}"
+
+# Setting the path for ss and ip
+export PATH="/usr/sbin:/sbin:$PATH"
+
+timeit(){
+ local stage=$1
+ shift
+ local cmd="$@"
+ local x1 x2 took extcode
+
+ if [[ $ttime -eq 1 ]];then
+ x1=$(date +%s)
+ wsrep_log_info "Evaluating $cmd"
+ eval "$cmd"
+ extcode=$?
+ x2=$(date +%s)
+ took=$(( x2-x1 ))
+ wsrep_log_info "NOTE: $stage took $took seconds"
+ totime=$(( totime+took ))
+ else
+ wsrep_log_info "Evaluating $cmd"
+ eval "$cmd"
+ extcode=$?
+ fi
+ return $extcode
+}
+
+get_keys()
+{
+ if [[ $encrypt -eq 2 ]];then
+ return
+ fi
+
+ if [[ $encrypt -eq 0 ]];then
+ if $MY_PRINT_DEFAULTS xtrabackup | grep -q encrypt;then
+ wsrep_log_error "Unexpected option combination. SST may fail. Refer to http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html "
+ fi
+ return
+ fi
+
+ if [[ $sfmt == 'tar' ]];then
+ wsrep_log_info "NOTE: Xtrabackup-based encryption - encrypt=1 - cannot be enabled with tar format"
+ encrypt=0
+ return
+ fi
+
+ wsrep_log_info "Xtrabackup based encryption enabled in my.cnf - Supported only from Xtrabackup 2.1.4"
+
+ if [[ -z $ealgo ]];then
+ wsrep_log_error "FATAL: Encryption algorithm empty from my.cnf, bailing out"
+ exit 3
+ fi
+
+ if [[ -z $ekey && ! -r $ekeyfile ]];then
+ wsrep_log_error "FATAL: Either key or keyfile must be readable"
+ exit 3
+ fi
+
+ if [[ -z $ekey ]];then
+ ecmd="xbcrypt --encrypt-algo=$ealgo --encrypt-key-file=$ekeyfile"
+ else
+ ecmd="xbcrypt --encrypt-algo=$ealgo --encrypt-key=$ekey"
+ fi
+
+ if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
+ ecmd+=" -d"
+ fi
+}
+
+get_transfer()
+{
+ TSST_PORT=${WSREP_SST_OPT_PORT:-4444}
+
+ if [[ $tfmt == 'nc' ]];then
+ if [[ ! -x `which nc` ]];then
+ wsrep_log_error "nc(netcat) not found in path: $PATH"
+ exit 2
+ fi
+ wsrep_log_info "Using netcat as streamer"
+ if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
+ if nc -h 2>&1 | grep -q ncat;then
+ # Ncat
+ tcmd="nc -l ${TSST_PORT}"
+ elif nc -h 2>&1 | grep -q -- '-d\>';then
+ # Debian netcat
+ tcmd="nc -dl ${TSST_PORT}"
+ else
+ # traditional netcat
+ tcmd="nc -l -p ${TSST_PORT}"
+ fi
+ else
+ if nc -h 2>&1 | grep -q ncat;then
+ # Ncat
+ tcmd="nc ${REMOTEIP} ${TSST_PORT}"
+ elif nc -h 2>&1 | grep -q -- '-d\>';then
+ # Debian netcat
+ tcmd="nc ${REMOTEIP} ${TSST_PORT}"
+ else
+ # traditional netcat
+ tcmd="nc -q0 ${REMOTEIP} ${TSST_PORT}"
+ fi
+ fi
+ else
+ tfmt='socat'
+ wsrep_log_info "Using socat as streamer"
+ if [[ ! -x `which socat` ]];then
+ wsrep_log_error "socat not found in path: $PATH"
+ exit 2
+ fi
+
+ if [[ $encrypt -eq 2 ]] && ! socat -V | grep -q OPENSSL;then
+ wsrep_log_info "NOTE: socat is not openssl enabled, falling back to plain transfer"
+ encrypt=0
+ fi
+
+ if [[ $encrypt -eq 2 ]];then
+ wsrep_log_info "Using openssl based encryption with socat"
+ if [[ -z $tpem || -z $tcert ]];then
+ wsrep_log_error "Both PEM and CRT files required"
+ exit 22
+ fi
+ if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
+ wsrep_log_info "Decrypting with PEM $tpem, CA: $tcert"
+ tcmd="socat -u openssl-listen:${TSST_PORT},reuseaddr,cert=$tpem,cafile=${tcert}${sockopt} stdio"
+ else
+ wsrep_log_info "Encrypting with PEM $tpem, CA: $tcert"
+ tcmd="socat -u stdio openssl-connect:${WSREP_SST_OPT_HOST}:${TSST_PORT},cert=$tpem,cafile=${tcert}${sockopt}"
+ fi
+ else
+ if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
+ tcmd="socat -u TCP-LISTEN:${TSST_PORT},reuseaddr${sockopt} stdio"
+ else
+ tcmd="socat -u stdio TCP:${WSREP_SST_OPT_HOST}:${TSST_PORT}${sockopt}"
+ fi
+ fi
+ fi
+
+}
+
+get_footprint()
+{
+ pushd $WSREP_SST_OPT_DATA 1>/dev/null
+ payload=$(find . -regex '.*\.ibd$\|.*\.MYI$\|.*\.MYD$\|.*ibdata1$' -type f -print0 | du --files0-from=- --block-size=1 -c -s | awk 'END { print $1 }')
+ if $MY_PRINT_DEFAULTS xtrabackup | grep -q -- "--compress";then
+ # QuickLZ has around 50% compression ratio
+ # When compression/compaction used, the progress is only an approximate.
+ payload=$(( payload*1/2 ))
+ fi
+ popd 1>/dev/null
+ pcmd+=" -s $payload"
+ adjust_progress
+}
+
+adjust_progress()
+{
+ if [[ -n $progress && $progress != '1' ]];then
+ if [[ -e $progress ]];then
+ pcmd+=" 2>>$progress"
+ else
+ pcmd+=" 2>$progress"
+ fi
+ elif [[ -z $progress && -n $rlimit ]];then
+ # When rlimit is non-zero
+ pcmd="pv -q"
+ fi
+
+ if [[ -n $rlimit && "$WSREP_SST_OPT_ROLE" == "donor" ]];then
+ wsrep_log_info "Rate-limiting SST to $rlimit"
+ pcmd+=" -L \$rlimit"
+ fi
+}
+
+read_cnf()
+{
+ sfmt=$(parse_cnf sst streamfmt "tar")
+ tfmt=$(parse_cnf sst transferfmt "socat")
+ tcert=$(parse_cnf sst tca "")
+ tpem=$(parse_cnf sst tcert "")
+ encrypt=$(parse_cnf sst encrypt 0)
+ sockopt=$(parse_cnf sst sockopt "")
+ progress=$(parse_cnf sst progress "")
+ rebuild=$(parse_cnf sst rebuild 0)
+ ttime=$(parse_cnf sst time 0)
+ incremental=$(parse_cnf sst incremental 0)
+ ealgo=$(parse_cnf xtrabackup encrypt "")
+ ekey=$(parse_cnf xtrabackup encrypt-key "")
+ ekeyfile=$(parse_cnf xtrabackup encrypt-key-file "")
+
+ # Refer to http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html
+ if [[ -z $ealgo ]];then
+ ealgo=$(parse_cnf sst encrypt-algo "")
+ ekey=$(parse_cnf sst encrypt-key "")
+ ekeyfile=$(parse_cnf sst encrypt-key-file "")
+ fi
+ rlimit=$(parse_cnf sst rlimit "")
+ uextra=$(parse_cnf sst use_extra 0)
+}
+
+get_stream()
+{
+ if [[ $sfmt == 'xbstream' ]];then
+ wsrep_log_info "Streaming with xbstream"
+ if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
+ strmcmd="xbstream -x"
+ else
+ strmcmd="xbstream -c \${INFO_FILE} \${IST_FILE}"
+ fi
+ else
+ sfmt="tar"
+ wsrep_log_info "Streaming with tar"
+ if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
+ strmcmd="tar xfi - --recursive-unlink -h"
+ else
+ strmcmd="tar cf - \${INFO_FILE} \${IST_FILE}"
+ fi
+
+ fi
+}
+
+get_proc()
+{
+ set +e
+ nproc=$(grep -c processor /proc/cpuinfo)
+ [[ -z $nproc || $nproc -eq 0 ]] && nproc=1
+ set -e
+}
+
+sig_joiner_cleanup()
+{
+ wsrep_log_error "Removing $MAGIC_FILE file due to signal"
+ rm -f "$MAGIC_FILE"
+}
+
+cleanup_joiner()
+{
+ # Since this is invoked just after exit NNN
+ local estatus=$?
+ if [[ $estatus -ne 0 ]];then
+ wsrep_log_error "Cleanup after exit with status:$estatus"
+ fi
+ if [ "${WSREP_SST_OPT_ROLE}" = "joiner" ];then
+ wsrep_log_info "Removing the sst_in_progress file"
+ wsrep_cleanup_progress_file
+ fi
+ if [[ -n $progress && -p $progress ]];then
+ wsrep_log_info "Cleaning up fifo file $progress"
+ rm $progress
+ fi
+}
+
+check_pid()
+{
+ local pid_file="$1"
+ [ -r "$pid_file" ] && ps -p $(cat "$pid_file") >/dev/null 2>&1
+}
+
+cleanup_donor()
+{
+ # Since this is invoked just after exit NNN
+ local estatus=$?
+ if [[ $estatus -ne 0 ]];then
+ wsrep_log_error "Cleanup after exit with status:$estatus"
+ fi
+
+ if [[ -n $XTRABACKUP_PID ]];then
+ if check_pid $XTRABACKUP_PID
+ then
+ wsrep_log_error "xtrabackup process is still running. Killing... "
+ kill_xtrabackup
+ fi
+
+ rm -f $XTRABACKUP_PID
+ fi
+ rm -f ${DATA}/${IST_FILE}
+
+ if [[ -n $progress && -p $progress ]];then
+ wsrep_log_info "Cleaning up fifo file $progress"
+ rm $progress
+ fi
+}
+
+kill_xtrabackup()
+{
+ local PID=$(cat $XTRABACKUP_PID)
+ [ -n "$PID" -a "0" != "$PID" ] && kill $PID && (kill $PID && kill -9 $PID) || :
+ rm -f "$XTRABACKUP_PID"
+}
+
+# waits ~10 seconds for nc to open the port and then reports ready
+# (regardless of timeout)
+wait_for_listen()
+{
+ local PORT=$1
+ local ADDR=$2
+ local MODULE=$3
+ for i in {1..50}
+ do
+ 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
+}
+
+check_extra()
+{
+ local use_socket=1
+ if [[ $uextra -eq 1 ]];then
+ if [ $(parse_cnf --mysqld thread-handling) = 'pool-of-threads'];then
+ local eport=$(parse_cnf --mysqld extra-port)
+ if [[ -n $eport ]];then
+ # Xtrabackup works only locally.
+ # Hence, setting host to 127.0.0.1 unconditionally.
+ wsrep_log_info "SST through extra_port $eport"
+ INNOEXTRA+=" --host=127.0.0.1 --port=$eport "
+ use_socket=0
+ else
+ wsrep_log_error "Extra port $eport null, failing"
+ exit 1
+ fi
+ else
+ wsrep_log_info "Thread pool not set, ignore the option use_extra"
+ fi
+ fi
+ if [[ $use_socket -eq 1 ]] && [[ -n "${WSREP_SST_OPT_SOCKET}" ]];then
+ INNOEXTRA+=" --socket=${WSREP_SST_OPT_SOCKET}"
+ fi
+}
+
+if [[ ! -x `which innobackupex` ]];then
+ wsrep_log_error "innobackupex not in path: $PATH"
+ exit 2
+fi
+
+rm -f "${MAGIC_FILE}"
+
+if [[ ! ${WSREP_SST_OPT_ROLE} == 'joiner' && ! ${WSREP_SST_OPT_ROLE} == 'donor' ]];then
+ wsrep_log_error "Invalid role ${WSREP_SST_OPT_ROLE}"
+ exit 22
+fi
+
+read_cnf
+get_stream
+get_transfer
+
+INNOEXTRA=""
+INNOAPPLY="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} --apply-log \$rebuildcmd \${DATA} &>\${DATA}/innobackup.prepare.log"
+INNOBACKUP="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} \$INNOEXTRA --galera-info --stream=\$sfmt \${TMPDIR} 2>\${DATA}/innobackup.backup.log"
+
+if [ "$WSREP_SST_OPT_ROLE" = "donor" ]
+then
+ trap cleanup_donor EXIT
+
+ if [ $WSREP_SST_OPT_BYPASS -eq 0 ]
+ then
+ usrst=0
+ TMPDIR="${TMPDIR:-/tmp}"
+
+ if [[ -n "${WSREP_SST_OPT_USER:-}" && "$WSREP_SST_OPT_USER" != "(null)" ]]; then
+ INNOEXTRA+=" --user=$WSREP_SST_OPT_USER"
+ usrst=1
+ fi
+
+ if [ -n "${WSREP_SST_OPT_PSWD:-}" ]; then
+ INNOEXTRA+=" --password=$WSREP_SST_OPT_PSWD"
+ elif [[ $usrst -eq 1 ]];then
+ # Empty password, used for testing, debugging etc.
+ INNOEXTRA+=" --password="
+ fi
+
+ get_keys
+ if [[ $encrypt -eq 1 ]];then
+ if [[ -n $ekey ]];then
+ INNOEXTRA+=" --encrypt=$ealgo --encrypt-key=$ekey "
+ else
+ INNOEXTRA+=" --encrypt=$ealgo --encrypt-key-file=$ekeyfile "
+ fi
+ fi
+
+ if [[ -n $lsn ]];then
+ INNOEXTRA+=" --incremental --incremental-lsn=$lsn "
+ fi
+
+ check_extra
+
+ wsrep_log_info "Streaming the backup to joiner at ${WSREP_SST_OPT_HOST} ${WSREP_SST_OPT_PORT}"
+
+ if [[ -n $progress ]];then
+ get_footprint
+ tcmd="$pcmd | $tcmd"
+ elif [[ -n $rlimit ]];then
+ adjust_progress
+ tcmd="$pcmd | $tcmd"
+ fi
+
+ set +e
+ timeit "Donor-Transfer" "$INNOBACKUP | $tcmd; RC=( "\${PIPESTATUS[@]}" )"
+ set -e
+
+ if [ ${RC[0]} -ne 0 ]; then
+ wsrep_log_error "${INNOBACKUPEX_BIN} finished with error: ${RC[0]}. " \
+ "Check ${DATA}/innobackup.backup.log"
+ exit 22
+ elif [[ ${RC[$(( ${#RC[@]}-1 ))]} -eq 1 ]];then
+ wsrep_log_error "$tcmd finished with error: ${RC[1]}"
+ exit 22
+ fi
+
+ # innobackupex implicitly writes PID to fixed location in ${TMPDIR}
+ XTRABACKUP_PID="${TMPDIR}/xtrabackup_pid"
+
+ else # BYPASS FOR IST
+
+ wsrep_log_info "Bypassing the SST for IST"
+ echo "continue" # now server can resume updating data
+
+ # Store donor's wsrep GTID (state ID) and wsrep_gtid_domain_id
+ # (separated by a space)
+ echo "${WSREP_SST_OPT_GTID} ${WSREP_SST_OPT_GTID_DOMAIN_ID}" > "${MAGIC_FILE}"
+ echo "1" > "${DATA}/${IST_FILE}"
+ get_keys
+ pushd ${DATA} 1>/dev/null
+ set +e
+ if [[ $encrypt -eq 1 ]];then
+ tcmd=" $ecmd | $tcmd"
+ fi
+ timeit "Donor-IST-Unencrypted-transfer" "$strmcmd | $tcmd; RC=( "\${PIPESTATUS[@]}" )"
+ set -e
+ popd 1>/dev/null
+
+ for ecode in "${RC[@]}";do
+ if [[ $ecode -ne 0 ]];then
+ wsrep_log_error "Error while streaming data to joiner node: " \
+ "exit codes: ${RC[@]}"
+ exit 1
+ fi
+ done
+ fi
+
+ echo "done ${WSREP_SST_OPT_GTID}"
+ wsrep_log_info "Total time on donor: $totime seconds"
+
+elif [ "${WSREP_SST_OPT_ROLE}" = "joiner" ]
+then
+ [[ -e $SST_PROGRESS_FILE ]] && wsrep_log_info "Stale sst_in_progress file: $SST_PROGRESS_FILE"
+ touch $SST_PROGRESS_FILE
+
+ if [[ ! -e ${DATA}/ibdata1 ]];then
+ incremental=0
+ fi
+
+ if [[ $incremental -eq 1 ]];then
+ wsrep_log_info "Incremental SST enabled"
+ #lsn=$(/pxc/bin/mysqld $WSREP_SST_OPT_CONF --basedir=/pxc --wsrep-recover 2>&1 | grep -o 'log sequence number .*' | cut -d " " -f 4 | head -1)
+ lsn=$(grep to_lsn xtrabackup_checkpoints | cut -d= -f2 | tr -d ' ')
+ wsrep_log_info "Recovered LSN: $lsn"
+ fi
+
+ sencrypted=1
+ nthreads=1
+
+ MODULE="xtrabackup_sst"
+
+ # May need xtrabackup_checkpoints later on
+ rm -f ${DATA}/xtrabackup_binary ${DATA}/xtrabackup_galera_info ${DATA}/xtrabackup_logfile
+
+ ADDR="${WSREP_SST_OPT_HOST}:${WSREP_SST_OPT_PORT:-4444}"
+
+ wait_for_listen ${WSREP_SST_OPT_PORT:-4444} ${ADDR} ${MODULE} &
+
+ trap sig_joiner_cleanup HUP PIPE INT TERM
+ trap cleanup_joiner EXIT
+
+ if [[ -n $progress ]];then
+ adjust_progress
+ tcmd+=" | $pcmd"
+ fi
+
+ if [[ $incremental -eq 1 ]];then
+ BDATA=$DATA
+ DATA=$(mktemp -d)
+ MAGIC_FILE="${DATA}/${INFO_FILE}"
+ fi
+
+ get_keys
+ set +e
+ if [[ $encrypt -eq 1 && $sencrypted -eq 1 ]];then
+ strmcmd=" $ecmd | $strmcmd"
+ fi
+
+ pushd ${DATA} 1>/dev/null
+ timeit "Joiner-Recv-Unencrypted" "$tcmd | $strmcmd; RC=( "\${PIPESTATUS[@]}" )"
+ popd 1>/dev/null
+
+ set -e
+
+ if [[ $sfmt == 'xbstream' ]];then
+ # Special handling till lp:1193240 is fixed"
+ if [[ ${RC[$(( ${#RC[@]}-1 ))]} -eq 1 ]];then
+ wsrep_log_error "Xbstream failed"
+ wsrep_log_error "Data directory ${DATA} may not be empty: lp:1193240" \
+ "Manual intervention required in that case"
+ exit 32
+ fi
+ fi
+
+ wait %% # join for wait_for_listen thread
+
+ for ecode in "${RC[@]}";do
+ if [[ $ecode -ne 0 ]];then
+ wsrep_log_error "Error while getting data from donor node: " \
+ "exit codes: ${RC[@]}"
+ exit 32
+ fi
+ done
+
+ if [ ! -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"
+ wsrep_log_info "$(ls -l ${DATA}/**/*)"
+ exit 32
+ fi
+
+ if ! ps -p ${WSREP_SST_OPT_PARENT} &>/dev/null
+ then
+ wsrep_log_error "Parent mysqld process (PID:${WSREP_SST_OPT_PARENT}) terminated unexpectedly."
+ exit 32
+ fi
+
+ if [ ! -r "${DATA}/${IST_FILE}" ]
+ then
+ wsrep_log_info "Proceeding with SST"
+ wsrep_log_info "Removing existing ib_logfile files"
+ if [[ $incremental -ne 1 ]];then
+ rm -f ${DATA}/ib_logfile*
+ else
+ rm -f ${BDATA}/ib_logfile*
+ fi
+
+ get_proc
+
+ # Rebuild indexes for compact backups
+ if grep -q 'compact = 1' ${DATA}/xtrabackup_checkpoints;then
+ wsrep_log_info "Index compaction detected"
+ rebuild=1
+ fi
+
+ if [[ $rebuild -eq 1 ]];then
+ nthreads=$(parse_cnf xtrabackup rebuild-threads $nproc)
+ wsrep_log_info "Rebuilding during prepare with $nthreads threads"
+ rebuildcmd="--rebuild-indexes --rebuild-threads=$nthreads"
+ fi
+
+ if test -n "$(find ${DATA} -maxdepth 1 -type f -name '*.qp' -print -quit)";then
+
+ wsrep_log_info "Compressed qpress files found"
+
+ if [[ ! -x `which qpress` ]];then
+ wsrep_log_error "qpress not found in path: $PATH"
+ exit 22
+ fi
+
+ if [[ -n $progress ]] && pv --help | grep -q 'line-mode';then
+ count=$(find ${DATA} -type f -name '*.qp' | wc -l)
+ count=$(( count*2 ))
+ if pv --help | grep -q FORMAT;then
+ pvopts="-f -s $count -l -N Decompression -F '%N => Rate:%r Elapsed:%t %e Progress: [%b/$count]'"
+ else
+ pvopts="-f -s $count -l -N Decompression"
+ fi
+ pcmd="pv $pvopts"
+ adjust_progress
+ dcmd="$pcmd | xargs -n 2 qpress -T${nproc}d"
+ else
+ dcmd="xargs -n 2 qpress -T${nproc}d"
+ fi
+
+ wsrep_log_info "Removing existing ibdata1 file"
+ rm -f ${DATA}/ibdata1
+
+ # Decompress the qpress files
+ wsrep_log_info "Decompression with $nproc threads"
+ timeit "Decompression" "find ${DATA} -type f -name '*.qp' -printf '%p\n%h\n' | $dcmd"
+ extcode=$?
+
+ if [[ $extcode -eq 0 ]];then
+ wsrep_log_info "Removing qpress files after decompression"
+ find ${DATA} -type f -name '*.qp' -delete
+ if [[ $? -ne 0 ]];then
+ wsrep_log_error "Something went wrong with deletion of qpress files. Investigate"
+ fi
+ else
+ wsrep_log_error "Decompression failed. Exit code: $extcode"
+ exit 22
+ fi
+ fi
+
+ if [[ $incremental -eq 1 ]];then
+ # Added --ibbackup=xtrabackup_55 because it fails otherwise citing connection issues.
+ INNOAPPLY="${INNOBACKUPEX_BIN} ${WSREP_SST_OPT_CONF} \
+ --ibbackup=xtrabackup_55 --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"
+
+ if [[ $incremental -eq 1 ]];then
+ wsrep_log_info "Cleaning up ${DATA} after incremental SST"
+ [[ -d ${DATA} ]] && rm -rf ${DATA}
+ DATA=$BDATA
+ fi
+
+ if [ $? -ne 0 ];
+ then
+ wsrep_log_error "${INNOBACKUPEX_BIN} finished with errors. Check ${DATA}/innobackup.prepare.log"
+ exit 22
+ fi
+ else
+ wsrep_log_info "${IST_FILE} received from donor: Running IST"
+ fi
+
+ if [[ ! -r ${MAGIC_FILE} ]];then
+ wsrep_log_error "SST magic file ${MAGIC_FILE} not found/readable"
+ exit 2
+ fi
+
+ cat "${MAGIC_FILE}" # Output : UUID:seqno wsrep_gtid_domain_id
+ wsrep_log_info "Total time on joiner: $totime seconds"
+fi
+
+exit 0