diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/CMakeLists.txt | 40 | ||||
-rw-r--r-- | scripts/comp_sql.c | 2 | ||||
-rw-r--r-- | scripts/mysql_config.sh | 11 | ||||
-rw-r--r-- | scripts/mysql_install_db.sh | 64 | ||||
-rw-r--r-- | scripts/mysql_system_tables.sql | 14 | ||||
-rw-r--r-- | scripts/mysql_system_tables_data.sql | 5 | ||||
-rw-r--r-- | scripts/mysql_system_tables_fix.sql | 12 | ||||
-rw-r--r-- | scripts/mysql_test_db.sql | 16 | ||||
-rw-r--r-- | scripts/mysql_zap.sh | 171 | ||||
-rw-r--r-- | scripts/mysqlaccess.sh | 2 | ||||
-rw-r--r-- | scripts/mysqlbug.sh | 406 | ||||
-rw-r--r-- | scripts/mysqld_multi.sh | 19 | ||||
-rw-r--r-- | scripts/mysqld_safe.sh | 88 | ||||
-rw-r--r-- | scripts/wsrep_sst_common.sh | 5 | ||||
-rw-r--r-- | scripts/wsrep_sst_mariabackup.sh | 11 | ||||
-rw-r--r-- | scripts/wsrep_sst_rsync.sh | 112 |
16 files changed, 220 insertions, 758 deletions
diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index b139b51e296..1e63c9eb239 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -96,6 +96,7 @@ INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mysql_system_tables.sql ${CMAKE_CURRENT_SOURCE_DIR}/mysql_system_tables_data.sql ${CMAKE_CURRENT_SOURCE_DIR}/mysql_performance_tables.sql + ${CMAKE_CURRENT_SOURCE_DIR}/mysql_test_db.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 @@ -163,42 +164,6 @@ ENDIF() SET(HOSTNAME "hostname") SET(MYSQLD_USER "mysql") - -# Required for mysqlbug until autotools are deprecated, once done remove these -# and expand default cmake variables -SET(CC ${CMAKE_C_COMPILER}) -SET(CXX ${CMAKE_CXX_COMPILER}) -SET(SAVE_CC ${CMAKE_C_COMPILER}) -SET(SAVE_CXX ${CMAKE_CXX_COMPILER}) -SET(SAVE_CFLAGS ${CFLAGS}) -SET(SAVE_CXXFLAGS ${CXXFLAGS}) -# XXX no cmake equivalent for this, just make one up -SET(CONFIGURE_LINE "Built using CMake") - -# Also required for mysqlbug, autoconf only supports --version so for now we -# just explicitly require GNU -EXECUTE_PROCESS( - COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1} --version - COMMAND sed 1q - ERROR_QUIET - OUTPUT_VARIABLE CC_VERSION) -EXECUTE_PROCESS( - COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} --version - COMMAND sed 1q - ERROR_QUIET - OUTPUT_VARIABLE CXX_VERSION) - -CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/mysqlbug.sh - ${CMAKE_CURRENT_BINARY_DIR}/mysqlbug ESCAPE_QUOTES @ONLY) - EXECUTE_PROCESS( - COMMAND chmod +x ${CMAKE_CURRENT_BINARY_DIR}/mysqlbug - ) - -INSTALL_SCRIPT(${CMAKE_CURRENT_BINARY_DIR}/mysqlbug - DESTINATION ${INSTALL_BINDIR} - COMPONENT Server - ) - ENDIF(UNIX) # Really ugly, one script, "mysql_install_db", needs prefix set to ".", @@ -212,6 +177,7 @@ IF(INSTALL_LAYOUT MATCHES "STANDALONE") SET(scriptdir ${prefix}/${INSTALL_BINDIR}) SET(libexecdir ${prefix}/${INSTALL_SBINDIR}) SET(pkgdatadir ${prefix}/${INSTALL_MYSQLSHAREDIR}) + SET(pkgplugindir ${prefix}/${INSTALL_PLUGINDIR}) SET(localstatedir ${prefix}/data) ELSE() SET(prefix "${CMAKE_INSTALL_PREFIX}") @@ -220,6 +186,7 @@ ELSE() SET(scriptdir ${INSTALL_BINDIRABS}) SET(libexecdir ${INSTALL_SBINDIRABS}) SET(pkgdatadir ${INSTALL_MYSQLSHAREDIRABS}) + SET(pkgplugindir ${INSTALL_PLUGINDIRABS}) SET(localstatedir ${MYSQL_DATADIR}) ENDIF() @@ -320,7 +287,6 @@ ELSE() IF (NOT WITHOUT_SERVER) SET(SERVER_SCRIPTS mysql_fix_extensions - mysql_zap mysqld_multi mysqld_safe mysqldumpslow diff --git a/scripts/comp_sql.c b/scripts/comp_sql.c index a1f27261892..748b2320f2a 100644 --- a/scripts/comp_sql.c +++ b/scripts/comp_sql.c @@ -68,7 +68,7 @@ static void die(const char *fmt, ...) char *fgets_fn(char *buffer, size_t size, fgets_input_t input, int *error) { - char *line= fgets(buffer, size, (FILE*) input); + char *line= fgets(buffer, (int)size, (FILE*) input); if (error) *error= (line == NULL) ? ferror((FILE*)input) : 0; return line; diff --git a/scripts/mysql_config.sh b/scripts/mysql_config.sh index 425dee1e271..e8ff125698b 100644 --- a/scripts/mysql_config.sh +++ b/scripts/mysql_config.sh @@ -114,6 +114,17 @@ if [ "$basedir" != "/usr" ]; then fi cflags="$include @CFLAGS_FOR_CLIENTS@" +mariadb_config="$basedir/bin/mariadb_config" +if test -x "$basedir/bin/mariadb_config"; then + cflags=`"$mariadb_config" --cflags` + include=`"$mariadb_config" --include` + libs=`"$mariadb_config" --libs` + plugindir=`"$mariadb_config" --plugindir` + socket=`"$mariadb_config" --socket` + port=`"$mariadb_config" --port` + version=`"$mariadb_config" --version` +fi + usage () { cat <<EOF Usage: $0 [OPTIONS] diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index adf521f89f6..38f12b5bd03 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -30,6 +30,7 @@ defaults="" defaults_group_suffix="" mysqld_opt="" user="" +silent_startup="--silent-startup" force=0 in_rpm=0 @@ -150,7 +151,7 @@ parse_arguments() # where a chown of datadir won't help) user=`parse_arg "$arg"` ;; --skip-name-resolve) ip_only=1 ;; - --verbose) verbose=1 ;; # Obsolete + --verbose) verbose=1 ; silent_startup="" ;; --rpm) in_rpm=1 ;; --help) usage ;; --no-defaults|--defaults-file=*|--defaults-extra-file=*) @@ -323,6 +324,7 @@ then langdir="$basedir/sql/share/english" srcpkgdatadir="$srcdir/scripts" buildpkgdatadir="$builddir/scripts" + plugindir="$builddir/plugin/auth_socket" elif test -n "$basedir" then bindir="$basedir/bin" # only used in the help text @@ -351,6 +353,7 @@ then cannot_find_file fill_help_tables.sql @pkgdata_locations@ exit 1 fi + plugindir=`find_in_dirs --dir auth_socket.so $basedir/lib*/plugin $basedir/lib*/mysql/plugin` # relative from where the script was run for a relocatable install elif test -n "$dirname0" -a -x "$rel_mysqld" -a ! "$rel_mysqld" -ef "@sbindir@/mysqld" then @@ -360,6 +363,7 @@ then mysqld="$rel_mysqld" srcpkgdatadir="$basedir/@INSTALL_MYSQLSHAREDIR@" buildpkgdatadir="$basedir/@INSTALL_MYSQLSHAREDIR@" + plugindir="$basedir/@INSTALL_PLUGINDIR@" else basedir="@prefix@" bindir="@bindir@" @@ -367,6 +371,7 @@ else mysqld="@sbindir@/mysqld" srcpkgdatadir="@pkgdatadir@" buildpkgdatadir="@pkgdatadir@" + plugindir="@pkgplugindir@" fi # Set up paths to SQL scripts required for bootstrap @@ -483,8 +488,9 @@ fi mysqld_bootstrap="${MYSQLD_BOOTSTRAP-$mysqld}" mysqld_install_cmd_line() { - "$mysqld_bootstrap" $defaults $defaults_group_suffix "$mysqld_opt" --bootstrap \ + "$mysqld_bootstrap" $defaults $defaults_group_suffix "$mysqld_opt" --bootstrap $silent_startup\ "--basedir=$basedir" "--datadir=$ldata" --log-warnings=0 --enforce-storage-engine="" \ + "--plugin-dir=${plugindir}" \ $args --max_allowed_packet=8M \ --net_buffer_length=16K } @@ -502,7 +508,7 @@ SET @auth_root_socket=NULL;" ;; SET @skip_auth_root_nopasswd=1; SET @auth_root_socket='$auth_root_socket_user';" ;; esac -if { echo "$install_params"; cat "$create_system_tables" "$create_system_tables2" "$fill_system_tables"; } | eval "$filter_cmd_line" | mysqld_install_cmd_line > /dev/null +if { echo "$install_params"; cat "$create_system_tables" "$create_system_tables2" "$fill_system_tables" "$fill_help_tables" "$maria_add_gis_sp"; } | eval "$filter_cmd_line" | mysqld_install_cmd_line > /dev/null then s_echo "OK" else @@ -537,27 +543,6 @@ else exit 1 fi -s_echo "Filling help tables..." -if { echo "use mysql;"; cat "$fill_help_tables"; } | mysqld_install_cmd_line > /dev/null -then - s_echo "OK" -else - echo - echo "WARNING: HELP FILES ARE NOT COMPLETELY INSTALLED!" - 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. @@ -567,19 +552,24 @@ then s_echo "To start mysqld at boot time you have to copy" s_echo "support-files/mysql.server to the right place for your system" - echo - echo "PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !" - echo "To do so, start the server, then issue the following commands:" - echo - echo "'$bindir/mysqladmin' -u root password 'new-password'" - echo "'$bindir/mysqladmin' -u root -h $hostname password 'new-password'" - echo - echo "Alternatively you can run:" - echo "'$bindir/mysql_secure_installation'" - echo - echo "which will also give you the option of removing the test" - echo "databases and anonymous user created by default. This is" - echo "strongly recommended for production servers." + if test "$auth_root_authentication_method" = normal + then + echo + echo + echo "PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !" + echo "To do so, start the server, then issue the following commands:" + echo + echo "'$bindir/mysqladmin' -u root password 'new-password'" + echo "'$bindir/mysqladmin' -u root -h $hostname password 'new-password'" + echo + echo "Alternatively you can run:" + echo "'$bindir/mysql_secure_installation'" + echo + echo "which will also give you the option of removing the test" + echo "databases and anonymous user created by default. This is" + echo "strongly recommended for production servers." + fi + echo echo "See the MariaDB Knowledgebase at http://mariadb.com/kb or the" echo "MySQL manual for more instructions." diff --git a/scripts/mysql_system_tables.sql b/scripts/mysql_system_tables.sql index 76b4fb93eab..7a5f472bd57 100644 --- a/scripts/mysql_system_tables.sql +++ b/scripts/mysql_system_tables.sql @@ -1,4 +1,4 @@ --- Copyright (c) 2007, 2013, Oracle and/or its affiliates. +-- Copyright (c) 2007, 2018, Oracle and/or its affiliates. -- Copyright (c) 2008, 2014, Monty Program Ab & SkySQL Ab -- -- This program is free software; you can redistribute it and/or modify @@ -46,7 +46,7 @@ CREATE TABLE IF NOT EXISTS func ( name char(64) binary DEFAULT '' NOT NULL, ret CREATE TABLE IF NOT EXISTS plugin ( name varchar(64) DEFAULT '' NOT NULL, dl varchar(128) DEFAULT '' NOT NULL, PRIMARY KEY (name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci comment='MySQL plugins'; -CREATE TABLE IF NOT EXISTS servers ( Server_name char(64) NOT NULL DEFAULT '', Host char(64) NOT NULL DEFAULT '', Db char(64) NOT NULL DEFAULT '', Username char(80) NOT NULL DEFAULT '', Password char(64) NOT NULL DEFAULT '', Port INT(4) NOT NULL DEFAULT '0', Socket char(64) NOT NULL DEFAULT '', Wrapper char(64) NOT NULL DEFAULT '', Owner char(64) NOT NULL DEFAULT '', PRIMARY KEY (Server_name)) CHARACTER SET utf8 comment='MySQL Foreign Servers table'; +CREATE TABLE IF NOT EXISTS servers ( Server_name char(64) NOT NULL DEFAULT '', Host varchar(2048) NOT NULL DEFAULT '', Db char(64) NOT NULL DEFAULT '', Username char(80) NOT NULL DEFAULT '', Password char(64) NOT NULL DEFAULT '', Port INT(4) NOT NULL DEFAULT '0', Socket char(64) NOT NULL DEFAULT '', Wrapper char(64) NOT NULL DEFAULT '', Owner varchar(512) NOT NULL DEFAULT '', PRIMARY KEY (Server_name)) CHARACTER SET utf8 comment='MySQL Foreign Servers table'; CREATE TABLE IF NOT EXISTS tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(80) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(141) DEFAULT '' NOT NULL, Timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Table privileges'; @@ -105,7 +105,7 @@ CREATE TABLE IF NOT EXISTS event ( db char(64) CHARACTER SET utf8 COLLATE utf8_b SET @create_innodb_table_stats="CREATE TABLE IF NOT EXISTS innodb_table_stats ( database_name VARCHAR(64) NOT NULL, - table_name VARCHAR(64) NOT NULL, + table_name VARCHAR(199) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, n_rows BIGINT UNSIGNED NOT NULL, clustered_index_size BIGINT UNSIGNED NOT NULL, @@ -115,7 +115,7 @@ SET @create_innodb_table_stats="CREATE TABLE IF NOT EXISTS innodb_table_stats ( SET @create_innodb_index_stats="CREATE TABLE IF NOT EXISTS innodb_index_stats ( database_name VARCHAR(64) NOT NULL, - table_name VARCHAR(64) NOT NULL, + table_name VARCHAR(199) NOT NULL, index_name VARCHAR(64) NOT NULL, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, /* there are at least: @@ -237,3 +237,9 @@ EXECUTE stmt; DROP PREPARE stmt; set storage_engine=@orig_storage_engine; + +-- +-- Drop some tables not used anymore in MariaDB +--- + +drop table if exists mysql.ndb_binlog_index; diff --git a/scripts/mysql_system_tables_data.sql b/scripts/mysql_system_tables_data.sql index 53704c763a5..4237d96701f 100644 --- a/scripts/mysql_system_tables_data.sql +++ b/scripts/mysql_system_tables_data.sql @@ -46,8 +46,11 @@ INSERT INTO tmp_user_nopasswd VALUES ('localhost','root','','Y','Y','Y','Y','Y', 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. +-- More secure root account using unix socket 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); +IF @auth_root_socket is not null THEN + IF not exists(select 1 from information_schema.plugins where plugin_name='unix_socket') THEN + INSTALL SONAME 'auth_socket'; END IF; END IF; -- 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'; diff --git a/scripts/mysql_system_tables_fix.sql b/scripts/mysql_system_tables_fix.sql index 89b1756d794..a07a4c53d8b 100644 --- a/scripts/mysql_system_tables_fix.sql +++ b/scripts/mysql_system_tables_fix.sql @@ -173,6 +173,12 @@ ALTER TABLE user MODIFY Host char(60) NOT NULL default '', MODIFY User char(80) binary NOT NULL default '', ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin; + +# In MySQL 5.7.6 the Password column is removed. Recreate it to preserve the number +# of columns MariaDB expects in the user table. +ALTER TABLE user + ADD Password char(41) character set latin1 collate latin1_bin NOT NULL default '' AFTER User; + ALTER TABLE user MODIFY Password char(41) character set latin1 collate latin1_bin NOT NULL default '', MODIFY Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, @@ -688,13 +694,13 @@ set @str=replace(@str, "innodb_index_stats", "innodb_table_stats"); prepare stmt from @str; execute stmt; -# update timestamp fields in the innodb stat tables -set @str="alter table mysql.innodb_index_stats modify last_update timestamp not null default current_timestamp on update current_timestamp"; +# update table_name and timestamp fields in the innodb stat tables +set @str="alter table mysql.innodb_index_stats modify last_update timestamp not null default current_timestamp on update current_timestamp, modify table_name varchar(199)"; 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="alter table mysql.innodb_table_stats modify last_update timestamp not null default current_timestamp on update current_timestamp, modify table_name varchar(199)"; set @str=if(@have_innodb <> 0, @str, "set @dummy = 0"); prepare stmt from @str; execute stmt; diff --git a/scripts/mysql_test_db.sql b/scripts/mysql_test_db.sql new file mode 100644 index 00000000000..059594eb852 --- /dev/null +++ b/scripts/mysql_test_db.sql @@ -0,0 +1,16 @@ +-- Copyright (c) 2018 MariaDB Foundation +-- +-- 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 + +CREATE DATABASE IF NOT EXISTS test CHARACTER SET latin1 COLLATE latin1_swedish_ci; diff --git a/scripts/mysql_zap.sh b/scripts/mysql_zap.sh deleted file mode 100644 index ca83482386f..00000000000 --- a/scripts/mysql_zap.sh +++ /dev/null @@ -1,171 +0,0 @@ -#!@PERL_PATH@ -# Copyright (c) 2000, 2017, 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-1335 USA - -# This is a utility for MariaDB. It is not needed by any standard part -# of MariaDB. - -# Usage: mysql_zap [-signal] [-f] [-t] pattern - -# Configuration parameters. - -$sig = ""; # Default to try all signals -$ans = "y"; -$opt_f= 0; -$opt_t= 0; -$opt_a = ""; - -$BSD = -f '/vmunix' || $ENV{"OS"} eq "SunOS4"; -$LINUX = $^O eq 'linux' || $^O eq 'darwin'; -$pscmd = $BSD ? "/bin/ps -auxww" : $LINUX ? "/bin/ps axuw" : "/bin/ps -ef"; - -open(TTYIN, "</dev/tty") || die "can't read /dev/tty: $!"; -open(TTYOUT, ">/dev/tty") || die "can't write /dev/tty: $!"; -select(TTYOUT); -$| = 1; -select(STDOUT); -$SIG{'INT'} = 'cleanup'; - -while ($#ARGV >= $[ && $ARGV[0] =~ /^-/) { - if ($ARGV[0] =~ /(ZERO|HUP|INT|QUIT|ILL|TRAP|ABRT|EMT|FPE|KILL|BUS|SEGV|SYS|PIPE|ALRM|TERM|URG|STOP|TSTP|CONT|CLD|TTIN|TTOU|IO|XCPU|XFSZ|VTALRM|PROF|WINCH|LOST|USR1|USR2)/ || $ARGV[0] =~ /-(\d+)$/) { - $sig = $1; - } elsif ($ARGV[0] eq "-f") { - $opt_f=1; - } elsif ($ARGV[0] eq "-t") { - $opt_t=1; - $ans = "n"; - } - elsif ($ARGV[0] eq "-a") - { - $opt_a = 1; - } - elsif ($ARGV[0] eq "-?" || $ARGV[0] eq "-I" || $ARGV[0] eq "--help") - { - &usage; - } - else { - print STDERR "$0: illegal argument $ARGV[0] ignored\n"; - } - shift; -} - -&usage if $#ARGV < 0; - -if (!$opt_f) -{ - if ($BSD) { - system "stty cbreak </dev/tty >/dev/tty 2>&1"; - } - else { - system "stty", 'cbreak', - system "stty", 'eol', '^A'; - } -} - -open(PS, "$pscmd|") || die "can't run $pscmd: $!"; -$title = <PS>; -print TTYOUT $title; - -# Catch any errors with eval. A bad pattern, for instance. -eval <<'EOF'; -process: while ($cand = <PS>) -{ - chop($cand); - ($user, $pid) = split(' ', $cand); - next if $pid == $$; - $found = !@ARGV; - if ($opt_a) { $found = 1; } - foreach $pat (@ARGV) - { - if ($opt_a) - { - if (! ($cand =~ $pat)) - { - next process; - } - } - else - { - $found = 1 if $cand =~ $pat; - } - } - next if (!$found); - if (! $opt_f && ! $opt_t) - { - print TTYOUT "$cand? "; - read(TTYIN, $ans, 1); - print TTYOUT "\n" if ($ans ne "\n"); - } - else - { - print TTYOUT "$cand\n"; - } - if ($ans =~ /^y/i) { &killpid($sig, $pid); } - if ($ans =~ /^q/i) { last; } -} -EOF - -&cleanup; - - -sub usage { - print <<EOF; -Usage: $0 [-signal] [-?Ift] [--help] pattern -Options: -I or -? "info" -f "force" -t "test". - -Version 1.0 -Kill processes that match the pattern. -If -f isn't given, ask user for confirmation for each process to kill. -If signal isn't given, try first with signal 15, then with signal 9. -If -t is given, the processes are only shown on stdout. -EOF - exit(1); -} - -sub cleanup { - if ($BSD) { - system "stty -cbreak </dev/tty >/dev/tty 2>&1"; - } - else { - system "stty", 'icanon'; - system "stty", 'eol', '^@'; - } - print "\n"; - exit; -} - -sub killpid { - local($signal,$pid) = @_; - if ($signal) - { - kill $signal,$pid; - } - else - { - print "kill -15\n"; - kill 15, $pid; - for (1..5) { - sleep 2; - return if kill(0, $pid) == 0; - } - print "kill -9\n"; - kill 9, $pid; - for (1..5) { - sleep 2; - return if kill(0, $pid) == 0; - } - print "$pid will not die!\n"; - } -} diff --git a/scripts/mysqlaccess.sh b/scripts/mysqlaccess.sh index 6a38abccda1..aaf711b0fb9 100644 --- a/scripts/mysqlaccess.sh +++ b/scripts/mysqlaccess.sh @@ -262,7 +262,7 @@ Release Notes: * default values are read from a configuration file $script.conf first this file is looked for in the current directory; if not found it is looked for in @sysconfdir@ - Note that when default-values are given, these can't get overriden + Note that when default-values are given, these can't get overridden by empty (blanc) values! * CGI-BIN version with HTML and forms interface. Simply place the script in an ScriptAliased directory, make the configuration file diff --git a/scripts/mysqlbug.sh b/scripts/mysqlbug.sh deleted file mode 100644 index 4533f8202ae..00000000000 --- a/scripts/mysqlbug.sh +++ /dev/null @@ -1,406 +0,0 @@ -#!/bin/sh -# Copyright (C) 2000-2002, 2004 MySQL AB -# Use is subject to license terms -# -# 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-1335 USA - -# Create a bug report and mail it to the mysql mailing list -# Based on glibc bug reporting script. - -echo "Finding system information for a MySQL bug report" - -VERSION="@VERSION@@MYSQL_SERVER_SUFFIX@" -COMPILATION_COMMENT="@COMPILATION_COMMENT@" -BUGmysql="maria-developers@lists.launchpad.net" -# This is set by configure -COMP_CALL_INFO="CC='@SAVE_CC@' CFLAGS='@SAVE_CFLAGS@' CXX='@SAVE_CXX@' CXXFLAGS='@SAVE_CXXFLAGS@' LDFLAGS='@SAVE_LDFLAGS@' ASFLAGS='@SAVE_ASFLAGS@'" -COMP_RUN_INFO="CC='@CC@' CFLAGS='@CFLAGS@' CXX='@CXX@' CXXFLAGS='@CXXFLAGS@' LDFLAGS='@LDFLAGS@' ASFLAGS='@ASFLAGS@'" -CONFIGURE_LINE="@CONF_COMMAND@" - -LIBC_INFO="" -for pat in /lib/libc.* /lib/libc-* /usr/lib/libc.* /usr/lib/libc-* -do - TMP=`ls -l $pat 2>/dev/null` - if test $? = 0 - then - LIBC_INFO="$LIBC_INFO -$TMP" - fi -done - -PATH=../client:$PATH:/bin:/usr/bin:/usr/local/bin -export PATH - -BUGADDR=${1-$BUGmysql} -ENVIRONMENT=`uname -a` - -: ${USER=${LOGNAME-`whoami`}} - -COMMAND=`echo $0|sed 's%.*/\([^/]*\)%\1%'` - -# Try to create a secure tmpfile -umask 077 -TEMPDIR=/tmp/mysqlbug-$$ -mkdir $TEMPDIR || (echo "can not create directory in /tmp, aborting"; exit 1;) -TEMP=${TEMPDIR}/mysqlbug - -trap 'rm -f $TEMP $TEMP.x; rmdir $TEMPDIR; exit 1' 1 2 3 13 15 -trap 'rm -f $TEMP $TEMP.x; rmdir $TEMPDIR' 0 - -# How to read the passwd database. -PASSWD="cat /etc/passwd" - -if test -f /usr/lib/sendmail -then - MAIL_AGENT="/usr/lib/sendmail -oi -t" -elif test -f /usr/sbin/sendmail -then - MAIL_AGENT="/usr/sbin/sendmail -oi -t" -else - MAIL_AGENT="rmail $BUGmysql" -fi - -# Figure out how to echo a string without a trailing newline -N=`echo 'hi there\c'` -case "$N" in - *c) ECHON1='echo -n' ECHON2= ;; - *) ECHON1=echo ECHON2='\c' ;; -esac - -# Find out the name of the originator of this PR. -if test -n "$NAME" -then - ORIGINATOR="$NAME" -elif test -f $HOME/.fullname -then - ORIGINATOR="`sed -e '1q' $HOME/.fullname`" -else - # Must use temp file due to incompatibilities in quoting behavior - # and to protect shell metacharacters in the expansion of $LOGNAME - $PASSWD | grep "^$LOGNAME:" | awk -F: '{print $5}' | sed -e 's/,.*//' > $TEMP - ORIGINATOR="`cat $TEMP`" - rm -f $TEMP -fi - -if test -n "$ORGANIZATION" -then - if test -f "$ORGANIZATION" - then - ORGANIZATION="`cat $ORGANIZATION`" - fi -else - if test -f $HOME/.organization - then - ORGANIZATION="`cat $HOME/.organization`" - elif test -f $HOME/.signature - then - ORGANIZATION=`sed -e "s/^/ /" $HOME/.signature; echo ">"` - fi -fi - -PATH_DIRS=`echo $PATH | sed -e 's/^:/. /' -e 's/:$/ ./' -e 's/::/ . /g' -e 's/:/ /g' ` - -which_1 () -{ - for cmd - do - # Absolute path ?. - if expr "x$cmd" : "x/" > /dev/null - then - echo "$cmd" - exit 0 - else - for d in $PATH_DIRS - do - file="$d/$cmd" - if test -x "$file" -a ! -d "$file" - then - echo "$file" - exit 0 - fi - done - fi - done - exit 1 -} - -change_editor () -{ - echo "You can change editor by setting the environment variable VISUAL." - echo "If your shell is a bourne shell (sh) do" - echo "VISUAL=your_editors_name; export VISUAL" - echo "If your shell is a C shell (csh) do" - echo "setenv VISUAL your_editors_name" -} - -# If they don't have a preferred editor set, then use emacs -if test -z "$VISUAL" -then - if test -z "$EDITOR" - then - # Honor debian sensible-editor - if test -x "/usr/bin/sensible-editor" - then - EDIT=/usr/bin/sensible-editor - else - EDIT=emacs - fi - else - EDIT="$EDITOR" - fi -else - EDIT="$VISUAL" -fi - -#which_1 $EDIT -used_editor=`which_1 $EDIT` - -echo "test -x $used_editor" -if test -x "$used_editor" -then - echo "Using editor $used_editor"; - change_editor - sleep 2 -else - echo "Could not find a text editor. (tried $EDIT)" - change_editor - exit 1 -fi - -# Find out some information. -SYSTEM=`( test -f /bin/uname && /bin/uname -a ) || \ - ( test -f /usr/bin/uname && /usr/bin/uname -a ) || echo ""` -ARCH=`test -f /bin/arch && /bin/arch` -MACHINE=`test -f /bin/machine && /bin/machine` -FILE_PATHS= - -for cmd in perl make gmake gcc cc -do - file=`which_1 $cmd` - if test $? = 0 - then - if test $cmd = "gcc" - then - GCC_INFO=`$file -v 2>&1` - elif test $cmd = "perl" - then - PERL_INFO=`$file -v | grep -i version 2>&1` - fi - FILE_PATHS="$FILE_PATHS $file" - fi -done - -admin=`which_1 mysqladmin` -MYSQL_SERVER= -if test -x "$admin" -then - MYSQL_SERVER=`$admin version 2> /dev/null` - if test "$?" = "1" - then - MYSQL_SERVER="" - fi -fi - -SUBJECT_C="[50 character or so descriptive subject here (for reference)]" -ORGANIZATION_C='<organization of PR author (multiple lines)>' -LICENCE_C='[none | licence | email support | extended email support ]' -SYNOPSIS_C='<synopsis of the problem (one line)>' -SEVERITY_C='<[ non-critical | serious | critical ] (one line)>' -PRIORITY_C='<[ low | medium | high ] (one line)>' -CLASS_C='<[ sw-bug | doc-bug | change-request | support ] (one line)>' -RELEASE_C='<release number or tag (one line)>' -ENVIRONMENT_C='<machine, os, target, libraries (multiple lines)>' -DESCRIPTION_C='<precise description of the problem (multiple lines)>' -HOW_TO_REPEAT_C='<code/input/activities to reproduce the problem (multiple lines)>' -FIX_C='<how to correct or work around the problem, if known (multiple lines)>' - - -cat > $TEMP <<EOF -SEND-PR: -*- send-pr -*- -SEND-PR: Lines starting with \`SEND-PR' will be removed automatically, as -SEND-PR: will all comments (text enclosed in \`<' and \`>'). -SEND-PR: -From: ${USER} -To: ${BUGADDR} -Subject: $SUBJECT_C - ->Description: - $DESCRIPTION_C ->How-To-Repeat: - $HOW_TO_REPEAT_C ->Fix: - $FIX_C - ->Submitter-Id: <submitter ID> ->Originator: ${ORIGINATOR} ->Organization: -${ORGANIZATION- $ORGANIZATION_C} ->MySQL support: $LICENCE_C ->Synopsis: $SYNOPSIS_C ->Severity: $SEVERITY_C ->Priority: $PRIORITY_C ->Category: mysql ->Class: $CLASS_C ->Release: mysql-${VERSION} ($COMPILATION_COMMENT) -`test -n "$MYSQL_SERVER" && echo ">Server: $MYSQL_SERVER"` ->C compiler: @CC_VERSION@ ->C++ compiler: @CXX_VERSION@ ->Environment: - $ENVIRONMENT_C -`test -n "$SYSTEM" && echo "System: $SYSTEM"` -`test -n "$ARCH" && echo "Architecture: $ARCH"` -`test -n "$MACHINE" && echo "Machine: $MACHINE"` -`test -n "$FILE_PATHS" && echo "Some paths: $FILE_PATHS"` -`test -n "$GCC_INFO" && echo "GCC: $GCC_INFO"` -`test -n "$COMP_CALL_INFO" && echo "Compilation info (call): $COMP_CALL_INFO"` -`test -n "$COMP_RUN_INFO" && echo "Compilation info (used): $COMP_RUN_INFO"` -`test -n "$LIBC_INFO" && echo "LIBC: $LIBC_INFO"` -`test -n "$CONFIGURE_LINE" && echo "Configure command: $CONFIGURE_LINE"` -`test -n "$PERL_INFO" && echo "Perl: $PERL_INFO"` -EOF - -chmod u+w $TEMP -cp $TEMP $TEMP.x - -eval $EDIT $TEMP - -if cmp -s $TEMP $TEMP.x -then - echo "File not changed, no bug report submitted." - mv -f $TEMP /tmp/failed-mysql-bugreport - echo "The raw bug report exists in /tmp/failed-mysql-bugreport" - echo "If you use this remember that the first lines of the report are now a lie.." - exit 1 -fi - -# -# Check the enumeration fields - -# This is a "sed-subroutine" with one keyword parameter -# (with workaround for Sun sed bug) -# -SED_CMD=' -/$PATTERN/{ -s||| -s|<.*>|| -s|^[ ]*|| -s|[ ]*$|| -p -q -}' - - -while :; do - CNT=0 - - # - # 1) Severity - # - PATTERN=">Severity:" - SEVERITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP` - case "$SEVERITY" in - ""|non-critical|serious|critical) CNT=`expr $CNT + 1` ;; - *) echo "$COMMAND: \`$SEVERITY' is not a valid value for \`Severity'." - esac - # - # 2) Priority - # - PATTERN=">Priority:" - PRIORITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP` - case "$PRIORITY" in - ""|low|medium|high) CNT=`expr $CNT + 1` ;; - *) echo "$COMMAND: \`$PRIORITY' is not a valid value for \`Priority'." - esac - # - # 3) Class - # - PATTERN=">Class:" - CLASS=`eval sed -n -e "\"$SED_CMD\"" $TEMP` - case "$CLASS" in - ""|sw-bug|doc-bug|change-request|support) CNT=`expr $CNT + 1` ;; - *) echo "$COMMAND: \`$CLASS' is not a valid value for \`Class'." - esac - - # - # 4) Synopsis - # - VALUE=`grep "^>Synopsis:" $TEMP | sed 's/>Synopsis:[ ]*//'` - case "$VALUE" in - "$SYNOPSIS_C") echo "$COMMAND: \`$VALUE' is not a valid value for \`Synopsis'." ;; - *) CNT=`expr $CNT + 1` - esac - - test $CNT -lt 4 && - echo "Errors were found with the problem report." - - - # Check if subject of mail was changed, if not, use Synopsis field - # - subject=`grep "^Subject" $TEMP| sed 's/^Subject:[ ]*//'` - if [ X"$subject" = X"$SUBJECT_C" -o X"$subject" = X"$SYNOPSIS_C" ]; then - subject=`grep Synopsis $TEMP | sed 's/>Synopsis:[ ]*//'` - sed "s/^Subject:[ ]*.*/Subject: $subject/" $TEMP > $TEMP.tmp - mv -f $TEMP.tmp $TEMP - fi - - while :; do - $ECHON1 "a)bort, e)dit or s)end? $ECHON2" - read input - case "$input" in - a*) - echo "$COMMAND: problem report saved in $HOME/dead.mysqlbug." - cat $TEMP >> $HOME/dead.mysqlbug - xs=1; exit - ;; - e*) - eval $EDIT $TEMP - continue 2 - ;; - s*) - break 2 - ;; - esac - done -done -# -# Remove comments and send the problem report -# (we have to use patterns, where the comment contains regex chars) -# -# /^>Originator:/s;$ORIGINATOR;; -sed -e " -/^SEND-PR:/d -/^>Organization:/,/^>[A-Za-z-]*:/s;$ORGANIZATION_C;; -/^>Confidential:/s;<.*>;; -/^>Synopsis:/s;$SYNOPSIS_C;; -/^>Severity:/s;<.*>;; -/^>Priority:/s;<.*>;; -/^>Class:/s;<.*>;; -/^>Release:/,/^>[A-Za-z-]*:/s;$RELEASE_C;; -/^>Environment:/,/^>[A-Za-z-]*:/s;$ENVIRONMENT_C;; -/^>Description:/,/^>[A-Za-z-]*:/s;$DESCRIPTION_C;; -/^>How-To-Repeat:/,/^>[A-Za-z-]*:/s;$HOW_TO_REPEAT_C;; -/^>Fix:/,/^>[A-Za-z-]*:/s;$FIX_C;; -" $TEMP > $TEMP.x - -if $MAIL_AGENT < $TEMP.x -then - echo "$COMMAND: problem report sent" - xs=0; exit -else - echo "$COMMAND: mysterious mail failure, report not sent." - echo "$COMMAND: problem report saved in $HOME/dead.mysqlbug." - cat $TEMP >> $HOME/dead.mysqlbug -fi - -exit 0 diff --git a/scripts/mysqld_multi.sh b/scripts/mysqld_multi.sh index 5f359551f0d..2c3578834eb 100644 --- a/scripts/mysqld_multi.sh +++ b/scripts/mysqld_multi.sh @@ -505,12 +505,19 @@ sub list_defaults_files return ($opt{file}) if exists $opt{file}; - return ('@sysconfdir@/my.cnf', - '@sysconfdir@/mysql/my.cnf', - '@prefix@/my.cnf', - ($ENV{MYSQL_HOME} ? "$ENV{MYSQL_HOME}/my.cnf" : undef), - $opt{'extra-file'}, - ($ENV{HOME} ? "$ENV{HOME}/.my.cnf" : undef)); + my @dirs; + + # same rule as in mysys/my_default.c + if ('@sysconfdir@') { + push @dirs, '@sysconfdir@/my.cnf'; + } else { + push @dirs, '/etc/my.cnf', '/etc/mysql/my.cnf'; + } + push @dirs, "$ENV{MYSQL_HOME}/my.cnf" if $ENV{MYSQL_HOME}; + push @dirs, $opt{'extra-file'} if $opt{'extra-file'}; + push @dirs, "$ENV{HOME}/.my.cnf" if $ENV{HOME}; + + return @dirs; } diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index 87dc81e8b5f..290f43e9e84 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -20,7 +20,6 @@ mysqld_ld_preload= mysqld_ld_library_path= flush_caches=0 numa_interleave=0 -unsafe_my_cnf=0 wsrep_on=0 dry_run=0 defaults_group_suffix= @@ -155,7 +154,11 @@ log_generic () { echo "$msg" case $logging in init) ;; # Just echo the message, don't save it anywhere - file) echo "$msg" | "$helper" "$user" log "$err_log" ;; + file) + if [ -n "$helper" ]; then + echo "$msg" | "$helper" "$user" log "$err_log" + fi + ;; syslog) logger -t "$syslog_tag_mysqld_safe" -p "$priority" "$*" ;; *) echo "Internal program error (non-fatal):" \ @@ -175,7 +178,11 @@ log_notice () { eval_log_error () { local cmd="$1" case $logging in - file) cmd="$cmd 2>&1 | "`shell_quote_string "$helper"`" $user log "`shell_quote_string "$err_log"` ;; + file) + if [ -n "$helper" ]; then + cmd="$cmd 2>&1 | "`shell_quote_string "$helper"`" $user log "`shell_quote_string "$err_log"` + fi + ;; syslog) # mysqld often prefixes its messages with a timestamp, which is # redundant when logging to syslog (which adds its own timestamp) @@ -292,13 +299,6 @@ wsrep_recover_position() { 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" - exit 1 - fi -} - parse_arguments() { for arg do val=`echo "$arg" | sed -e "s;--[^=]*=;;"` @@ -329,14 +329,13 @@ parse_arguments() { # mysqld_safe-specific options - must be set in my.cnf ([mysqld_safe])! --core[-_]file[-_]size=*) core_file_size="$val" ;; - --ledir=*) check_executable_location "$arg" ; ledir="$val" ;; - --malloc[-_]lib=*) check_executable_location "$arg"; set_malloc_lib "$val" ;; - --crash[-_]script=*) check_executable_location "$arg"; crash_script="$val" ;; - --mysqld=*) check_executable_location "$arg"; MYSQLD="$val" ;; + --ledir=*) ledir="$val" ;; + --malloc[-_]lib=*) set_malloc_lib "$val" ;; + --crash[-_]script=*) crash_script="$val" ;; + --mysqld=*) MYSQLD="$val" ;; --mysqld[-_]version=*) if test -n "$val" then - check_executable_location "$arg" MYSQLD="mysqld-$val" PLUGIN_VARIANT="/$val" else @@ -467,8 +466,9 @@ get_mysql_config() { # set_malloc_lib LIB # - If LIB is empty, do nothing and return -# - If LIB is 'tcmalloc', look for tcmalloc shared library in /usr/lib -# then pkglibdir. tcmalloc is part of the Google perftools project. +# - If LIB starts with 'tcmalloc' or 'jemalloc', look for the shared library in +# /usr/lib, /usr/lib64 and then pkglibdir. +# tcmalloc is part of the Google perftools project. # - If LIB is an absolute path, assume it is a malloc shared library # # Put LIB in mysqld_ld_preload, which will be added to LD_PRELOAD when @@ -476,23 +476,23 @@ get_mysql_config() { set_malloc_lib() { malloc_lib="$1" - if [ "$malloc_lib" = tcmalloc ]; then + if expr "$malloc_lib" : "\(tcmalloc\|jemalloc\)" > /dev/null ; then pkglibdir=`get_mysql_config --variable=pkglibdir` - malloc_lib= + where='' # This list is kept intentionally simple. Simply set --malloc-lib # to a full path if another location is desired. - for libdir in /usr/lib "$pkglibdir" "$pkglibdir/mysql"; do - for flavor in _minimal '' _and_profiler _debug; do - tmp="$libdir/libtcmalloc$flavor.so" - #log_notice "DEBUG: Checking for malloc lib '$tmp'" - [ -r "$tmp" ] || continue - malloc_lib="$tmp" - break 2 - done + for libdir in /usr/lib /usr/lib64 "$pkglibdir" "$pkglibdir/mysql"; do + tmp=`echo "$libdir/lib$malloc_lib.so".[0-9]` + where="$where $libdir" + # log_notice "DEBUG: Checking for malloc lib '$tmp'" + [ -r "$tmp" ] || continue + malloc_lib="$tmp" + where='' + break done - if [ -z "$malloc_lib" ]; then - log_error "no shared library for --malloc-lib=tcmalloc found in /usr/lib or $pkglibdir" + if [ -n "$where" ]; then + log_error "no shared library for lib$malloc_lib.so.[0-9] found in$where" exit 1 fi fi @@ -508,8 +508,8 @@ set_malloc_lib() { fi ;; *) - log_error "--malloc-lib must be an absolute path or 'tcmalloc'; " \ - "ignoring value '$malloc_lib'" + log_error "--malloc-lib must be an absolute path, 'tcmalloc' or " \ + "'jemalloc'; ignoring value '$malloc_lib'" exit 1 ;; esac @@ -561,6 +561,9 @@ fi helper=`find_in_bin mysqld_safe_helper` print_defaults=`find_in_bin my_print_defaults` +# Check if helper exists +$helper --help >/dev/null 2>&1 || helper="" + # # Second, try to find the data directory # @@ -569,10 +572,6 @@ print_defaults=`find_in_bin my_print_defaults` if test -d $MY_BASEDIR_VERSION/data/mysql then DATADIR=$MY_BASEDIR_VERSION/data - if test -z "$defaults" -a -r "$DATADIR/my.cnf" - then - defaults="--defaults-extra-file=$DATADIR/my.cnf" - fi # Next try where the source installs put it elif test -d $MY_BASEDIR_VERSION/var/mysql then @@ -584,24 +583,13 @@ fi if test -z "$MYSQL_HOME" then - if test -r "$MY_BASEDIR_VERSION/my.cnf" && test -r "$DATADIR/my.cnf" - then - log_error "WARNING: Found two instances of my.cnf - -$MY_BASEDIR_VERSION/my.cnf and -$DATADIR/my.cnf -IGNORING $DATADIR/my.cnf" - - MYSQL_HOME=$MY_BASEDIR_VERSION - elif test -r "$DATADIR/my.cnf" + if test -r "$DATADIR/my.cnf" then log_error "WARNING: Found $DATADIR/my.cnf -The data directory is a deprecated location for my.cnf, please move it to +The data directory is not a valid location for my.cnf, please move it to $MY_BASEDIR_VERSION/my.cnf" - unsafe_my_cnf=1 - MYSQL_HOME=$DATADIR - else - MYSQL_HOME=$MY_BASEDIR_VERSION fi + MYSQL_HOME=$MY_BASEDIR_VERSION fi export MYSQL_HOME @@ -778,7 +766,7 @@ then does not exist or is not executable. Please cd to the mysql installation directory and restart this script from there as follows: ./bin/mysqld_safe& -See http://dev.mysql.com/doc/mysql/en/mysqld-safe.html for more information" +See https://mariadb.com/kb/en/mysqld_safe for more information" exit 1 fi diff --git a/scripts/wsrep_sst_common.sh b/scripts/wsrep_sst_common.sh index f80abf108ee..ee7817a1550 100644 --- a/scripts/wsrep_sst_common.sh +++ b/scripts/wsrep_sst_common.sh @@ -280,9 +280,8 @@ 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]:-}" + WSREP_SST_OPT_USER="${WSREP_SST_OPT_AUTH%%:*}" + WSREP_SST_OPT_PSWD="${WSREP_SST_OPT_AUTH##*:}" fi readonly WSREP_SST_OPT_USER readonly WSREP_SST_OPT_PSWD diff --git a/scripts/wsrep_sst_mariabackup.sh b/scripts/wsrep_sst_mariabackup.sh index a2d10beee06..4eb9917d341 100644 --- a/scripts/wsrep_sst_mariabackup.sh +++ b/scripts/wsrep_sst_mariabackup.sh @@ -556,10 +556,10 @@ wait_for_listen() do if [ "$OS" = "FreeBSD" ];then sockstat -46lp $PORT | grep -qE "^[^ ]* *(socat|nc) *[^ ]* *[^ ]* *[^ ]* *[^ ]*:$PORT" && break - else - ss -p state listening "( sport = :$PORT )" | grep -qE 'socat|nc' && break - fi - sleep 0.2 + else + ss -p state listening "( sport = :$PORT )" | grep -qE 'socat|nc' && break + fi + sleep 0.2 done echo "ready ${ADDR}/${MODULE}//$sst_ver" } @@ -672,7 +672,6 @@ monitor_process() if ! ps -p "${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 @@ -990,7 +989,7 @@ then rm -f "${DATA}/${IST_FILE}" # May need xtrabackup_checkpoints later on - rm -f ${DATA}/xtrabackup_binary ${DATA}/xtrabackup_galera_info ${DATA}/xtrabackup_logfile + rm -f ${DATA}/xtrabackup_binary ${DATA}/xtrabackup_galera_info ${DATA}/ib_logfile0 ADDR=${WSREP_SST_OPT_ADDR} if [ -z "${SST_PORT}" ] diff --git a/scripts/wsrep_sst_rsync.sh b/scripts/wsrep_sst_rsync.sh index 8fbb32135d7..ef32e77e20d 100644 --- a/scripts/wsrep_sst_rsync.sh +++ b/scripts/wsrep_sst_rsync.sh @@ -62,27 +62,65 @@ 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 - - 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) + local rsync_addr=$3 + local rsync_port=$4 + + case $OS in + FreeBSD) + local port_info="$(sockstat -46lp ${rsync_port} 2>/dev/null | \ + grep ":${rsync_port}")" + local is_rsync="$(echo $port_info | \ + grep -E '[[:space:]]+(rsync|stunnel)[[:space:]]+'"$rsync_pid" 2>/dev/null)" + ;; + *) + 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 [ -n "$port_info" -a -z "$is_rsync" ]; then - wsrep_log_error "rsync daemon port '$rsync_port' has been taken" - exit 16 # EBUSY + local port_info="$(lsof -i :$rsync_port -Pn 2>/dev/null | \ + grep "(LISTEN)")" + local is_rsync="$(echo $port_info | \ + grep -E '^(rsync|stunnel)[[:space:]]+'"$rsync_pid" 2>/dev/null)" + ;; + esac + + local is_listening_all="$(echo $port_info | \ + grep "*:$rsync_port" 2>/dev/null)" + local is_listening_addr="$(echo $port_info | \ + grep -F "$rsync_addr:$rsync_port" 2>/dev/null)" + + if [ ! -z "$is_listening_all" -o ! -z "$is_listening_addr" ]; then + if [ -z "$is_rsync" ]; then + wsrep_log_error "rsync daemon port '$rsync_port' has been taken" + exit 16 # EBUSY + fi fi check_pid $pid_file && \ [ -n "$port_info" ] && [ -n "$is_rsync" ] && \ [ $(cat $pid_file) -eq $rsync_pid ] } +is_local_ip() +{ + local address="$1" + local get_addr_bin=`which ifconfig` + if [ -z "$get_addr_bin" ] + then + get_addr_bin=`which ip` + get_addr_bin="$get_addr_bin address show" + # Add an slash at the end, so we don't get false positive : 172.18.0.4 matches 172.18.0.41 + # ip output format is "X.X.X.X/mask" + address="${address}/" + else + # Add an space at the end, so we don't get false positive : 172.18.0.4 matches 172.18.0.41 + # ifconfig output format is "X.X.X.X " + address="$address " + fi + + $get_addr_bin | grep -F "$address" > /dev/null +} + STUNNEL_CONF="$WSREP_SST_OPT_DATA/stunnel.conf" rm -f "$STUNNEL_CONF" @@ -159,7 +197,7 @@ fi # --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' +FILTER="-f '- /lost+found' -f '- /.fseventsd' -f '- /.Trashes' -f '+ /wsrep_sst_binlog.tar' @@ -167,7 +205,7 @@ FILTER=(-f '- /lost+found' -f '- $INNODB_DATA_HOME_DIR/ibdata*' -f '+ /undo*' -f '+ /*/' - -f '- /*') + -f '- /*'" SSTKEY=$(parse_cnf sst tkey "") SSTCERT=$(parse_cnf sst tcert "") @@ -260,10 +298,10 @@ EOF # first, the normal directories, so that we can detect incompatible protocol RC=0 - rsync ${STUNNEL:+--rsh="$STUNNEL"} \ + eval rsync ${STUNNEL:+--rsh="$STUNNEL"} \ --owner --group --perms --links --specials \ --ignore-times --inplace --dirs --delete --quiet \ - $WHOLE_FILE_OPT "${FILTER[@]}" "$WSREP_SST_OPT_DATA/" \ + $WHOLE_FILE_OPT ${FILTER} "$WSREP_SST_OPT_DATA/" \ rsync://$WSREP_SST_OPT_ADDR >&2 || RC=$? if [ "$RC" -ne 0 ]; then @@ -407,10 +445,26 @@ 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} + # If the IP is local listen only in it + if is_local_ip "$RSYNC_ADDR" + then + RSYNC_EXTRA_ARGS="--address $RSYNC_ADDR" + STUNNEL_ACCEPT="$RSYNC_ADDR:$RSYNC_PORT" + else + # Not local, possibly a NAT, listen on all interfaces + RSYNC_EXTRA_ARGS="" + STUNNEL_ACCEPT="$RSYNC_PORT" + # Overwrite address with all + RSYNC_ADDR="*" + fi -cat << EOF > "$STUNNEL_CONF" + if [ -z "$STUNNEL" ] + then + rsync --daemon --no-detach --port "$RSYNC_PORT" --config "$RSYNC_CONF" ${RSYNC_EXTRA_ARGS} & + RSYNC_REAL_PID=$! + else + cat << EOF > "$STUNNEL_CONF" key = $SSTKEY cert = $SSTCERT foreground = yes @@ -418,23 +472,16 @@ pid = $STUNNEL_PID debug = warning client = no [rsync] -accept = $RSYNC_PORT +accept = $STUNNEL_ACCEPT 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 + stunnel "$STUNNEL_CONF" & + RSYNC_REAL_PID=$! + RSYNC_PID=$STUNNEL_PID fi - until check_pid_and_port "$RSYNC_PID" "$RSYNC_REAL_PID" "$RSYNC_PORT" + until check_pid_and_port "$RSYNC_PID" "$RSYNC_REAL_PID" "$RSYNC_ADDR" "$RSYNC_PORT" do sleep 0.2 done @@ -479,6 +526,7 @@ EOF done fi cd "$OLD_PWD" + fi if [ -r "$MAGIC_FILE" ] then |