Galera/mysql集群备忘(三)

2014-11-24 13:50:18 · 作者: · 浏览: 4
age: wait_for_pid created|removed pid pid_file_path" exit 1 ;; esac

# if server isn't running, then pid-file will never be updated if test -n "$pid"; then if kill -0 "$pid" 2>/dev/null; then : # the server still runs

else # The server may have exited between the last pid-file check and now. if test -n "$avoid_race_condition"; then avoid_race_condition="" continue # Check again. fi

# there's nothing that will affect the file. log_failure_msg "The server quit without updating PID file ($pid_file_path)." return 1 # not waiting any more. fi fi

if test -e $sst_progress_file && [ $startup_sleep -ne 100 ];then echo $echo_n "SST in progress, setting sleep higher" startup_sleep=100 fi

echo $echo_n ".$echo_c" i=`expr $i + 1` sleep $startup_sleep

done

if test -z "$i" ; then log_success_msg return 0 else log_failure_msg return 1 fi }

# Get arguments from the my.cnf file, # the only group, which is read from now on is [mysqld] if test -x ./bin/my_print_defaults then

print_defaults="./bin/my_print_defaults" elif test -x $bindir/my_print_defaults then print_defaults="$bindir/my_print_defaults" elif test -x $bindir/mysql_print_defaults then print_defaults="$bindir/mysql_print_defaults" else # Try to find basedir in /etc/my.cnf conf=/usr/local/mysql/etc/my.cnf print_defaults= if test -r $conf then subpat='^[^=]*basedir[^=]*=\(.*\)$' dirs=`sed -e "/$subpat/!d" -e 's//\1/' $conf` for d in $dirs do d=`echo $d | sed -e 's/[ ]//g'` if test -x "$d/bin/my_print_defaults" then print_defaults="$d/bin/my_print_defaults" break fi if test -x "$d/bin/mysql_print_defaults" then print_defaults="$d/bin/mysql_print_defaults" break fi done fi

# Hope it's in the PATH ... but I doubt it test -z "$print_defaults" && print_defaults="my_print_defaults" fi

# # Read defaults file from 'basedir'. If there is no defaults file there

# check if it's in the old (depricated) place (datadir) and read it from there #

extra_args="" if test -r "$basedir/my.cnf" then extra_args="-e $basedir/my.cnf" else if test -r "$datadir/my.cnf" then extra_args="-e $datadir/my.cnf" fi fi

parse_server_arguments `$print_defaults $extra_args mysqld server mysql_server mysql.server`

# # Set pid file if not given # if test -z "$mysqld_pid_file_path" then mysqld_pid_file_path=$datadir/`hostname`.pid else case "$mysqld_pid_file_path" in /* ) ;; * ) mysqld_pid_file_path="$datadir/$mysqld_pid_file_path" ;; esac fi

case "$mode" in 'start') # Start daemon

# Safeguard (relative paths, core dumps..) cd $basedir

echo $echo_n "Starting MySQL"

if test -x $bindir/mysqld_safe then # Give extra arguments to mysqld with the my.cnf file. This script # may be overwritten at next upgrade. $bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null 2>&1 & wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$

# Make lock for RedHat / SuSE if test -w "$lockdir" then touch "$lock_file_path" fi

exit $return_value else log_failure_msg "Couldn't find MySQL server ($bindir/mysqld_safe)" fi ;;

'stop') # Stop daemon. We use a signal here to avoid having to know the # root password.

if test -s "$mysqld_pid_file_path" then mysqld_pid=`cat "$mysqld_pid_file_path"`

if (kill -0 $mysqld_pid 2>/dev/null) then echo $echo_n "Shutting down MySQL" kill $mysqld_pid # mysqld should remove the pid file when it exits, so wait for it. wait_for_pid removed "$mysqld_pid" "$mysqld_pid_file_path"; return_value=$ else log_failure_msg "MySQL se