AUTMATION SCRIPT - DBSTRAT and STOP

Step1: create scripts

***********DBSTART SCRIPT********
[oracle@AVIATION ~]$ cat stratdb.sh
export  ORACLE_BASE=/d01/oracle
export ORACLE_HOME=/d01/oracle/product/11.2.0/dbhome_1
export ORACLE_SID=AVIATION
export PATH=$PATH:$ORACLE_HOME/bin
echo $ORACLE_SID
sqlplus '/as sysdba'<<!
startup
show parameter db_name
select open_mode from v\$database ;
exit


*********DBSTOPSCRIPT*********
[oracle@AVIATION ~]$ cat stopdb.sh
export  ORACLE_BASE=/d01/oracle
export ORACLE_HOME=/d01/oracle/product/11.2.0/dbhome_1
export ORACLE_SID=AVIATION
export PATH=$PATH:$ORACLE_HOME/bin
echo $ORACLE_SID
sqlplus 'sys/oracle as sysdba'<<eof
select name, open_mode from v\$database ;
show parameter db_name
shutdown immediate
exit
eof


Step2:create dbora script to

***************dbora-service-script*********
#!/bin/sh
# chkconfig: 345 99 10
# description: Oracle auto start-stop script.
#
# Set ORA_OWNER to the user id of the owner of the
# Oracle database software.

ORA_OWNER=oracle

case "$1" in
    'start')
        # Start the Oracle databases:
        # The following command assumes that the oracle login
        # will not prompt the user for any values
        # Remove "&" if you don't want startup as a background process.
        su $ORA_OWNER -c "/home/oracle/stratdb.sh >> /home/oracle/startup_shutdown.log 2>&1" &

        touch /var/lock/subsys/dbora
        ;;
    'stop')
        # Stop the Oracle databases:
        # The following command assumes that the oracle login
        # will not prompt the user for any values
        su $ORA_OWNER -c "/home/oracle/stopdb.sh >> /home/oracle/startup_shutdown.log 2>&1"
        rm -f /var/lock/subsys/dbora
        ;;
esac

**************



Step3:change entry in oratab
****

[oracle@AVIATION ~]$ cat /etc/oratab
logout
AVIATION:/d01/oracle/product/11.2.0/dbhome_1:Y
[root@AVIATION etc]#


Step4:Add linux service to dbora script:
*********
chmod 750 /etc/init.d/dbora

chkconfig --add dbora


Stpe5:which run level you need to use the script mentioning through chkconfig
*****************
chkconfig --level 356 dbora on
chkconfig --level 0124 dbora off



NOTE:inittab --have the runlevel details. (loc:/etc/inittab)
******************after adding dbora to init.d the below softlinks will be created automatically******
[root@AVIATION init.d]# pwd
/etc/rc.d/init.d
[root@AVIATION init.d]# cd ..
[root@AVIATION rc.d]# pwd
/etc/rc.d
[root@AVIATION rc.d]# ls -ltr
total 112
-rwxr-xr-x 1 root root   220 Jun  7  2011 rc.local
-rwxr-xr-x 1 root root  2255 Jun  7  2011 rc
-rwxr-xr-x 1 root root 26930 Jul 22  2011 rc.sysinit
drwxr-xr-x 2 root root  4096 Mar  2 13:47 init.d
drwxr-xr-x 2 root root  4096 Mar  2 14:33 rc6.d
drwxr-xr-x 2 root root  4096 Mar  2 14:33 rc5.d
drwxr-xr-x 2 root root  4096 Mar  2 14:33 rc3.d
drwxr-xr-x 2 root root  4096 Mar  2 14:34 rc4.d
drwxr-xr-x 2 root root  4096 Mar  2 14:34 rc2.d
drwxr-xr-x 2 root root  4096 Mar  2 14:34 rc1.d
drwxr-xr-x 2 root root  4096 Mar  2 14:34 rc0.d
[root@AVIATION rc.d]# cd rc4.d
[root@AVIATION rc4.d]# ls
lrwxrwxrwx 1 root root 15 Mar  2 14:34 K10dbora -> ../init.d/dbora
[root@AVIATION rc4.d]# pwd
/etc/rc.d/rc4.d







No comments: