コンテンツエリア開始

This graphic is explained in the accompanying text : データベースインスタンスの起動スクリプト (Linux) Locate the document in its SAP Library structure

用途

maxdb 起動スクリプトを使用すると、データベースインスタンス DEMODB の操作状態は、コンピュータが起動すると自動的に ONLINE に切り替わり、コンピュータの電源を切ると自動的に OFFLINE に切り替わります。

使用しているオペレーティングシステムによっては、maxdb 起動スクリプトの変更が必要となる場合があります。

前提条件

      データベースインスタンス DEMODB、および DBM オペレータ OLEG とパスワード MONDAY が登録されている必要があります。

      root シェルを開いていることが必要です。

手順

...

        1.      maxdb 起動スクリプトをディレクトリ /etc/init.d に保存します。

       2.      ディレクトリ /etc/rc3.d に移動します。

       3.      以下のシンボリックリンクを登録します。

ln -s ../init.d/maxdb K05maxdb

ln -s ../init.d/maxdb S18maxdb

maxdb 起動スクリプト

#! /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

 

参照:

自動起動

 

 

コンテンツエリア終了