1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-01 06:46:55 +03:00

add mysql-Calpont back in

This commit is contained in:
david hill
2016-02-04 14:26:07 -06:00
parent 54ec8ef57e
commit a56875b62c
2 changed files with 208 additions and 265 deletions

View File

@ -349,7 +349,7 @@ rm -rf $RPM_BUILD_ROOT $RPM_BUILD_DIR/%{name}-%{version}-%{release}
/usr/local/Calpont/lib/libcalmysql.so.1.0.0
/usr/local/Calpont/lib/libudf_mysql.so.1.0.0
#/usr/local/Calpont/mysql/mysql-Calpont
/usr/local/Calpont/mysql/mysql-Calpont
/usr/local/Calpont/mysql/install_calpont_mysql.sh
/usr/local/Calpont/mysql/syscatalog_mysql.sql
/usr/local/Calpont/mysql/dumpcat_mysql.sql

View File

@ -1,9 +1,4 @@
#!/bin/bash
#
# $Id: mysql-Calpont 9604 2013-06-05 15:56:49Z dhill $
#
#!/bin/sh
# Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
# This file is public domain and comes with NO WARRANTY of any kind
@ -30,7 +25,7 @@
# Description: MySQL is a very fast and reliable SQL database engine.
### END INIT INFO
# If you install MySQL on some other places than /, then you
# If you install MySQL on some other places than /usr/local/Calpont/mysql, then you
# have to do one of the following things for this script to work:
#
# - Run this script from within the MySQL installation directory
@ -48,47 +43,34 @@
# If you change base dir, you must also change datadir. These may get
# overwritten by settings in the MySQL configuration files.
if [ -z "$INFINIDB_INSTALL_DIR" ]; then
test -f /etc/default/infinidb && . /etc/default/infinidb
fi
if [ -z "$INFINIDB_INSTALL_DIR" ]; then
INFINIDB_INSTALL_DIR=/usr/local/Calpont
SUDO=
else
SUDO="sudo"
fi
export INFINIDB_INSTALL_DIR=$INFINIDB_INSTALL_DIR
basedir=$INFINIDB_INSTALL_DIR/mysql
datadir=$basedir/db
basedir=/usr/local/Calpont/mysql
datadir=/usr/local/Calpont/mysql/db
# Default value, in seconds, afterwhich the script should timeout waiting
# for server start.
# Value here is overriden by value in my.cnf.
# 0 means don't wait at all
# Negative numbers mean to wait indefinitely
service_startup_timeout=30
service_shutdown_timeout=3
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.
# Set some defaults
pid_file=
server_pid_file=
use_mysqld_safe=1
user=mysql
mysqld_pid_file_path=
if test -z "$basedir"
then
basedir=/
bindir=/usr/bin
basedir=/usr/local/Calpont/mysql
bindir=/usr/local/bin
if test -z "$datadir"
then
datadir=/var/lib/mysql
fi
sbindir=/usr/sbin
libexecdir=/usr/sbin
sbindir=/usr/local/sbin
libexecdir=/usr/local/sbin
else
bindir="$basedir/bin"
if test -z "$datadir"
@ -96,7 +78,12 @@ else
datadir="$basedir/data"
fi
sbindir="$basedir/sbin"
if test -f "$basedir/sbin/mysqld"
then
libexecdir="$basedir/sbin"
else
libexecdir="$basedir/libexec"
fi
fi
# datadir_set is used to determine if datadir was set (and so should be
@ -110,6 +97,11 @@ lsb_functions="/lib/lsb/init-functions"
if test -f $lsb_functions ; then
. $lsb_functions
else
# Include non-LSB RedHat init functions to make systemctl redirect work
init_functions="/etc/init.d/functions"
if test -f $init_functions; then
. $init_functions
fi
log_success_msg()
{
echo " SUCCESS! $@"
@ -120,15 +112,12 @@ else
}
fi
PATH=/sbin:/usr/sbin:/bin:/usr/bin:$basedir/bin
PATH="/sbin:/usr/sbin:/bin:/usr/bin:$basedir/bin"
export PATH
mode=$1 # start or stop
shift
other_args="$*" # uncommon, but needed when called from an RPM upgrade action
# Expected: "--skip-networking --skip-grant-tables"
# They are not checked here, intentionally, as it is the resposibility
# of the "spec" file author to give correct arguments only.
[ $# -ge 1 ] && shift
case `echo "testing\c"`,`echo -n testing` in
*c*,-n*) echo_n= echo_c= ;;
@ -145,116 +134,26 @@ parse_server_arguments() {
datadir="$basedir/data"
fi
sbindir="$basedir/sbin"
if test -f "$basedir/sbin/mysqld"
then
libexecdir="$basedir/sbin"
else
libexecdir="$basedir/libexec"
fi
#libexecdir="$basedir/libexec"
;;
--datadir=*) datadir=`echo "$arg" | sed -e 's/^[^=]*=//'`
datadir_set=1
;;
--user=*) user=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
--pid-file=*) server_pid_file=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
--log-basename=*|--hostname=*|--loose-log-basename=*)
mysqld_pid_file_path=`echo "$arg.pid" | sed -e 's/^[^=]*=//'`
;;
--pid-file=*) mysqld_pid_file_path=`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
done
}
wait_for_pid () {
verb="$1"
manager_pid="$2" # process ID of the program operating on the pid-file
i=0
avoid_race_condition="by checking again"
case "$verb" in
'created')
timeout=$service_startup_timeout
;;
'removed')
timeout=$service_shutdown_timeout
;;
*)
timeout=$service_startup_timeout
;;
esac
while test $i -ne $timeout ; do
case "$verb" in
'created')
# wait for a PID-file to pop into existence.
test -s $pid_file && i='' && break
;;
'removed')
# wait for this PID-file to disappear
test ! -s $pid_file && i='' && break
;;
*)
echo "wait_for_pid () usage: wait_for_pid created|removed manager_pid"
exit 1
;;
esac
# if manager isn't running, then pid-file will never be updated
if test -n "$manager_pid"; then
if kill -0 "$manager_pid" 2>/dev/null; then
: # the manager still runs
else
# The manager 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
kill_by_pid
# there's nothing that will affect the file.
log_failure_msg "Manager of pid-file quit without updating file."
return 1 # not waiting any more.
fi
fi
echo $echo_n ".$echo_c"
i=`expr $i + 1`
sleep 1
done
if test -z "$i" ; then
log_success_msg
return 0
else
log_failure_msg
return 1
fi
}
kill_by_pid() {
# let's see if we can kill the 2 mysql procs by hand
# get the our mysql from ps
eval $(ps -ef | grep "$INFINIDB_INSTALL_DIR/mysql/libexec/mysqld" | grep -v grep | head -1 | awk '{printf "pid=%d\n", $2}')
if [ -n "$pid" ]; then
ppid=$(ps -o ppid= -p $pid)
$SUDO kill -9 $ppid
kill -9 $ppid
sleep 1
$SUDO kill -9 $pid
kill -9 $pid
echo $echo_n "Force shutting down (no/bad pid file)"
log_success_msg
exit 0
fi
return
}
# 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
@ -268,7 +167,7 @@ then
print_defaults="$bindir/mysql_print_defaults"
else
# Try to find basedir in /etc/my.cnf
conf=$basedir/mysql/my.cnf
conf=/etc/my.cnf
print_defaults=
if test -r $conf
then
@ -302,109 +201,125 @@ fi
extra_args=""
if test -r "$basedir/my.cnf"
then
extra_args="-c $basedir/my.cnf"
extra_args="-e $basedir/my.cnf"
else
if test -r "$datadir/my.cnf"
then
extra_args="-c $datadir/my.cnf"
extra_args="-e $datadir/my.cnf"
fi
fi
parse_server_arguments `$print_defaults $extra_args mysqld server mysql_server mysql.server`
parse_server_arguments `$print_defaults $extra_args --mysqld mysql.server`
parse_server_arguments "$@"
# Look for the pidfile
parse_manager_arguments `$print_defaults $extra_args manager`
# wait for the pid file to disappear
wait_for_gone () {
pid="$1" # process ID of the program operating on the pid-file
pid_file_path="$2" # path to the PID file.
i=0
crash_protection="by checking again"
while test $i -ne $service_startup_timeout ; do
if kill -0 "$pid" 2>/dev/null; then
: # the server still runs
else
if test ! -s "$pid_file_path"; then
# no server process and no pid-file? great, we're done!
log_success_msg
return 0
fi
# pid-file exists, the server process doesn't.
# it must've crashed, and mysqld_safe will restart it
if test -n "$crash_protection"; then
crash_protection=""
sleep 5
continue # Check again.
fi
# Cannot help it
log_failure_msg "The server quit without updating PID file ($pid_file_path)."
return 1 # not waiting any more.
fi
echo $echo_n ".$echo_c"
i=`expr $i + 1`
sleep 1
done
log_failure_msg
return 1
}
wait_for_ready () {
i=0
while test $i -ne $service_startup_timeout ; do
if $bindir/mysqladmin ping --socket=/usr/local/Calpont/mysql/lib/mysql/mysql.sock >/dev/null 2>&1; then
log_success_msg
return 0
elif kill -0 $! 2>/dev/null ; then
: # mysqld_safe is still running
else
# mysqld_safe is no longer running, abort the wait loop
break
fi
echo $echo_n ".$echo_c"
i=`expr $i + 1`
sleep 1
done
log_failure_msg
return 1
}
#
# Set pid file if not given
#
if test -z "$pid_file"
if test -z "$mysqld_pid_file_path"
then
pid_file=$datadir/mysqlmanager-`/bin/hostname`.pid
mysqld_pid_file_path=$datadir/`hostname`.pid
else
case "$pid_file" in
case "$mysqld_pid_file_path" in
/* ) ;;
* ) pid_file="$datadir/$pid_file" ;;
esac
fi
if test -z "$server_pid_file"
then
server_pid_file=$datadir/`/bin/hostname`.pid
else
case "$server_pid_file" in
/* ) ;;
* ) server_pid_file="$datadir/$server_pid_file" ;;
* ) mysqld_pid_file_path="$datadir/$mysqld_pid_file_path" ;;
esac
fi
# source other config files
[ -f /etc/default/mysql ] && . /etc/default/mysql
[ -f /etc/sysconfig/mysql ] && . /etc/sysconfig/mysql
[ -f /etc/conf.d/mysql ] && . /etc/conf.d/mysql
case "$mode" in
'start')
if [ -f /var/lock/subsys/mysql-Calpont ]; then
echo "InfiniDB MySQL already running"
exit 0
fi
# Start daemon
# Safeguard (relative paths, core dumps..)
cd $basedir
manager=$bindir/mysqlmanager
if test -x $libexecdir/mysqlmanager
then
manager=$libexecdir/mysqlmanager
elif test -x $sbindir/mysqlmanager
then
manager=$sbindir/mysqlmanager
fi
# @bug 2104. remove all left over vtables. Look for @0024vtable ($vtable).
# "@0024vtable" is a reserved word of InfiniDB and can not be used in regular user table name.
cd db
find . -name '@0024vtable*' | xargs /bin/rm -f
cd ..
# hook for InfiniDB automated testing
test -x /usr/local/bin/idb-testing-mysql-pre-start && /usr/local/bin/idb-testing-mysql-pre-start $basedir
echo $echo_n "Starting MySQL"
if test -x $manager -a "$use_mysqld_safe" = "0"
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-Calpont
fi
exit $return_value
elif test -x $bindir/mysqld_safe
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.
pid_file=$server_pid_file
$bindir/mysqld_safe --defaults-file=$basedir/my.cnf --datadir=$datadir --pid-file=$server_pid_file $other_args >/dev/null 2>&1 &
wait_for_pid created $!; return_value=$?
$bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" "--ledir=$libexecdir" "$@" >/dev/null 2>&1 &
wait_for_ready; return_value=$?
# Make lock for RedHat / SuSE
if test -w /var/lock/subsys
if test -w "$lockdir"
then
touch /var/lock/subsys/mysql-Calpont
touch "$lock_file_path"
fi
exit $return_value
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
;;
@ -412,52 +327,40 @@ case "$mode" in
# Stop daemon. We use a signal here to avoid having to know the
# root password.
# The RedHat / SuSE lock directory to remove
lock_dir=/var/lock/subsys/mysqlmanager-Calpont
# If the manager pid_file doesn't exist, try the server's
if test ! -s "$pid_file"
if test -s "$mysqld_pid_file_path"
then
pid_file=$server_pid_file
lock_dir=/var/lock/subsys/mysql-Calpont
fi
mysqld_pid=`cat "$mysqld_pid_file_path"`
if test -s "$pid_file"
if (kill -0 $mysqld_pid 2>/dev/null)
then
mysqlmanager_pid=`cat $pid_file`
echo $echo_n "Shutting down MySQL"
$SUDO kill $mysqlmanager_pid
kill $mysqlmanager_pid
# mysqlmanager should remove the pid_file when it exits, so wait for it.
wait_for_pid removed "$mysqlmanager_pid"
# @bug2639. force kill mysqld and mysqld_safe after timeout
$SUDO kill -9 $(ps -efl|awk "{if (\$4==$mysqlmanager_pid) print \$5}") &>/dev/null
kill -9 $(ps -efl|awk "{if (\$4==$mysqlmanager_pid) print \$5}") &>/dev/null
$SUDO kill -9 $mysqlmanager_pid &>/dev/null
kill -9 $mysqlmanager_pid &>/dev/null
log_success_msg
kill $mysqld_pid
# mysqld should remove the pid file when it exits, so wait for it.
wait_for_gone $mysqld_pid "$mysqld_pid_file_path"; return_value=$?
else
kill_by_pid
log_failure_msg "MySQL manager or server PID file could not be found!"
log_failure_msg "MySQL server process #$mysqld_pid is not running!"
rm "$mysqld_pid_file_path"
fi
# delete lock for RedHat / SuSE
if test -f $lock_dir
# Delete lock for RedHat / SuSE
if test -f "$lock_file_path"
then
rm -f $lock_dir
rm -f "$lock_file_path"
fi
exit $return_value
else
log_failure_msg "MySQL server PID file could not be found!"
fi
# hook for InfiniDB automated testing
test -x /usr/local/bin/idb-testing-mysql-post-stop && /usr/local/bin/idb-testing-mysql-post-stop $basedir
;;
'restart')
# Stop the service and regardless of whether it was
# running or not, start it again.
if $0 stop $other_args; then
$0 start $other_args
if $0 stop "$@"; then
if ! $0 start "$@"; then
log_failure_msg "Failed to restart server."
exit 1
fi
else
log_failure_msg "Failed to stop running server, so refusing to try to start."
exit 1
@ -465,10 +368,10 @@ case "$mode" in
;;
'reload'|'force-reload')
if test -s "$server_pid_file" ; then
read mysqld_pid < $server_pid_file
if test -s "$mysqld_pid_file_path" ; then
read mysqld_pid < "$mysqld_pid_file_path"
kill -HUP $mysqld_pid && log_success_msg "Reloading service MySQL"
touch $server_pid_file
touch "$mysqld_pid_file_path"
else
log_failure_msg "MySQL PID file could not be found!"
exit 1
@ -476,8 +379,8 @@ case "$mode" in
;;
'status')
# First, check to see if pid file exists
if test -s "$server_pid_file" ; then
read mysqld_pid < $server_pid_file
if test -s "$mysqld_pid_file_path" ; then
read mysqld_pid < "$mysqld_pid_file_path"
if kill -0 $mysqld_pid 2>/dev/null ; then
log_success_msg "MySQL running ($mysqld_pid)"
exit 0
@ -488,27 +391,67 @@ case "$mode" in
else
# Try to find appropriate mysqld process
mysqld_pid=`pidof $libexecdir/mysqld`
if test -z $mysqld_pid ; then
if test "$use_mysqld_safe" = "0" ; then
lockfile=/var/lock/subsys/mysqlmanager-Calpont
else
lockfile=/var/lock/subsys/mysql-Calpont
fi
if test -f $lockfile ; then
log_failure_msg "MySQL is not running, but lock exists"
# test if multiple pids exist
pid_count=`echo $mysqld_pid | wc -w`
if test $pid_count -gt 1 ; then
log_failure_msg "Multiple MySQL running but PID file could not be found ($mysqld_pid)"
exit 5
elif test -z $mysqld_pid ; then
if test -f "$lock_file_path" ; then
log_failure_msg "MySQL is not running, but lock file ($lock_file_path) exists"
exit 2
fi
log_failure_msg "MySQL is not running"
exit 3
else
log_failure_msg "MySQL running but PID file could not be found"
log_failure_msg "MySQL is running but PID file could not be found"
exit 4
fi
fi
;;
'configtest')
# Safeguard (relative paths, core dumps..)
cd $basedir
echo $echo_n "Testing MySQL configuration syntax"
daemon=$bindir/mysqld
if test -x $libexecdir/mysqld
then
daemon=$libexecdir/mysqld
elif test -x $sbindir/mysqld
then
daemon=$sbindir/mysqld
elif test -x `which mysqld`
then
daemon=`which mysqld`
else
log_failure_msg "Unable to locate the mysqld binary!"
exit 1
fi
help_out=`$daemon --help 2>&1`; r=$?
if test "$r" != 0 ; then
log_failure_msg "$help_out"
log_failure_msg "There are syntax errors in the server configuration. Please fix them!"
else
log_success_msg "Syntax OK"
fi
exit $r
;;
'bootstrap')
if test "$_use_systemctl" == 1 ; then
log_failure_msg "Please use galera_new_cluster to start the mariadb service with --wsrep-new-cluster"
exit 1
fi
# Bootstrap the cluster, start the first node
# that initiate the cluster
echo $echo_n "Bootstrapping the cluster.. "
$0 start $other_args --wsrep-new-cluster
exit $?
;;
*)
# 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|configtest|bootstrap} [ MySQL server options ]"
exit 1
;;
esac