Oracle systemd startup script

from: https://community.oracle.com/thread/2520738

oracle.service

sudo touch /etc/systemd/system/oracle.service

sudo chmod 644 /etc/systemd/system/oracle.service

[Unit]
Description=Oracle database server
After=syslog.target network.target

[Service]
Type=oneshot
User=oracle
Group=oinstall
RemainAfterExit=yes
ExecStart=/bin/oracle.sh
Environment=ORACLE_HOME=/opt/oracle/product/12.1.0/dbhome_1
Environment=ORACLE_BASE=/opt/oracle
Environment=ORACLE_SID=orcl

[Install]
WantedBy=multi-user.target

oracle.sh

sudo touch /bin/oracle.sh

sudo chown :oinstall /bin/oracle.sh

sudo chmod 750 /bin/oracle.sh

#! /bin/bash
#  script used by oracle.service

$ORACLE_HOME/bin/lsnrctl start;
$ORACLE_HOME/bin/dbstart $ORACLE_HOME;

sudo systemctl daemon-reload

sudo systemctl enable oracle.service

[Note: if the database wasn’t started, you need to check the /etc/oratab to see if the third field is set to ‘N’. If so, the database will be ignored by dbstart and you need to manually change it to ‘Y’.]

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s