Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Any official Oracle’s systemd service startup script to run 12c grid infrastructure and 12c database

niksajurJan 27 2017 — edited Feb 1 2017

Hello,

is there any official or recommended Oracle’s service startup script to run 12c grid infrastructure and 12c database under systemd? I was searching the 12.1 documentation, even the newest 12.2 documentation, but didn’t find anything.

When it comes to systemd, it is not a problem to start conventional 12c installation without grid (asm) using ext4 filesystem for database storage. On my other machine I have fresh Fedora 25 Server installation and 12c database (ext4 fs) and this ora.service startup script works just fine starting/stopping listener and database:

# Systemd unit file ora

[Unit]

Description=Oracle Database 12c Startup/Shutdown Service

After=syslog.target network.target

[Service]

LimitMEMLOCK=infinity

LimitNOFILE=65535

Type=oneshot

RemainAfterExit=yes

User=oracle

Group=oinstall

Environment="ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1"

ExecStart=/u01/app/oracle/product/12.1.0/dbhome_1/bin/dbstart $ORACLE_HOME >> 2>&1 &

ExecStop=/u01/app/oracle/product/12.1.0/dbhome_1/bin/dbshut $ORACLE_HOME 2>&1 &

[Install]

WantedBy=multi-user.target

It is however completely different and more complicated situation when it comes to Oracle Linux 7.3 on my first machine with 12c grid (asm) and database installations in two separate homes owned by two OS users (grid and oracle) which are members of nine OS groups (oinstall, dba, oper, backupdba,  dgdba, kmdba, asmdba, asmoper, asmadmin). More precisely

# id oracle

uid=54321(oracle) gid=54321(oinstall) groups=54321(oinstall),54322(dba),54323(oper),54324(backupdba),54325(dgdba),54326(kmdba),54327(asmdba)

# id grid

uid=54322(grid) gid=54321(oinstall) groups=54321(oinstall),54322(dba),54327(asmdba),54328(asmoper),54329(asmadmin)

where

grid:oinstall owns ORACLE_HOME=/u01/app/grid/product/12.1.0/gridhome_1        /                  

oracle:oinstall owns ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1

Currently I am starting and stopping listener, grid, oracle and OEM Cloud Control manually and outside of systemd. Oracle’s official recommendation for this kind of installation is to start all by ‘srvctl’ command. Here is my actual ora.sh bash script to start them all outside of systemd using srvctl. It works just fine. Note that srvctl from oracle’s ORACLE_HOME automatically chooses to start listener and asm from grid home. That way the tnslsnr process and all of _+asm processes will be owned by grid user.

#!/bin/sh

# /home/oracle/scripts/ora.sh 12c start-all script

# Startup script for the Oracle Listener, ASM Instance, DBMS Instance and OEM Cloud Control

# srvctl from oracle’s ORACLE_HOME automatically chooses to start listener and asm from grid home

case "$1" in

    start)

        echo -ne "Starting Listener, ASM, Oracle Database 12c and Oracle Enterprise Manager Cloud Control 12c:\n"

        su - oracle -l -c '${ORACLE_HOME}/bin/srvctl start listener'

        su - oracle -l -c '${ORACLE_HOME}/bin/srvctl start asm'

        su - oracle -l -c '${ORACLE_HOME}/bin/srvctl start database -db orcl'

        su - oracle -l -c '${OMS_HOME}/bin/emctl start oms'

        su - oracle -l -c '${AGENT_HOME}/bin/emctl start agent'

        ;;

    stop)

        echo -ne "Stopping Oracle Enterprise Manager Cloud Control 12c, Oracle Database 12c, ASM and Listener:\n"

        su - oracle -l -c '${OMS_HOME}/bin/emctl stop oms -all'

        su - oracle -l -c '${AGENT_HOME}/bin/emctl stop agent'

        su - oracle -l -c '${ORACLE_HOME}/bin/srvctl stop database -db orcl'

        su - oracle -l -c '${ORACLE_HOME}/bin/srvctl stop asm -force'

        su - oracle -l -c '${ORACLE_HOME}/bin/srvctl stop listener'

        ;;

    reload|restart)

        $0 stop

        $0 start

        ;;

    *)

        echo "Usage: $0 start|stop|restart|reload"

        exit 1

esac

exit 0

Unfortunately this ora.sh script doesn’t work under systemd. I can divide the script into two separate scripts: ora_start.sh for startup and ora_stop.sh for shutdown and create systemd ora.service unit putting

User=oracle

Group=oinstall

ExecStart=/home/oracle/scripts/ora_start.sh

ExecStop=/home/oracle/scripts/ora_stop.sh

but it doesn’t work. Even if it worked, I would not be able to judge whether it is the optimal solution or not. There are two users here (oracle and grid) sharing the same primary group (oinstall). The srvctl command must be run from oracle home by oracle user in order to start listener and asm from grid home and correctly resolve ownership for both grid and oracle users’ processes. On the other side, systemd is too complex, too complicated, extremely messy and most definitely violates and breaks unix philosophy. It’s not easy to experiment with thousands of obfuscated non-memorizable unit parameters not knowing what you are doing. Therefore I cannot believe that Oracle didn’t ship an official or at least recommended systemd ora.service primer for this kind of installation.

Thanks in advance.

This post has been answered by niksajur on Feb 1 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 1 2017
Added on Jan 27 2017
17 comments
5,999 views