Steps to auto-start an Oracle Database on boot in RHEL 7

Step 1: Verify Oracle Environment

Login as oracle user and confirm:

echo $ORACLE_HOME
echo $ORACLE_SID

Example:

ORACLE_HOME=/u01/app/oracle/product/19c/dbhome_1
ORACLE_SID=ORCLCDB

🔹 Step 2: Update /etc/oratab

Edit the file as root:

vi /etc/oratab

Change the last field from N to Y:

ORCLCDB:/u01/app/oracle/product/19c/dbhome_1:Y

📌 Important

  • Y = Auto startup allowed
  • N = Manual only

🔹 Step 3: Create systemd Service

3.1 Create the service file

vi /etc/systemd/system/oracle-db.service

3.2 Paste the following content

[Unit]
Description=Oracle Database 19c Service
After=network.target

[Service]
Type=forking
User=oracle
Group=oinstall
ExecStart=/u01/app/oracle/product/19c/dbhome_1/bin/dbstart /u01/app/oracle/product/19c/dbhome_1
ExecStop=/u01/app/oracle/product/19c/dbhome_1/bin/dbshut /u01/app/oracle/product/19c/dbhome_1
Restart=no

[Install]
WantedBy=multi-user.target

📌 Replace paths if your ORACLE_HOME is different.


🔹 Step 4: Fix dbstart/dbshut Script

Oracle scripts rely on correct environment.

Edit both files:

vi $ORACLE_HOME/bin/dbstart
vi $ORACLE_HOME/bin/dbshut

Ensure this line exists and is NOT commented:

ORACLE_HOME_LISTNER=$ORACLE_HOME

Save and exit.


🔹 Step 5: Reload systemd & Enable Service

systemctl daemon-reload
systemctl enable oracle-db

🔹 Step 6: Start & Test

Start manually:

systemctl start oracle-db

Check status:

systemctl status oracle-db

Reboot test:

reboot

After reboot:

ps -ef | grep pmon
lsnrctl status

✅ Optional: Separate Listener Service (Best Practice)

Create another service:

/etc/systemd/system/oracle-listener.service
[Unit]
Description=Oracle Listener
After=network.target

[Service]
Type=forking
User=oracle
ExecStart=/u01/app/oracle/product/19c/dbhome_1/bin/lsnrctl start
ExecStop=/u01/app/oracle/product/19c/dbhome_1/bin/lsnrctl stop

[Install]
WantedBy=multi-user.target

Enable it:

systemctl enable oracle-listener
Scroll to Top