2004-04-14 15:46:39 +02:00
|
|
|
#!/bin/sh
|
|
|
|
# Copyright (C) 2004 MySQL AB
|
|
|
|
# For a more info consult the file COPYRIGHT distributed with this file
|
|
|
|
|
|
|
|
# This scripts starts the table handler ndbcluster
|
|
|
|
|
|
|
|
# configurable parameters, make sure to change in mysqlcluterd as well
|
2004-06-28 20:22:39 +02:00
|
|
|
port_base="2200"
|
2004-04-14 15:46:39 +02:00
|
|
|
fsdir=`pwd`
|
|
|
|
# end configurable parameters
|
|
|
|
|
2004-06-02 02:54:58 +02:00
|
|
|
#BASEDIR is always one above mysql-test directory
|
|
|
|
CWD=`pwd`
|
|
|
|
cd ..
|
|
|
|
BASEDIR=`pwd`
|
|
|
|
cd $CWD
|
2004-05-27 09:04:45 +02:00
|
|
|
|
2004-06-02 02:54:58 +02:00
|
|
|
# Are we using a source or a binary distribution?
|
2004-05-27 09:04:45 +02:00
|
|
|
if [ -d ../sql ] ; then
|
|
|
|
SOURCE_DIST=1
|
2004-06-02 02:54:58 +02:00
|
|
|
ndbtop=$BASEDIR/ndb
|
2004-06-02 12:37:43 +02:00
|
|
|
exec_ndb=$ndbtop/src/kernel/ndbd
|
2004-06-02 12:37:42 +02:00
|
|
|
exec_mgmtsrvr=$ndbtop/src/mgmsrv/ndb_mgmd
|
2004-05-27 10:05:10 +02:00
|
|
|
exec_waiter=$ndbtop/tools/ndb_waiter
|
2004-06-02 12:37:43 +02:00
|
|
|
exec_mgmtclient=$ndbtop/src/mgmclient/ndb_mgm
|
2004-05-27 09:04:45 +02:00
|
|
|
else
|
|
|
|
BINARY_DIST=1
|
2004-06-02 12:37:42 +02:00
|
|
|
if test -x "$BASEDIR/libexec/ndbd"
|
2004-06-02 02:54:58 +02:00
|
|
|
then
|
2004-06-02 12:37:42 +02:00
|
|
|
exec_ndb=$BASEDIR/libexec/ndbd
|
|
|
|
exec_mgmtsrvr=$BASEDIR/libexec/ndb_mgmd
|
2004-06-02 02:54:58 +02:00
|
|
|
else
|
2004-06-02 12:37:42 +02:00
|
|
|
exec_ndb=$BASEDIR/bin/ndbd
|
|
|
|
exec_mgmtsrvr=$BASEDIR/bin/ndb_mgmd
|
2004-06-02 02:54:58 +02:00
|
|
|
fi
|
|
|
|
exec_waiter=$BASEDIR/bin/ndb_waiter
|
2004-06-02 12:37:43 +02:00
|
|
|
exec_mgmtclient=$BASEDIR/bin/ndb_mgm
|
2004-05-27 09:04:45 +02:00
|
|
|
fi
|
2004-04-14 15:46:39 +02:00
|
|
|
|
|
|
|
pidfile=ndbcluster.pid
|
2004-06-02 12:37:42 +02:00
|
|
|
cfgfile=Ndb.cfg
|
|
|
|
stop_ndb=
|
|
|
|
initial_ndb=
|
2004-06-15 09:01:36 +02:00
|
|
|
status_ndb=
|
|
|
|
ndb_discless=0
|
|
|
|
|
|
|
|
ndb_con_op=100000
|
|
|
|
ndb_dmem=80M
|
|
|
|
ndb_imem=24M
|
2004-04-14 15:46:39 +02:00
|
|
|
|
|
|
|
while test $# -gt 0; do
|
|
|
|
case "$1" in
|
2004-06-02 12:37:42 +02:00
|
|
|
--stop)
|
|
|
|
stop_ndb=1
|
|
|
|
;;
|
2004-04-14 15:46:39 +02:00
|
|
|
--initial)
|
|
|
|
flags_ndb=$flags_ndb" -i"
|
|
|
|
initial_ndb=1
|
|
|
|
;;
|
2004-06-15 09:01:36 +02:00
|
|
|
--status)
|
|
|
|
status_ndb=1
|
|
|
|
;;
|
|
|
|
--small)
|
|
|
|
ndb_con_op=10000
|
|
|
|
ndb_dmem=40M
|
|
|
|
ndb_imem=12M
|
|
|
|
;;
|
|
|
|
--discless)
|
|
|
|
ndb_discless=1
|
|
|
|
;;
|
2004-04-14 15:46:39 +02:00
|
|
|
--data-dir=*)
|
|
|
|
fsdir=`echo "$1" | sed -e "s;--data-dir=;;"`
|
|
|
|
;;
|
|
|
|
--port-base=*)
|
|
|
|
port_base=`echo "$1" | sed -e "s;--port-base=;;"`
|
|
|
|
;;
|
|
|
|
-- ) shift; break ;;
|
|
|
|
--* ) $ECHO "Unrecognized option: $1"; exit 1 ;;
|
|
|
|
* ) break ;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
fs_ndb=$fsdir/ndbcluster
|
2004-06-28 20:22:39 +02:00
|
|
|
fs_name_1=$fs_ndb/node-1-fs-$port_base
|
|
|
|
fs_name_2=$fs_ndb/node-2-fs-$port_base
|
2004-04-14 15:46:39 +02:00
|
|
|
|
|
|
|
NDB_HOME=
|
|
|
|
export NDB_CONNECTSTRING
|
|
|
|
if [ ! -x $fsdir ]; then
|
|
|
|
echo "$fsdir missing"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ ! -x $exec_ndb ]; then
|
|
|
|
echo "$exec_ndb missing"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ ! -x $exec_mgmtsrv ]; then
|
|
|
|
echo "$exec_mgmtsrvr missing"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
start_default_ndbcluster() {
|
|
|
|
|
|
|
|
# do some checks
|
|
|
|
|
|
|
|
NDB_CONNECTSTRING=
|
|
|
|
|
|
|
|
if [ $initial_ndb ] ; then
|
2004-04-18 22:02:12 +02:00
|
|
|
[ -d $fs_ndb ] || mkdir $fs_ndb
|
2004-06-28 20:22:39 +02:00
|
|
|
[ -d $fs_name_1 ] || mkdir $fs_name_1
|
2004-04-18 22:02:12 +02:00
|
|
|
[ -d $fs_name_2 ] || mkdir $fs_name_2
|
2004-04-14 15:46:39 +02:00
|
|
|
fi
|
2004-06-28 20:22:39 +02:00
|
|
|
if [ -d "$fs_ndb" -a -d "$fs_name_1" -a -d "$fs_name_2" ]; then :; else
|
2004-04-14 15:46:39 +02:00
|
|
|
echo "$fs_ndb filesystem directory does not exist"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# set som help variables
|
|
|
|
|
|
|
|
ndb_host="localhost"
|
2004-06-28 20:22:39 +02:00
|
|
|
ndb_mgmd_port=$port_base
|
|
|
|
port_transporter=`expr $ndb_mgmd_port + 2`
|
|
|
|
export NDB_CONNECTSTRING="host=$ndb_host:$ndb_mgmd_port"
|
2004-04-14 15:46:39 +02:00
|
|
|
|
|
|
|
|
|
|
|
# Start management server as deamon
|
|
|
|
|
|
|
|
# Edit file system path and ports in config file
|
|
|
|
|
|
|
|
if [ $initial_ndb ] ; then
|
|
|
|
sed \
|
2004-06-15 09:01:36 +02:00
|
|
|
-e s,"CHOOSE_MaxNoOfConcurrentOperations",$ndb_con_op,g \
|
|
|
|
-e s,"CHOOSE_DataMemory",$ndb_dmem,g \
|
|
|
|
-e s,"CHOOSE_IndexMemory",$ndb_imem,g \
|
|
|
|
-e s,"CHOOSE_Discless",$ndb_discless,g \
|
2004-04-14 15:46:39 +02:00
|
|
|
-e s,"CHOOSE_HOSTNAME_".*,"$ndb_host",g \
|
2004-06-28 20:22:39 +02:00
|
|
|
-e s,"CHOOSE_FILESYSTEM_NODE_1","$fs_name_1",g \
|
2004-04-14 15:46:39 +02:00
|
|
|
-e s,"CHOOSE_FILESYSTEM_NODE_2","$fs_name_2",g \
|
2004-06-28 20:22:39 +02:00
|
|
|
-e s,"CHOOSE_PORT_MGM",$ndb_mgmd_port,g \
|
|
|
|
-e s,"CHOOSE_PORT_TRANSPORTER",$port_transporter,g \
|
2004-04-14 15:46:39 +02:00
|
|
|
< ndb/ndb_config_2_node.ini \
|
2004-06-28 20:22:39 +02:00
|
|
|
> "$fs_ndb/config.ini"
|
2004-04-14 15:46:39 +02:00
|
|
|
fi
|
|
|
|
|
2004-06-28 20:22:39 +02:00
|
|
|
rm -f Ndb.cfg
|
|
|
|
rm -f $fs_ndb/Ndb.cfg
|
|
|
|
|
|
|
|
if ( cd $fs_ndb ; $exec_mgmtsrvr -d -c config.ini ) ; then :; else
|
2004-04-14 15:46:39 +02:00
|
|
|
echo "Unable to start $exec_mgmtsrvr from `pwd`"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2004-06-28 20:22:39 +02:00
|
|
|
cat `find $fs_ndb -name 'ndb_*.pid'` > $pidfile
|
2004-04-14 15:46:39 +02:00
|
|
|
|
|
|
|
# Start database node
|
|
|
|
|
2004-06-28 20:22:39 +02:00
|
|
|
echo "Starting ndbd"
|
|
|
|
( cd $fs_ndb ; $exec_ndb -d $flags_ndb & )
|
2004-04-14 15:46:39 +02:00
|
|
|
|
2004-06-28 20:22:39 +02:00
|
|
|
cat `find $fs_ndb -name 'ndb_*.pid'` > $pidfile
|
2004-04-14 15:46:39 +02:00
|
|
|
|
|
|
|
# Start database node
|
|
|
|
|
2004-06-28 20:22:39 +02:00
|
|
|
echo "Starting ndbd"
|
|
|
|
( cd $fs_ndb ; $exec_ndb -d $flags_ndb & )
|
2004-04-14 15:46:39 +02:00
|
|
|
|
2004-06-28 20:22:39 +02:00
|
|
|
cat `find $fs_ndb -name 'ndb_*.pid'` > $pidfile
|
2004-04-14 15:46:39 +02:00
|
|
|
|
|
|
|
# test if Ndb Cluster starts properly
|
|
|
|
|
2004-06-15 09:01:36 +02:00
|
|
|
echo "Waiting for started..."
|
2004-05-27 09:04:45 +02:00
|
|
|
if ( $exec_waiter ) | grep "NDBT_ProgramExit: 0 - OK"; then :; else
|
2004-04-14 15:46:39 +02:00
|
|
|
echo "Ndbcluster startup failed"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2004-06-28 20:22:39 +02:00
|
|
|
cat `find $fs_ndb -name 'ndb_*.pid'` > $pidfile
|
2004-06-15 09:01:36 +02:00
|
|
|
|
|
|
|
status_ndbcluster
|
|
|
|
}
|
|
|
|
|
|
|
|
status_ndbcluster() {
|
2004-06-28 20:22:39 +02:00
|
|
|
# Start management client
|
|
|
|
echo "show" | $exec_mgmtclient $ndb_host $ndb_mgmd_port
|
2004-04-14 15:46:39 +02:00
|
|
|
}
|
|
|
|
|
2004-06-02 12:37:42 +02:00
|
|
|
stop_default_ndbcluster() {
|
|
|
|
|
|
|
|
#if [ ! -f $pidfile ] ; then
|
|
|
|
# exit 0
|
|
|
|
#fi
|
|
|
|
|
|
|
|
if [ ! -f $cfgfile ] ; then
|
|
|
|
echo "$cfgfile missing"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
ndb_host=`cat $cfgfile | sed -e "s,.*host=\(.*\)\:.*,\1,1"`
|
2004-06-28 20:22:39 +02:00
|
|
|
ndb_mgmd_port=`cat $cfgfile | sed -e "s,.*host=$ndb_host\:\([0-9]*\).*,\1,1"`
|
2004-06-02 12:37:42 +02:00
|
|
|
|
|
|
|
# Start management client
|
|
|
|
|
2004-06-28 20:22:39 +02:00
|
|
|
exec_mgmtclient="$exec_mgmtclient --try-reconnect=1 $ndb_host $ndb_mgmd_port"
|
2004-06-02 12:37:42 +02:00
|
|
|
|
|
|
|
echo "$exec_mgmtclient"
|
|
|
|
echo "all stop" | $exec_mgmtclient
|
|
|
|
|
|
|
|
sleep 5
|
|
|
|
|
|
|
|
if [ -f $pidfile ] ; then
|
2004-06-15 09:01:36 +02:00
|
|
|
kill `cat $pidfile` 2> /dev/null
|
2004-06-02 12:37:42 +02:00
|
|
|
rm $pidfile
|
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-06-15 09:01:36 +02:00
|
|
|
if [ $status_ndb ] ; then
|
|
|
|
status_ndbcluster
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2004-06-02 12:37:42 +02:00
|
|
|
if [ $stop_ndb ] ; then
|
|
|
|
stop_default_ndbcluster
|
|
|
|
else
|
|
|
|
start_default_ndbcluster
|
|
|
|
fi
|
2004-04-14 15:46:39 +02:00
|
|
|
|
|
|
|
exit 0
|