Database

Automating Standalone Database Startup and Shutdown

Automating Database Startup and Shutdown

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

vi /etc/oratab

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

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

vi /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
BASH

3. Change the group of the dbora file to dba, and set its permissions to 750
chgrp dba /etc/init.d/dbora
chmod 750 /etc/init.d/dbora
BASH
4. Create symbolic links to the dbora script in the appropriate run-level script directories
ln -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
BASH
5. Restart srv1 and wait for a few minutes to allow the database to automatically start up.
ps -ef | grep pmon
sqlplus / as sysdba
BASH
That’s it.


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!

Frequently asked questions

Why must the /etc/oratab line end with Y?
dbstart and dbshut only start and stop databases whose oratab entry ends with Y. A database marked N is skipped.
Does dbstart also start the listener?
Yes. When the Oracle home is passed as an argument, as in dbstart $ORA_HOME, it also starts the listener in that home.
What do the S99dbora and K01dbora links do?
S99 links in rc3.d and rc5.d start the script late in the boot, after networking. The K01 link in rc0.d runs it early at shutdown, so the database is stopped cleanly before the server powers off.
Does this work on Oracle Linux 7 and 8?
These releases use systemd, which runs scripts in /etc/init.d through a compatibility layer. It works, but for new servers a systemd service unit is the recommended way to start the database at boot.
How do I check it worked?
After a reboot, run ps -ef | grep pmon to see the database background process, then connect with sqlplus / as sysdba.
Advertisement
Share:

Comments

0

No comments yet

Be the first to share your thoughts!