Backport WL#4085: Merge revno:2617.56.29 from 6.0.
This commit is contained in:
parent
f952bbe55c
commit
50486457b1
@ -22,6 +22,5 @@ base_configs=" \
|
|||||||
--enable-local-infile \
|
--enable-local-infile \
|
||||||
--with-extra-charsets=all \
|
--with-extra-charsets=all \
|
||||||
--prefix=N:/mysql \
|
--prefix=N:/mysql \
|
||||||
--without-mysqlmanager \
|
|
||||||
--without-man \
|
--without-man \
|
||||||
"
|
"
|
||||||
|
@ -7499,10 +7499,7 @@ SHOW_VAR status_vars[]= {
|
|||||||
static void print_version(void)
|
static void print_version(void)
|
||||||
{
|
{
|
||||||
set_server_version();
|
set_server_version();
|
||||||
/*
|
|
||||||
Note: the instance manager keys off the string 'Ver' so it can find the
|
|
||||||
version from the output of 'mysqld --version', so don't change it!
|
|
||||||
*/
|
|
||||||
printf("%s Ver %s for %s on %s (%s)\n",my_progname,
|
printf("%s Ver %s for %s on %s (%s)\n",my_progname,
|
||||||
server_version,SYSTEM_TYPE,MACHINE_TYPE, MYSQL_COMPILATION_COMMENT);
|
server_version,SYSTEM_TYPE,MACHINE_TYPE, MYSQL_COMPILATION_COMMENT);
|
||||||
}
|
}
|
||||||
|
@ -53,13 +53,14 @@ datadir=
|
|||||||
# Negative numbers mean to wait indefinitely
|
# Negative numbers mean to wait indefinitely
|
||||||
service_startup_timeout=900
|
service_startup_timeout=900
|
||||||
|
|
||||||
|
# Lock directory for RedHat / SuSE.
|
||||||
|
lockdir='/var/lock/subsys'
|
||||||
|
lock_file_path="$lockdir/mysql"
|
||||||
|
|
||||||
# The following variables are only set for letting mysql.server find things.
|
# The following variables are only set for letting mysql.server find things.
|
||||||
|
|
||||||
# Set some defaults
|
# Set some defaults
|
||||||
pid_file=
|
mysqld_pid_file_path=
|
||||||
server_pid_file=
|
|
||||||
use_mysqld_safe=1
|
|
||||||
user=@MYSQLD_USER@
|
|
||||||
if test -z "$basedir"
|
if test -z "$basedir"
|
||||||
then
|
then
|
||||||
basedir=@prefix@
|
basedir=@prefix@
|
||||||
@ -101,11 +102,14 @@ else
|
|||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PATH=/sbin:/usr/sbin:/bin:/usr/bin:$basedir/bin
|
PATH="/sbin:/usr/sbin:/bin:/usr/bin:$basedir/bin"
|
||||||
export PATH
|
export PATH
|
||||||
|
|
||||||
mode=$1 # start or stop
|
mode=$1 # start or stop
|
||||||
shift
|
|
||||||
|
[ $# -ge 1 ] && shift
|
||||||
|
|
||||||
|
|
||||||
other_args="$*" # uncommon, but needed when called from an RPM upgrade action
|
other_args="$*" # uncommon, but needed when called from an RPM upgrade action
|
||||||
# Expected: "--skip-networking --skip-grant-tables"
|
# Expected: "--skip-networking --skip-grant-tables"
|
||||||
# They are not checked here, intentionally, as it is the resposibility
|
# They are not checked here, intentionally, as it is the resposibility
|
||||||
@ -131,59 +135,50 @@ parse_server_arguments() {
|
|||||||
--datadir=*) datadir=`echo "$arg" | sed -e 's/^[^=]*=//'`
|
--datadir=*) datadir=`echo "$arg" | sed -e 's/^[^=]*=//'`
|
||||||
datadir_set=1
|
datadir_set=1
|
||||||
;;
|
;;
|
||||||
--user=*) user=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
|
--pid-file=*) mysqld_pid_file_path=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
|
||||||
--pid-file=*) server_pid_file=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
|
|
||||||
--service-startup-timeout=*) service_startup_timeout=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
|
--service-startup-timeout=*) service_startup_timeout=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
|
||||||
--use-mysqld_safe) use_mysqld_safe=1;;
|
|
||||||
--use-manager) use_mysqld_safe=0;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
parse_manager_arguments() {
|
|
||||||
for arg do
|
|
||||||
case "$arg" in
|
|
||||||
--pid-file=*) pid_file=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
|
|
||||||
--user=*) user=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
|
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
wait_for_pid () {
|
wait_for_pid () {
|
||||||
verb="$1"
|
verb="$1" # created | removed
|
||||||
manager_pid="$2" # process ID of the program operating on the pid-file
|
pid="$2" # process ID of the program operating on the pid-file
|
||||||
|
pid_file_path="$3" # path to the PID file.
|
||||||
|
|
||||||
i=0
|
i=0
|
||||||
avoid_race_condition="by checking again"
|
avoid_race_condition="by checking again"
|
||||||
|
|
||||||
while test $i -ne $service_startup_timeout ; do
|
while test $i -ne $service_startup_timeout ; do
|
||||||
|
|
||||||
case "$verb" in
|
case "$verb" in
|
||||||
'created')
|
'created')
|
||||||
# wait for a PID-file to pop into existence.
|
# wait for a PID-file to pop into existence.
|
||||||
test -s $pid_file && i='' && break
|
test -s "$pid_file_path" && i='' && break
|
||||||
;;
|
;;
|
||||||
'removed')
|
'removed')
|
||||||
# wait for this PID-file to disappear
|
# wait for this PID-file to disappear
|
||||||
test ! -s $pid_file && i='' && break
|
test ! -s "$pid_file_path" && i='' && break
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "wait_for_pid () usage: wait_for_pid created|removed manager_pid"
|
echo "wait_for_pid () usage: wait_for_pid created|removed pid pid_file_path"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# if manager isn't running, then pid-file will never be updated
|
# if server isn't running, then pid-file will never be updated
|
||||||
if test -n "$manager_pid"; then
|
if test -n "$pid"; then
|
||||||
if kill -0 "$manager_pid" 2>/dev/null; then
|
if kill -0 "$pid" 2>/dev/null; then
|
||||||
: # the manager still runs
|
: # the server still runs
|
||||||
else
|
else
|
||||||
# The manager may have exited between the last pid-file check and now.
|
# The server may have exited between the last pid-file check and now.
|
||||||
if test -n "$avoid_race_condition"; then
|
if test -n "$avoid_race_condition"; then
|
||||||
avoid_race_condition=""
|
avoid_race_condition=""
|
||||||
continue # Check again.
|
continue # Check again.
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# there's nothing that will affect the file.
|
# there's nothing that will affect the file.
|
||||||
log_failure_msg "Manager of pid-file quit without updating file."
|
log_failure_msg "The server quit without updating PID file ($pid_file_path)."
|
||||||
return 1 # not waiting any more.
|
return 1 # not waiting any more.
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -191,6 +186,7 @@ wait_for_pid () {
|
|||||||
echo $echo_n ".$echo_c"
|
echo $echo_n ".$echo_c"
|
||||||
i=`expr $i + 1`
|
i=`expr $i + 1`
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
if test -z "$i" ; then
|
if test -z "$i" ; then
|
||||||
@ -259,28 +255,16 @@ fi
|
|||||||
|
|
||||||
parse_server_arguments `$print_defaults $extra_args mysqld server mysql_server mysql.server`
|
parse_server_arguments `$print_defaults $extra_args mysqld server mysql_server mysql.server`
|
||||||
|
|
||||||
# Look for the pidfile
|
|
||||||
parse_manager_arguments `$print_defaults $extra_args manager`
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Set pid file if not given
|
# Set pid file if not given
|
||||||
#
|
#
|
||||||
if test -z "$pid_file"
|
if test -z "$mysqld_pid_file_path"
|
||||||
then
|
then
|
||||||
pid_file=$datadir/mysqlmanager-`@HOSTNAME@`.pid
|
mysqld_pid_file_path=$datadir/`@HOSTNAME@`.pid
|
||||||
else
|
else
|
||||||
case "$pid_file" in
|
case "$mysqld_pid_file_path" in
|
||||||
/* ) ;;
|
/* ) ;;
|
||||||
* ) pid_file="$datadir/$pid_file" ;;
|
* ) mysqld_pid_file_path="$datadir/$mysqld_pid_file_path" ;;
|
||||||
esac
|
|
||||||
fi
|
|
||||||
if test -z "$server_pid_file"
|
|
||||||
then
|
|
||||||
server_pid_file=$datadir/`@HOSTNAME@`.pid
|
|
||||||
else
|
|
||||||
case "$server_pid_file" in
|
|
||||||
/* ) ;;
|
|
||||||
* ) server_pid_file="$datadir/$server_pid_file" ;;
|
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -291,53 +275,23 @@ case "$mode" in
|
|||||||
# Safeguard (relative paths, core dumps..)
|
# Safeguard (relative paths, core dumps..)
|
||||||
cd $basedir
|
cd $basedir
|
||||||
|
|
||||||
manager=$bindir/mysqlmanager
|
|
||||||
if test -x $libexecdir/mysqlmanager
|
|
||||||
then
|
|
||||||
manager=$libexecdir/mysqlmanager
|
|
||||||
elif test -x $sbindir/mysqlmanager
|
|
||||||
then
|
|
||||||
manager=$sbindir/mysqlmanager
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo $echo_n "Starting MySQL"
|
echo $echo_n "Starting MySQL"
|
||||||
if test -x $manager -a "$use_mysqld_safe" = "0"
|
if test -x $bindir/mysqld_safe
|
||||||
then
|
|
||||||
if test -n "$other_args"
|
|
||||||
then
|
|
||||||
log_failure_msg "MySQL manager does not support options '$other_args'"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
# Give extra arguments to mysqld with the my.cnf file. This script may
|
|
||||||
# be overwritten at next upgrade.
|
|
||||||
"$manager" \
|
|
||||||
--mysqld-safe-compatible \
|
|
||||||
--user="$user" \
|
|
||||||
--pid-file="$pid_file" >/dev/null 2>&1 &
|
|
||||||
wait_for_pid created $!; return_value=$?
|
|
||||||
|
|
||||||
# Make lock for RedHat / SuSE
|
|
||||||
if test -w /var/lock/subsys
|
|
||||||
then
|
|
||||||
touch /var/lock/subsys/mysqlmanager
|
|
||||||
fi
|
|
||||||
exit $return_value
|
|
||||||
elif test -x $bindir/mysqld_safe
|
|
||||||
then
|
then
|
||||||
# Give extra arguments to mysqld with the my.cnf file. This script
|
# Give extra arguments to mysqld with the my.cnf file. This script
|
||||||
# may be overwritten at next upgrade.
|
# may be overwritten at next upgrade.
|
||||||
pid_file=$server_pid_file
|
$bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null 2>&1 &
|
||||||
$bindir/mysqld_safe --datadir=$datadir --pid-file=$server_pid_file $other_args >/dev/null 2>&1 &
|
wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$?
|
||||||
wait_for_pid created $!; return_value=$?
|
|
||||||
|
|
||||||
# Make lock for RedHat / SuSE
|
# Make lock for RedHat / SuSE
|
||||||
if test -w /var/lock/subsys
|
if test -w "$lockdir"
|
||||||
then
|
then
|
||||||
touch /var/lock/subsys/mysql
|
touch "$lock_file_path"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit $return_value
|
exit $return_value
|
||||||
else
|
else
|
||||||
log_failure_msg "Couldn't find MySQL manager ($manager) or server ($bindir/mysqld_safe)"
|
log_failure_msg "Couldn't find MySQL server ($bindir/mysqld_safe)"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
@ -345,39 +299,29 @@ case "$mode" in
|
|||||||
# Stop daemon. We use a signal here to avoid having to know the
|
# Stop daemon. We use a signal here to avoid having to know the
|
||||||
# root password.
|
# root password.
|
||||||
|
|
||||||
# The RedHat / SuSE lock directory to remove
|
if test -s "$mysqld_pid_file_path"
|
||||||
lock_dir=/var/lock/subsys/mysqlmanager
|
|
||||||
|
|
||||||
# If the manager pid_file doesn't exist, try the server's
|
|
||||||
if test ! -s "$pid_file"
|
|
||||||
then
|
then
|
||||||
pid_file=$server_pid_file
|
mysqld_pid=`cat "$mysqld_pid_file_path"`
|
||||||
lock_dir=/var/lock/subsys/mysql
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test -s "$pid_file"
|
if (kill -9 $mysqld_pid 2>/dev/null)
|
||||||
then
|
|
||||||
mysqlmanager_pid=`cat $pid_file`
|
|
||||||
|
|
||||||
if (kill -0 $mysqlmanager_pid 2>/dev/null)
|
|
||||||
then
|
then
|
||||||
echo $echo_n "Shutting down MySQL"
|
echo $echo_n "Shutting down MySQL"
|
||||||
kill $mysqlmanager_pid
|
kill $mysqld_pid
|
||||||
# mysqlmanager should remove the pid_file when it exits, so wait for it.
|
# mysqld should remove the pid file when it exits, so wait for it.
|
||||||
wait_for_pid removed "$mysqlmanager_pid"; return_value=$?
|
wait_for_pid removed "$mysqld_pid" "$mysqld_pid_file_path"; return_value=$?
|
||||||
else
|
else
|
||||||
log_failure_msg "MySQL manager or server process #$mysqlmanager_pid is not running!"
|
log_failure_msg "MySQL server process #$mysqld_pid is not running!"
|
||||||
rm $pid_file
|
rm "$mysqld_pid_file_path"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# delete lock for RedHat / SuSE
|
# Delete lock for RedHat / SuSE
|
||||||
if test -f $lock_dir
|
if test -f "$lock_file_path"
|
||||||
then
|
then
|
||||||
rm -f $lock_dir
|
rm -f "$lock_file_path"
|
||||||
fi
|
fi
|
||||||
exit $return_value
|
exit $return_value
|
||||||
else
|
else
|
||||||
log_failure_msg "MySQL manager or server PID file could not be found!"
|
log_failure_msg "MySQL server PID file could not be found!"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
@ -393,10 +337,10 @@ case "$mode" in
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
'reload'|'force-reload')
|
'reload'|'force-reload')
|
||||||
if test -s "$server_pid_file" ; then
|
if test -s "$mysqld_pid_file_path" ; then
|
||||||
read mysqld_pid < $server_pid_file
|
read mysqld_pid < "$mysqld_pid_file_path"
|
||||||
kill -HUP $mysqld_pid && log_success_msg "Reloading service MySQL"
|
kill -HUP $mysqld_pid && log_success_msg "Reloading service MySQL"
|
||||||
touch $server_pid_file
|
touch "$mysqld_pid_file_path"
|
||||||
else
|
else
|
||||||
log_failure_msg "MySQL PID file could not be found!"
|
log_failure_msg "MySQL PID file could not be found!"
|
||||||
exit 1
|
exit 1
|
||||||
@ -404,8 +348,8 @@ case "$mode" in
|
|||||||
;;
|
;;
|
||||||
'status')
|
'status')
|
||||||
# First, check to see if pid file exists
|
# First, check to see if pid file exists
|
||||||
if test -s "$server_pid_file" ; then
|
if test -s "$mysqld_pid_file_path" ; then
|
||||||
read mysqld_pid < $server_pid_file
|
read mysqld_pid < "$mysqld_pid_file_path"
|
||||||
if kill -0 $mysqld_pid 2>/dev/null ; then
|
if kill -0 $mysqld_pid 2>/dev/null ; then
|
||||||
log_success_msg "MySQL running ($mysqld_pid)"
|
log_success_msg "MySQL running ($mysqld_pid)"
|
||||||
exit 0
|
exit 0
|
||||||
@ -417,13 +361,8 @@ case "$mode" in
|
|||||||
# Try to find appropriate mysqld process
|
# Try to find appropriate mysqld process
|
||||||
mysqld_pid=`pidof $libexecdir/mysqld`
|
mysqld_pid=`pidof $libexecdir/mysqld`
|
||||||
if test -z $mysqld_pid ; then
|
if test -z $mysqld_pid ; then
|
||||||
if test "$use_mysqld_safe" = "0" ; then
|
if test -f "$lock_file_path" ; then
|
||||||
lockfile=/var/lock/subsys/mysqlmanager
|
log_failure_msg "MySQL is not running, but lock file ($lock_file_path) exists"
|
||||||
else
|
|
||||||
lockfile=/var/lock/subsys/mysql
|
|
||||||
fi
|
|
||||||
if test -f $lockfile ; then
|
|
||||||
log_failure_msg "MySQL is not running, but lock exists"
|
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
log_failure_msg "MySQL is not running"
|
log_failure_msg "MySQL is not running"
|
||||||
@ -436,7 +375,8 @@ case "$mode" in
|
|||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
# usage
|
# usage
|
||||||
echo "Usage: $0 {start|stop|restart|reload|force-reload|status} [ MySQL server options ]"
|
basename=`basename "$0"`
|
||||||
|
echo "Usage: $basename {start|stop|restart|reload|force-reload|status} [ MySQL server options ]"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
Loading…
x
Reference in New Issue
Block a user