Posted by 후니아부지
:

root 계정으로 아래 스크립트를 생성한다. 

# gedit /etc/init.d/oracle


다음 내용을 써준다.

#!/bin/bash
#chkconfig: 2345 95 20
#description: oracle service
#processname: oracle

# /etc/init.d/oracle
#
# Run-level Startup script for the Oracle Listener and Instances
# It relies on the information on /etc/oratab

export ORACLE_BASE=/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11g
export ORACLE_OWNR=oracle
export PATH=$PATH:$ORACLE_HOME/bin

if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]
then
    echo "Oracle startup: cannot start"
    exit 1
fi

case "$1" in
    start)
        # Oracle listener and instance startup
        echo -n "Starting Oracle: "
        su $ORACLE_OWNR -c "$ORACLE_HOME/bin/lsnrctl start"
        su $ORACLE_OWNR -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
        sudo touch /var/lock/oracle
        echo "OK"
        ;;
        
    stop)
        # Oracle listener and instance shutdown
        echo -n "Shutdown Oracle: "
        su $ORACLE_OWNR -c "$ORACLE_HOME/bin/lsnrctl stop"
        su $ORACLE_OWNR -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME"
        sudo rm -f /var/lock/oracle
        echo "OK"
        ;;
        
    reload|restart)
        $0 stop
        $0 start
        ;;
        
    *)
        echo "Usage: `basename $0` start|stop|restart|reload"
        exit 1
esac

exit 0

생성한 파일을 실행할 수 있도록 변경한다.

# chmod 750 /etc/init.d/oracle


서비스를 등록한다.

※ chkconfig --add [서비스이름] --level 0356

# chkconfig --add oracle --level 0356



리부팅 후 자동으로 시작된다.


Posted by 후니아부지
: