Auto restart Oracle and related service via dbstart

For  Oracle Grid or ASM environment , the Oracle restart is being used to start the Oracle after the OS startup. However, the Oracle instance does not use the Oracle RAC and ASM, we still need to use dbstart/dbshut to start the oracle.

dbstart and dbshut


Edit the /etc/oratab file

The file contains the Oracle SID and the oracle home directory. The last parameter decide whether dbstart would bring it up or not.
SID: ORACLE_HOME: Y/N
image
After the ORALCE_SID is set to Y, we can use dbstart to bring up the oracle instance.

Known issue with ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener

There is known issue with the dbstart. We would get the error message about “ORACLE_HOME_LISTNER is not SET, unable to auto-stop Oracle Net Listener”. The database would startup fine but the listener does not start.
image
To fix the error, we need to pass the $ORACLE_HOME to the dbstart ..
image
However, this would only bring up the default listener. I can not find anyway to bring up the named listener via dbstart. I have to create the customize script in the init.d to do this.

Create /etc/init.d/oracle

#!/bin/sh
# chkconfig: 345 99 10
 
ORA_OWNER=oracle
ORACLE_HOME=/u01/app/oracle/product/11.2.0
 
case "$1" in
    'start')
        su - $ORA_OWNER -c "$ORACLE_HOME/bin/lsnrctl start LISTENER_ORACLEDB1" 
        su - $ORA_OWNER -c "$ORACLE_HOME/bin/dbstart" 
        su - $ORA_OWNER -c "$ORACLE_HOME/bin/emctl start dbconsole" 
    ;;
    'stop')
        su - $ORA_OWNER -c "$ORACLE_HOME/bin/lsnrctl stop LISTENER_ORACLEDB1" 
        su - $ORA_OWNER -c "$ORACLE_HOME/bin/emctl stop dbconsole" 
        su - $ORA_OWNER -c "$ORACLE_HOME/bin/dbshut" 
    ;;
esac

In order for chkconfig to recognize the script, we need to have “# chkconfig: 345 99 10
chmod 750 oracle
chkconfig --add oracle
chkconfig --list oracle
image
To test the init.d script, we can use service command
service oracle start
service oracle stop

Source

Posting Komentar