Automating Database Startup and Shutdown on Linux
1 1)
Create a file called “/etc/init.d/dbora” as the root user, containing the following
# vi /etc/init.d/dbora
#!/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
su - $ORA_OWNER -c
"/home/oracle/scripts/startup.sh >>
/home/oracle/scripts/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/scripts/shutdown.sh >>
/home/oracle/scripts/startup_shutdown.log 2>&1"
rm -f /var/lock/subsys/dbora
;;
esac
2) chmod 750 /etc/init.d/dbora
3) # mkdir -p /home/oracle/scripts
4) # chown oracle.oinstall /home/oracle/scripts
5) Vi /home/oracle/scripts/startup.sh
#!/bin/bash
export ORACLE_SID=DB11G */database name/*
ORAENV_ASK=NO
. oraenv
ORAENV_ASK=YES
# Start Listener
lsnrctl start
# Start Database
sqlplus / as sysdba << EOF
STARTUP;
EXIT;
EOF
6)vi /home/oracle/scripts/shutdown.sh
#!/bin/bash
export ORACLE_SID=DB11G */database name /*
ORAENV_ASK=NO
. oraenv
ORAENV_ASK=YES
# Stop Database
sqlplus / as sysdba << EOF
SHUTDOWN IMMEDIATE;
EXIT;
EOF
# Stop Listener
lsnrctl stop
7)# chmod u+x /home/oracle/scripts/startup.sh
# chmod u+x /home/oracle/scripts/shutdown.sh
8)# chown oracle.oinstall /home/oracle/scripts/startup.sh
#chown oracle.oinstall /home/oracle/scripts/shutdown.sh
9) # service dbora start
10)# service dbora stop
No comments:
Post a Comment