Saturday, November 1, 2008

Automatic startup and shutdown Oracle R12 on Linux

After installation on Linux, when the server restarted, the application will not started automatically. To start the application automaticaly, we need to create some scripts. I use Vision Demo Instance as example.
First one is to start the database. Using oracle user, create a file containing this script:
#! /bin/sh
source /oracle/VIS/db/tech_st/10.2.0/VIS_oracle.env
/oracle/VIS/db/tech_st/10.2.0/appsutil/scripts/VIS_oracle/addbctl.sh start
/oracle/VIS/db/tech_st/10.2.0/appsutil/scripts/VIS_oracle/addlnctl.sh start VIS
Then save it as startDB.sh.
I also want to create script to stop the database using this script:
#! /bin/sh
source /oracle/VIS/db/tech_st/10.2.0/VIS_oracle.env
/oracle/VIS/db/tech_st/10.2.0/appsutil/scripts/VIS_oracle/addbctl.sh stop
/oracle/VIS/db/tech_st/10.2.0/appsutil/scripts/VIS_oracle/addlnctl.sh stop VIS
Then save it as stopDB.sh

As applmgr user, create scripts to start and stop applications. To start application use this script:
#! /bin/sh
source /oracle/VIS/apps/apps_st/appl/VIS_oracle.env
$ADMIN_SCRIPTS_HOME/adstrtal.sh apps/apps
Then save it as startApps.sh
To stop application, use this script:
#! /bin/sh
source /oracle/VIS/apps/apps_st/appl/VIS_oracle.env
$ADMIN_SCRIPTS_HOME/adstpall.sh apps/apps

As root, create a file on /etc/init.d named startVIS containing this script:
#! /bin/sh
#
# /etc/init.d/R12_VIS
#

### BEGIN INIT INFO
# Provides: Oracle Applications
# Required-Start: $syslog $network $xvfbserver
# Required-Stop:
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Description: Start the Oracle Applications server
### END INIT INFO

case "$1" in
start)
su oracle -c "/home/oracle/dbVIS.sh"
su applmgr -c "/home/applmgr/applVIS.sh"
#rc_status -v
;;
stop)
su applmgr -c "/home/applmgr/stopapplVIS.sh"
su oracle -c "/home/oracle/stopdbVIS.sh"
#rc_status -v
;;

*)
echo "Usage: $0 {start|stop}"
exit 1
;;
esac

The last step is to add startVIS to the services list. Use this command as root:
chkconfig --add startVIS