วันพุธที่ 11 ธันวาคม พ.ศ. 2556

autostart oracle database/listener/em on centos 6.5

login เป็น root, 
สร้างไฟล์ /etc/init.d/oracle :
ก๊อปปี้ส่วนนี้ลงไป
-------------------------------------------------------------------------------------------------------------------------

#!/bin/bash


# oracle: Start/Stop Oracle Database 11g R2
#
# chkconfig: 345 90 10
# description: Oracle 11g R2
#
# processname: oracle

. /etc/rc.d/init.d/functions

LOCKFILE=/var/lock/subsys/oracle
ORACLE_HOME=/opt/app/oracle/product/11.2.0/db_1/
ORACLE_USER=oracle

case "$1" in
'start')
   if [ -f $LOCKFILE ]; then
      echo $0 already running.
      exit 1
   fi
   echo -n $"Starting Oracle Database:"
   su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl start"
   su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
   su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl start dbconsole"
   touch $LOCKFILE
   ;;
'stop')
   if [ ! -f $LOCKFILE ]; then
      echo $0 already stopping.
      exit 1
   fi
   echo -n $"Stopping Oracle Database:"
   su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl stop"
   su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME"
   su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl stop dbconsole"
   rm -f $LOCKFILE
   ;;
'restart')
   $0 stop
   $0 start
   ;;
'status')
   if [ -f $LOCKFILE ]; then
      echo $0 started.
      else
      echo $0 stopped.
   fi
   ;;
*)
   echo "Usage: $0 [start|stop|status]"
   exit 1
esac


exit 0
---------------------------------------------------------------------------------------------------------------------------------

Make it executable:
chmod +x /etc/init.d/oracle


Test:
/etc/init.d/oracle start
/etc/init.d/oracle stop


Make it active:
chkconfig --add oracle
chkconfig oracle on


Verify:

chkconfig --list oracle

อ้างอิง : http://janhellevik.com/?p=923