FAQ
HP-UX에서 자동적으로 Reboot시 알티베이스를 Startup하는 방법 | |||||
분류 | 운영/관리 | 등록일 | 2013-07-09 | 조회수 | 5293 |
hwon 2004-02-24 95 HP-UX에서 자동적으로 Reboot시 알티베이스를 Startup하는 방법 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 요약 ++++ HP-UX가Booting되면서 자동적으로 알티베이스를 Startup하기 위해서 Startup Shell에 Setting하여야 할 부분들에 대한 문서입니다. HP-UX Startup Script ++++++++++++++++++++ HP-UX가 Reboot되면서 수행하는 rc script들은 /sbin/rc 다. 그런데 일반적으로 이 위치에 있는 File들은 /sbin/init.d에 존재하는 file에 대한 link일 뿐입니다. 이렇게 관리하는 이유는 시스템이 Startup할 때 수행하는 Startup Script 와 System이 Shutdown될 때 수행되는 Shutdown Script가 하나의 file로 되어 있고 이것을 두 개의 이름으로 Symbolic Link를 만들어서 시스템에서는 Startup, Shutdown시 이용하기 때문입니다. RC Script의 수행을 쉽게 Control하기 위하여 일반적으로 하나의 rc Script당 하나의 환경 변수 file을 가져갑니다. 이 File이 존재하는 위치는 /etc/rc.config.d로서 rc script에 서 사용하는 변수들의 정의와 값을 Setting할 수 있습니다. 그래서 자동 구동 여부를 조절 하고자 할 때에는 rc script를 수정하는 것이 아니라 이 환경변수 File을 Editing하여서 쉽 게 Control할 수 있습니다. STEP1 +++++ /etc/rc.config.d/alti_conf file을 만들어야 합니다. 위에서 설명했듯이 이 file에서는 자동 구동시 필요한 변수들을 정의하고 Setting합니다. 이 file의 내용은 아래와 같습니다. ################################################################# ALTIBASE_HOME=/user5/hwon/work/altidev/altibase_home ;export ALTIBASE_HOME PATH=$ALTIBASE_HOME/bin:/usr/bin:/sbin ; export PATH ALTIBASE_OWNER=hwon START_ALTIBASE=1 ################################################################# 만약 자동 구동을 하고 싶지 않다면 START_ALTIBASE의 값을 0으로 맞추면 됩니다. 그리고 ALTIBASE_OWNER나 ALTIBASE_HOME이 변경되었을 경우에는 반드시 이 File에 있는 값을 수정 해 주어야 합니다. STEP2 +++++ /sbin/init.d/alti_start file을 만든다. 이 script에서는 알티베이스 구동 명령어를 이용해서 실제로 DBMS를 startup하는 script입 니다. ################################################################# #!/sbin/sh if [ -f /etc/rc.config.d/altibase_conf ] ; then . /etc/rc.config.d/altibase_conf fi dbadmin < startup quit EOF ################################################################# STEP3 +++++ /sbin/init.d/alti_stop file을 만든다. 이 script에서는 알티베이스 구동 명령어를 이용해서 실제로 DBMS를 stop하는 script입니 다. ################################################################# #!/sbin/sh if [ -f /etc/rc.config.d/altibase_conf ] ; then . /etc/rc.config.d/altibase_conf fi dbadmin < startup quit EOF ################################################################# STEP4 +++++ /sbin/init.d/altibase file을 만든다. 이 file은 /sbin/init.d/template file을 복사해서 만들면 되는데 실제로 나중에 startup script나 stop script가 symbolic link를 만들 file이다. 이 file의 내용은 아래와 같다. ################################################################# #!/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 exit $rval ################################################################# STEP5 +++++ /sbin/rc2.d Directory에서 Startup Script와 Shutdown Script의 Symbolic Link를 만든다. #cd /sbin/rc2.d # ln -s /sbin/init.d/altibase S955altibase # ln -s /sbin/init.d/altibase K955altibase STEP6 +++++ 각각의 Script가 정상적으로 수행될 수 있도록 수행 권한을 Setting한다. #cd /sbin/rc2.d # chmod 755 S955altibase # chmod 755 K955altibase #cd /sbin/rc2.d # chmod 755 S955altibase # chmod 755 K955altibase #cd /sbin/init.d # chmod 755 *alti* STEP7 +++++ 정상적으로 동작하는 지 Test를 해본다. 이 때 Test는 root계정에서 수행해 보아야 한다. # su ? root # /sbin/init.d/altibase |