This is for the Grid Control server.
#!/bin/sh
#for whatever reason, /bin/bash does not work, it does not even create the log file while server reboot
# https://gruffdba.wordpress.com/2013/02/09/installing-oracle-enterprise-manager-12c-12-1-0-2-on-centos-6-3-on-vmware-workstation-8/#more-584
# Created on Oct 7th, 2016 by Jiulu Sun
# This script is used on Oracle Grid Control OMS Server, it will start/stop oracle database, listener, OMS and agent when the box is reboot.
# !!! I have to modify first line of $ORACLE_HOME/bin/dbstart and dbshut script to use ksh rather than sh, otherwise it run into error 'invalid identifier' using sh
ORA_OWNER=orabcf
#export ORAENV_ASK=NO
#export ORACLE_SID=oem11g
#. oraenv
#export ORACLE_HOME=/u01/oracle/oem11g/product/11.2.0
#export OMS_HOME=/u01/oracle/grc/middleware/oms11g
#export AGENT_HOME=/u01/oracle/grc/middleware/agent11g
case "$1" in
start)
echo "start">/u01/orabcf/dbstartup.log
date>> /u01/orabcf/dbstartup.log
su - $ORA_OWNER -c 'export ORACLE_SID=oem11g; export ORAENV_ASK=NO; . oraenv; $ORACLE_HOME/bin/lsnrctl start' >> /u01/orabcf/dbstartup.log
su - $ORA_OWNER -c 'export ORACLE_SID=oem11g; export ORAENV_ASK=NO; . oraenv; $ORACLE_HOME/bin/dbstart $ORACLE_HOME' >> /u01/orabcf/dbstartup.log
su - $ORA_OWNER -c 'export ORACLE_SID=oms11g; export ORAENV_ASK=NO; . oraenv; $ORACLE_HOME/bin/emctl start oms' >> /u01/orabcf/dbstartup.log
su - $ORA_OWNER -c 'export ORACLE_SID=agent11g; export ORAENV_ASK=NO; . oraenv; $ORACLE_HOME/bin/emctl start agent' >> /u01/orabcf/dbstartup.log
;;
stop)
echo "stop">/u01/orabcf/dbshut.log
date>> /u01/orabcf/dbshut.log
# Stop everything
su - $ORA_OWNER -c 'export ORACLE_SID=oms11g; export ORAENV_ASK=NO; . oraenv; $ORACLE_HOME/bin/emctl stop oms -all' >>/u01/orabcf/dbshut.log
su - $ORA_OWNER -c 'export ORACLE_SID=agent11g; export ORAENV_ASK=NO; . oraenv; $ORACLE_HOME/bin/emctl stop agent' >> /u01/orabcf/dbshut.log
su - $ORA_OWNER -c 'export ORACLE_SID=oem11g; export ORAENV_ASK=NO; . oraenv; $ORACLE_HOME/bin/lsnrctl stop' >> /u01/orabcf/dbshut.log
su - $ORA_OWNER -c 'export ORACLE_SID=oem11g; export ORAENV_ASK=NO; . oraenv; $ORACLE_HOME/bin/dbshut $ORACLE_HOME' >> /u01/orabcf/dbshut.log
;;
*)
date>>/u01/orabcf/start.log
exit 1
;;
esac
exit 0
#!/bin/sh
#for whatever reason, /bin/bash does not work, it does not even create the log file while server reboot
# https://gruffdba.wordpress.com/2013/02/09/installing-oracle-enterprise-manager-12c-12-1-0-2-on-centos-6-3-on-vmware-workstation-8/#more-584
# Created on Oct 7th, 2016 by Jiulu Sun
# This script is used on Oracle Grid Control OMS Server, it will start/stop oracle database, listener, OMS and agent when the box is reboot.
# !!! I have to modify first line of $ORACLE_HOME/bin/dbstart and dbshut script to use ksh rather than sh, otherwise it run into error 'invalid identifier' using sh
ORA_OWNER=orabcf
#export ORAENV_ASK=NO
#export ORACLE_SID=oem11g
#. oraenv
#export ORACLE_HOME=/u01/oracle/oem11g/product/11.2.0
#export OMS_HOME=/u01/oracle/grc/middleware/oms11g
#export AGENT_HOME=/u01/oracle/grc/middleware/agent11g
case "$1" in
start)
echo "start">/u01/orabcf/dbstartup.log
date>> /u01/orabcf/dbstartup.log
su - $ORA_OWNER -c 'export ORACLE_SID=oem11g; export ORAENV_ASK=NO; . oraenv; $ORACLE_HOME/bin/lsnrctl start' >> /u01/orabcf/dbstartup.log
su - $ORA_OWNER -c 'export ORACLE_SID=oem11g; export ORAENV_ASK=NO; . oraenv; $ORACLE_HOME/bin/dbstart $ORACLE_HOME' >> /u01/orabcf/dbstartup.log
su - $ORA_OWNER -c 'export ORACLE_SID=oms11g; export ORAENV_ASK=NO; . oraenv; $ORACLE_HOME/bin/emctl start oms' >> /u01/orabcf/dbstartup.log
su - $ORA_OWNER -c 'export ORACLE_SID=agent11g; export ORAENV_ASK=NO; . oraenv; $ORACLE_HOME/bin/emctl start agent' >> /u01/orabcf/dbstartup.log
;;
stop)
echo "stop">/u01/orabcf/dbshut.log
date>> /u01/orabcf/dbshut.log
# Stop everything
su - $ORA_OWNER -c 'export ORACLE_SID=oms11g; export ORAENV_ASK=NO; . oraenv; $ORACLE_HOME/bin/emctl stop oms -all' >>/u01/orabcf/dbshut.log
su - $ORA_OWNER -c 'export ORACLE_SID=agent11g; export ORAENV_ASK=NO; . oraenv; $ORACLE_HOME/bin/emctl stop agent' >> /u01/orabcf/dbshut.log
su - $ORA_OWNER -c 'export ORACLE_SID=oem11g; export ORAENV_ASK=NO; . oraenv; $ORACLE_HOME/bin/lsnrctl stop' >> /u01/orabcf/dbshut.log
su - $ORA_OWNER -c 'export ORACLE_SID=oem11g; export ORAENV_ASK=NO; . oraenv; $ORACLE_HOME/bin/dbshut $ORACLE_HOME' >> /u01/orabcf/dbshut.log
;;
*)
date>>/u01/orabcf/start.log
exit 1
;;
esac
exit 0
Comments
Post a Comment