개요
HP-UX에서 부팅 시 알티베이스를 자동으로 구동시키기 위한 방법에 대해 설명합니다.
HP-UX Startup Script란?
HP-UX에서는 시스템 부팅/종료 시 수행되는 스크립트 파일들을 다음과 같이 관리합니다.
- 부팅 시 수행하는 실제 스크립트 파일들은 /sbin/init.d 디렉토리에 존재합니다.
- 위 스크립트 파일들을 위한 설정파일들은 /etc/rc.config.d 디렉토리에 존재합니다. 하나의 rc script 마다 하나의 설정파일을 가지며 스크립트 수행에 필요한 변수들의 정의와 값을 설정합니다.
- 부팅 시 수행하는 스크립트 파일들은 /sbin/rc*.d 디렉토리에 존재하며 이 파일들은 /sbin/init.d 디렉토리에 존재하는 파일들의 심볼릭 링크입니다.
알티베이스 자동 구동/종료를 위한 스크립트 작성 방법
STEP 1
/etc/rc.config.d/altibase_conf 파일을 만듭니다.
위에서 설명했듯이 이 파일에 알티베이스의 구동/종료 시 필요한 변수들을 정의하고 값을 설정합니다.
이 파일의 내용은 아래와 같습니다.
ALTIBASE_HOME=/altibase/altibase_home; export ALTIBASE_HOME
PATH=$ALTIBASE_HOME/bin:/usr/bin:/sbin; export PATH
ALTIBASE_OWNER=altibase
START_ALTIBASE=1만약 HP-UX 부팅 시 알티베이스의 자동 구동을 하고 싶지 않다면 START_ALTIBASE의 값을 0으로 설정합니다. 그리고 ALTIBASE_OWNER나 ALTIBASE_HOME이 변경되었을 경우에는 반드시 altibase_conf 파일도 수정해야 합니다.
STEP 2
/sbin/init.d/alti_start 파일을 만듭니다.
이 파일은 알티베이스 구동 명령어를 이용하여 실제로 알티베이스를 구동하는 스크립트입니다.
#!/sbin/sh
if [ -f /etc/rc.config.d/altibase_conf ] ; then
. /etc/rc.config.d/altibase_conf
fi
ADMIN="${ALTIBASE_HOME}/bin/isql -u sys -p manager -sysdba -noprompt"
${ADMIN} << EOF
startup
quit
EOF
STEP 3
/sbin/init.d/alti_stop 파일을 만듭니다.
이 파일은 알티베이스 종료 명령어를 이용하여 실제로 알티베이스를 종료하는 스크립트입니다.
#!/sbin/sh
if [ -f /etc/rc.config.d/altibase_conf ] ; then
. /etc/rc.config.d/altibase_conf
fi
ADMIN="${ALTIBASE_HOME}/bin/isql -u sys -p manager -sysdba -noprompt"
FUNC_CHECK_ISQL_CONN()
{
case $ISQL_CONNECTION in
[Ii][Pp][Cc])
unset ISQL_CONNECTION
;;
*)
;;
esac
}
# Permit sysdba via IPC
FUNC_CHECK_ISQL_CONN
${ADMIN} << EOF > /dev/null
ALTER SYSTEM SET CHECKPOINT_BULK_WRITE_PAGE_COUNT = 0;
ALTER SYSTEM SET CHECKPOINT_BULK_WRITE_SLEEP_SEC = 0;
ALTER SYSTEM SET CHECKPOINT_BULK_WRITE_SLEEP_USEC = 0;
quit;
EOF
killCheckServer > ${ALTIBASE_HOME}/trc/killCheckServer.log 2>&1
${ADMIN} << EOF
shutdown immediate;
quit;
EOF
STEP 4
/sbin/init.d/altibase 파일을 만듭니다.
이 파일은 /sbin/init.d/template 파일을 복사해서 만들면 되는데, 실제로 나중에 Start/Stop script가 Symbolic Link를 만들 파일입니다.
#!/sbin/sh
#
# @(#)B.11.11_LR
#
# NOTE: This script is not configurable! Any changes made to this
# script will be overwritten when you upgrade to the next
# release of HP-UX.
#
# WARNING: Changing this script in any way may lead to a system that
# is unbootable. Do not modify this script.
#
rval=0
# Check the exit value of a command run by this script. If non-zero, the
# exit code is echoed to the log file and the return value of this script
# is set to indicate failure.
set_return() {
x=$?
if [ $x -ne 0 ]; then
echo "EXIT CODE: $x"
rval=1 # script FAILed
fi
}
# Kill the named process(es).
# $1=
killproc() {
pid=`ps -el | awk '( ($NF ~ /'"$1"'/) && ($4 != mypid) && ($5 != mypid) )
{ print $4 }' mypid=$$ `
if [ "X$pid" != "X" ]; then
if kill "$pid"; then
echo "$1 stopped"
else
rval=1
echo "Unable to stop $1"
fi
fi
}
case $1 in
'start_msg')
# Emit a _short_ message relating to running this script with
# the "start" argument; this message appears as part of the checklist.
echo "Starting the Altibase Database"
;;
'stop_msg')
# Emit a _short_ message relating to running this script with
# the "stop" argument; this message appears as part of the checklist.
echo "Stopping the Altibase Database"
;;
'start')
# source the system configuration variables
if [ -f /etc/rc.config.d/altibase_conf ] ; then
. /etc/rc.config.d/altibase_conf
else
echo "ERROR: /etc/rc.config defaults file MISSING"
fi
# Check to see if this script is allowed to run...
if [ "$START_ALTIBASE" != 1 ]; then
rval=2
else
# Execute the commands to start your subsystem
su - $ALTIBASE_OWNER -c "/sbin/init.d/alti_start"
fi
;;
'stop')
# source the system configuration variables
if [ -f /etc/rc.config.d/altibase_conf ] ; then
. /etc/rc.config.d/altibase_conf
else
echo "ERROR: /etc/rc.config defaults file MISSING"
fi
# Check to see if this script is allowed to run...
if [ "$START_ALTIBASE" != 1 ]; then
rval=2
else
su - $ALTIBASE_OWNER -c "/sbin/init.d/alti_stop"
# Execute the commands to stop your subsystem
fi
;;
*)
echo "usage: $0 {start|stop|start_msg|stop_msg}"
rval=1
;;
esac
STEP 5
/sbin/rc2.d 디렉토리에서 Startup Script와 Shutdown Script의 Symbolic Link를 만듭니다.
# cd /sbin/rc2.d
# ln -s /sbin/init.d/altibase S955altibase
# ln -s /sbin/init.d/altibase K955altibase
STEP 6
각각의 스크립트가 정상적으로 수행될 수 있도록 실행 권한을 수정합니다.
# cd /sbin/rc2.d
# chmod 755 S955altibase
# chmod 755 K955altibase
# cd /sbin/init.d
# chmod 755 *alti*
STEP 7
정상적으로 동작하는지 테스트해 봅니다. 이 때 테스트는 root 계정에서 수행해야 합니다.
# su - root
# /sbin/init.d/altibase