HP StorageWorks Storage Mirroring application notes Guidelines for using Oracle 10g with Storage Mirroring Linux (T2558-96087, February 2008)

8
############***** BEGINING OF INIT.D SCRIPT FOR ORACLE SERVICE ***** #############
#!/bin/bash
ORACLE_USER="oracle"
##### Path of installed oracle home directory in the server. #####
ORACLE_HOME="/u01/app/oracle/product/10.2.1/db_1/"
##### Set user name. #####
SYS_USER="sys"
##### Set password of the username. ######
SYS_PASS="password"
case "$1" in
start)
echo "*** Starting Oracle *** "
su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl start"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/ora_start"
###### here "ora_start" is a shell script created inside $ORACLE_HOME/bin directory. This script contains
###### the following sqlplus command :--
###### ----> $sqlplus "sys/password as sysdba" @/home/oracle/start.sql
###### Again /home/oracle/start.sql is the path of a sql script "start.sql" used for starting the database.
###### Following are the contents of sql script.
###### ----> startup ; exit ;
;;
stop)
echo "*** Stopping Oracle *** "
su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl stop"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/ora_shut"
###### here "ora_shut" is a shell script created inside $ORACLE_HOME/bin directory. This script contains
###### the following sqlplus command :--
###### ----> $sqlplus "sys/password as sysdba" @/home/oracle/shut.sql
###### Again /home/oracle/shut.sql is the path of a sql script "shut.sql" used for shutting down the
###### database. Following are the contents of sql script..
###### ----> shutdown immediate ; exit ;
;;
isqlstart)
echo "***** Starting Oracle iSQL Plus ****"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/isqlplusctl start"
echo "***** Note : You can access service at url: http://$(hostname):5560/isqlplus"
;;
isqlstop)
echo "***** Stopping Oracle iSQL Plus ****"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/isqlplusctl stop"
;;
emstart)
echo "***** Starting Oracle Enterprise Manager 10g Database Control ****"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl start dbconsole"
echo "***** Note : You can access service at url: http://$(hostname):1158/em"
;;
emstop)
echo "***** Stopping Oracle Enterprise Manager 10g Database Control ****"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl stop dbconsole"
;;
*)
echo $"Usage : $0 {start|stop|isqlstart|isqlstop|emstart|emstop}"
exit 1
esac
exit 0
############# ***** END OF INIT.D SCRIPT FOR ORACLE SERVICE ***** #############
*********************************************************************************************************
NOTE :--- Copy this script to the /etc/init.d/ directory of the linux server, and name it as "oracle".
Create a soft link (Run level 3)
$ cd /etc/rc.d/rc3.d/
$ ln -s /etc/init.d/oracle S100oracle
$ ln -s /etc/init.d/oracle K100oracle
Alternatively use chkconfig command to add script:
$ chkconfig --add oracle
$ chkconfig --list oracle
Please note that you can just use script directly, To start Oracle type command:
$ /etc/init.d/oracle start
To stop Oracle type command:
$ /etc/init.d/oracle stop
*********************************************************************************************************
NOTE ---> Create the following scripts at the directories as mentioned in the INIT.D script, if you are using
this script for oracle service.
ora_start ---> $ORACLE_HOME/bin/
ora_shut ---> $ORACLE_HOME/bin/
start.sql ---> /home/oracle/
shut.sql ---> /home/oracle/
**********************************************************************************************************