if you are not using Grid Infrastructure and Oracle Restart, this guide will help you
automate single instance Oracle database.
create a directory for your shell scripts for example:
mkdir /app/oracle/scripts
1. create a script called setEnv.sh
vi setEnv.sh
# Oracle Settings
export TMP=$ORACLE_BASE/tmp
export TMPDIR=$ORACLE_BASE/tmp
export ORACLE_HOSTNAME=mycomputer.com
export ORACLE_UNQNAME=db12c
export ORACLE_BASE=/orcl/db12
export ORACLE_HOME=/orcl/db12/product/12.2.0.1
export ORACLE_SID=/orcl/db12
export PATH=$PATH:$ORACLE_HOME/bin:/usr/vacpp/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/jlib:/$ORACLE_HOME/rdbms/jlib
2. create two scripts called start_all.sh & stop_all.sh
vi start_all.sh
#!/bin/sh
. /app/oracle/scripts/setEnv.sh
export ORAENV_ASK=NO
. oraenv
export ORAENV_ASK=YES
dbstart \$ORACLE_HOME
vi stop_all.sh
#!/bin/sh
. /app/oracle/scripts/setEnv.sh
export ORAENV_ASK=NO
. oraenv
export ORAENV_ASK=YES
dbshut \$ORACLE_HOME
3. edit scripts unde $ORACLE_HOME/bin for dbstart and dbshut by performing the following:
replace ORACLE_HOME_LISTNER=$1
with
ORACLE_HOME_LISTNER=$ORACLE_HOME
and replace $ORACLE_HOME/bin/lsnrctl start >> $LOG 2>&1 &
with your listener name configured in your listener.ora file
$ORACLE_HOME/bin/lsnrctl start listener_db12c >> $LOG 2>&1 &
4. make sure /etc/oratab is reflecting the right oracle home path
5. Ask Linux Admin to create the following file:
vi /lib/systemd/system/dbora.service
[Unit]
Description=Oracle DB 12cR2
After=syslog.target network.target
[Service]
RemainAfterExit=yes
User=oracle
Group=dba
ExecStart=/app/oracle/scripts/start_all.sh
ExecStop=/app/oracle/scripts/stop_all.sh
[Install]
WantedBy=multi-user.target
6. Linux Admin should execute the following:
systemctl daemon-reload
systemctl start dbora.service
systemctl enable dbora.service
8. Ask Linux Admin to reboot the Linux server to TEST automatic startup of the database