With the maxdb start script, the database instance DEMODB is automatically transferred to the ONLINE operational state when the computer is started and automatically switched to the OFFLINE operational state when the computer is turned off.
Depending on the operating system you are using, you may have to modify the start script.
· You have created the database instance DEMODB and the DBM operator OLEG with the password MONDAY.
· You are in a root shell.
...
1. Save the maxdb start script in the directory /etc/init.d
2. Go to the directory /etc/rc3.d
3. Create the following symbolic links:
ln -s ../init.d/maxdb K05maxdb
ln -s ../init.d/maxdb S18maxdb
#! /bin/sh
# Copyright (c) 2001-2004 SAP AG, Germany.
#
# Author: <maxdb@lists.mysql.com>
#
# init.d/maxdb
#
# and symbolic its link
#
#
### BEGIN INIT INFO
# Provides: MaxDB
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Description: Start MaxDB communication server.
### END INIT INFO
if [ -f /etc/rc.config ]; then
. /etc/rc.config
fi
# where to find x_server executable
IND_PROG_DBROOT=""
if [ -f /etc/opt/sdb ]; then
IND_PROG_DBROOT=`grep '^IndepPrograms=' /etc/opt/sdb | sed 's:IndepPrograms=::g'`
else
exit 5
fi
X_SERVER=$IND_PROG_DBROOT/bin/x_server
X_PATH=$IND_PROG_DBROOT/bin
MaxDB_BIN=$X_SERVER
test -x $MaxDB_BIN || exit 5
MaxDB_BIN=$X_PATH/dbmcli
test -x $MaxDB_BIN || exit 5
# find program fuser
FUSER=/bin/fuser
test -x $FUSER || FUSER=/sbin/fuser
test -x $FUSER || FUSER=/usr/sbin/fuser
# Shell functions sourced from /etc/rc.status:
# rc_check check and set local and overall rc status
# rc_status check and set local and overall rc status
# rc_status -v ditto but be verbose in local rc status
# rc_status -v -r ditto and clear the local rc status
# rc_failed set local and overall rc status to failed
# rc_reset clear local rc status (overall remains)
# rc_exit exit appropriate to overall rc status
#. /etc/rc.status
# First reset status of this service
#rc_reset
# Return values acc. to LSB for all commands but status:
# 0 - success
# 1 - misc error
# 2 - invalid or excess args
# 3 - unimplemented feature (e.g. reload)
# 4 - insufficient privilege
# 5 - program not installed
# 6 - program not configured
# 7 - program is not running
#
# Note that starting an already running service, stopping
# or restarting a not-running service as well as the restart
# with force-reload (in case signalling is not supported) are
# considered a success.
RETVAL=1
case "$1" in
start)
echo -n "Starting MaxDB services: "
if [ ! -z "$X_SERVER" ]; then
$X_SERVER start>/dev/null 2>&1
# to enable auto start/stop demodb remove following comments
DBMCLI=$X_PATH/dbmcli
if [ ! -x $DBMCLI ]; then
echo "dbmcli not found" >&2
exit 5
fi
$DBMCLI -d DEMODB << __EOD__ 2>&1 > /dev/null
user_logon OLEG,MONDAY
db_online
__EOD__
_test=`echo $_o | grep ERR`
if [ "$_test" = "" ]; then
echo -n " database DEMODB started"
else
echo "cannot start DEMODB: $_o" >&2
exit 7
fi
RETVAL=0
fi
touch /var/lock/subsys/maxdb
;;
stop)
echo -n "Shutting down MaxDB services: "
if [ ! -z "$X_SERVER" ]; then
# to enable auto start/stop demodb remove following comments
DBMCLI=$X_PATH/dbmcli
if [ ! -x $DBMCLI ]; then
echo "dbmcli not found" >&2
exit 5
fi
_o=`$DBMCLI -d DEMODB << __EOD__ 2>&1
user_logon OLEG,MONDAY
db_offline
__EOD__`
_test=`echo $_o | grep ERR`
if [ "$_test" = "" ]; then
echo -n "database DEMODB stopped"
else
echo "cannot stop DEMODB: $_o" >&2
exit 1
fi
$X_SERVER stop > /dev/null 2>&1
RETVAL=0
fi
rm -f /var/lock/subsys/maxdb
;;
status)
if [ ! -z "$X_PATH" ]; then
if [ -x $FUSER ]; then
_o=`$FUSER $IND_PROG_DBROOT/pgm/vserver`
if [ $? -eq 0 ]; then
echo "communication server is running"
# to enable auto start/stop demodb remove following comments
DBMCLI=$X_PATH/dbmcli
if [ ! -x $DBMCLI ]; then
echo "dbmcli not found" >&2
exit 5
fi
_o=`$DBMCLI -d DEMODB << __EOD__
user_logon OLEG,MONDAY
db_state
__EOD__`
_test=`echo $_o | grep ERR`
if [ "$_test" = "" ]; then
_state=`echo $_o | sed s/.*State\ *// | sed s/\ .*//`
echo "database DEMODB is $_state"
else
echo "cannot get state of DEMODB: $_o" >&2
fi
RETVAL=0
else
echo "communication server is not running"
RETVAL=0
fi
else
echo "status unkown - fuser not found" >&2
fi
else
echo "status unkown - x_server not found" >&2
fi
;;
restart)
$0 stop
$0 start
;;
reload)
$0 stop
$0 start
;;
*)
echo "Usage: maxdb {start|stop|status|reload|restart}"
exit 1
;;
esac
exit $RETVAL
See also: