Installing Trend Micro Deep Security solution in RHEL 8 with Oracle DB in Oracle linux 8.5, Part-3

Md. Mahim Bin Firoj
3 min readJan 23, 2024

How to Automate Startup and Shutdown Oracle 19c Standalone database in Oracle Linux 8.5

As you might guess that what is the motive of this blog. We often face the issue that after rebooting the oracle db, the port 1521 is not up and our db instance is also shutdown state. We need to manually up that by following the below commands:

lsnrctl start

sqlplus / as sysdba
SQL> startup

Only after that the database instance got up and everything starts working.

In todays blog post, we will show you how we can automate this process so that you don’t need to worry to start it manually. I will not explain each of the steps perform in this blog because that’s not the scope of it. Rather I am giving you the link that will be helpful for you if you want to understand what is actually happening in the background. This guy really explained well in this video.

https://www.youtube.com/watch?v=KALvm8ZMlhw&ab_channel=KawsarHamid

Step 1:

From oracle user, edit the /etc/oratab file using this command.

vim /etc/oratab

Now change the last letter from N to Y from the last line.

ORCLCDB:/opt/oracle/product/19c/dbhome_1:N

Now save the file using :wq in vim.

Now change the user from oracle to root.

Step 2:

Now create this file:

vim /etc/init.d/dbora

And paste the following script:

#!/bin/bash
# chkconfig: 35 99 10
# description: Starts and Stops Oracle and Listener processes
ORACLE_HOME=/opt/oracle/product/19c/dbhome_1
PATH=${PATH}:$ORACLE_HOME/bin
export ORACLE_HOME PATH
case "$1" in
'start')
echo -n $"Starting Oracle DB: "
su - oracle -c "$0RACLE_HOME/bin/lsnrctl start" &
su - oracle -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME" &
;;
'stop')
echo -n $ "Shutting down Oracle DB: "
su - oracle -c "$ORACLE_HOME/bin/lsnrctl stop" &
su - oracle -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME" &
;;
'restart')
echo -n $"Shutting down Oracle DB: "
su - oracle -c "$ORACLEHOME/bin/lsnrctl stop" &
su - oracle -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME" &
sleep 5
echo -n $"Starting Oracle DB: "
su - oracle -c "$0RACLE_HOME/bin/lsnrctl start" &
su - oracle -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME" &
;;
*)

echo "usage: $0 {start|stop|restart}"
exit
;;
esac

# End of script dbora

Now we need to add following two commands so that dba group have the appropriate permission to execute it:

chgrp dba /etc/init.d/dbora
chmod 750 /etc/init.d/dbora
Giving dba the proper permission

Step 3:

Now finally we need to add it in chkconfig.

chkconfig --add dbora

chkconfig --list | grep dbora

systenctl start dbora
systemctl enable dbora
systemctl status dbora

Now when you reboot the oracle db, automatically lsnrctl and database instance will be started.

Thanks. I hope this blog will help you to efficiently managing the db system. Please subscribe below if you find this useful.

LinkedIn:

https://www.linkedin.com/in/md-mahimbin-firoj-7b8a5a113/

YouTube:

https://www.youtube.com/@mahimfiroj1802/videos

--

--