Automating Standalone Database Startup and Shutdown

Automating Standalone Database Startup and Shutdown
Advertisement
1. Change the last field for the database line to Y

BASHvi /etc/oratab

orcl:/u01/app/oracle/product/19.3.0.0/dbhome_1:Y

2. Create the file /etc/init.d/dbora and add the following code in it

BASHvi /etc/init.d/dbora

#! /bin/sh
# description: Oracle auto start-stop script.
ORA_HOME=/u01/app/oracle/product/19.3.0.0/dbhome_1
ORA_OWNER=oracle
case "$1" in
'start')
# Start the Oracle databases:
# Remove "&" if you don't want startup as a background process.
su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart $ORA_HOME" &
touch /var/lock/subsys/dbora
;;
'stop')
# Stop the Oracle databases:
su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut $ORA_HOME" &
rm -f /var/lock/subsys/dbora
;;
esac

3. Change the group of the dbora file to dba, and set its permissions to 750
BASHchgrp dba /etc/init.d/dbora
chmod 750 /etc/init.d/dbora
4. Create symbolic links to the dbora script in the appropriate run-level script directories
BASHln -s /etc/init.d/dbora /etc/rc.d/rc0.d/K01dbora
ln -s /etc/init.d/dbora /etc/rc.d/rc3.d/S99dbora
ln -s /etc/init.d/dbora /etc/rc.d/rc5.d/S99dbora
5. Restart srv1 and wait for a few minutes to allow the database to automatically start up.
BASHps -ef | grep pmon
sqlplus / as sysdba
That’s it.

INFO

If you would have any questions or concerns, please leave your comments. I would be glad to explain in more details. Thank you so much for all your feedback and support!

Share this article:
Advertisement

Comments (0)

No comments yet. Be the first to share your thoughts!