To make the database and listeners start up automatically when the server reboots and shut down automatically when the server shuts down, you’ll need to create a dbora file in /etc/init.d and link it to /etc/rc2.d and /etc/rc0.d. You’ll need to do this as the root user. First create a file called dbora in /etc/init.d as follows as root:
vi /etc/init.d/dbora
#!/bin/sh
# description: Starts and stops Oracle processes
#
ORA_BASE=/u01/app/oracle
ORA_HOME=/u01/app/oracle/ OraHome_1
ORA_OWNER=oracle
if [ ! -f $ORA_HOME/bin/dbstart ]
then
echo "Oracle startup: cannot start"
exit
fi
case "$1" in
'start')
# Start the Oracle database, listener and Web Control
su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart"
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start"
su - $ORA_OWNER -c "$ORA_HOME/bin/emctl start dbconsole"
;;
'stop')
# Stop the Oracle database, listener and Web Control
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop"
su - $ORA_OWNER -c "$ORA_HOME/bin/emctl stop dbconsole"
su - $ORA_OWNER -c $ORA_HOME/bin/dbshut
;;
esac
Link the script:
ln -s /etc/init.d/dbora /etc/rc2.d/S99dbora
ln -s /etc/init.d/dbora /etc/rc0.d/K10dbora
Test the script created. To test the script created above, without rebooting do the following:
su - root
/etc/init.d/dbora start (for startup)
/etc/init.d/dbora stop (for shutdown)
vi /etc/init.d/dbora
#!/bin/sh
# description: Starts and stops Oracle processes
#
ORA_BASE=/u01/app/oracle
ORA_HOME=/u01/app/oracle/
ORA_OWNER=oracle
if [ ! -f $ORA_HOME/bin/dbstart ]
then
echo "Oracle startup: cannot start"
exit
fi
case "$1" in
'start')
# Start the Oracle database, listener and Web Control
su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart"
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start"
su - $ORA_OWNER -c "$ORA_HOME/bin/emctl start dbconsole"
;;
'stop')
# Stop the Oracle database, listener and Web Control
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop"
su - $ORA_OWNER -c "$ORA_HOME/bin/emctl stop dbconsole"
su - $ORA_OWNER -c $ORA_HOME/bin/dbshut
;;
esac
Link the script:
ln -s /etc/init.d/dbora /etc/rc2.d/S99dbora
ln -s /etc/init.d/dbora /etc/rc0.d/K10dbora
Test the script created. To test the script created above, without rebooting do the following:
su - root
/etc/init.d/dbora start (for startup)
/etc/init.d/dbora stop (for shutdown)
No comments:
Post a Comment