[systemd-devel] starting Oracle with systemd

Lennart Poettering lennart at poettering.net
Thu Oct 30 10:05:46 PDT 2014


On Tue, 28.10.14 15:08, Fisher, Charles J. (Top Echelon) (Charles.Fisher at alcoa.com) wrote:

> Is this the best way to start Oracle?
> 
> [root at localhost system]# cat oracle-foo.service
> [Unit]
> Description=oracle db - foo
> After=syslog.target

The After=syslog.target line is unnecessary these days. It's implied.

> 
> [Service]
> Environment=ORACLE_SID=foo ORACLE_HOME=/home/oracle/Ora12c/db
> ExecStart=/bin/ksh -c 'print "connect / as sysdba \n startup \n quit" | $ORACLE_HOME/bin/sqlplus -silent /nolog'
> ExecStop=/bin/ksh -c 'print "connect / as sysdba \n shutdown
> immediate \n quit" | $ORACLE_HOME/bin/sqlplus -silent /nolog'

This looks quite suspicious as you spawn a shell and keep it
running. It's fine to run shells and then finally exec the real
binary, replacing the shell process, but keeping the shell around
would tell systemd that the shell was the actual daemon process.

> Type=forking
> User=oracle
> Group=dba
> 
> [Install]
> WantedBy=multi-user.target
> 
> #This file should be placed in /etc/systemd/system
> #enable for start at boot by: systemctl enable oracle_db-foo.service
> 
> I used to do it with an init.d script that grabbed the SID out of
> argv[0] with ORACLE_SID=${0##*-} - I'm assuming that a systemd
> service file can't grab anything similarly out of argv[0], and I
> can't hard-link them all together.
> 
> I may have several instances on a machine; I'd like one service to
> start/stop everything if possible (maybe with dbstart/dbshut), but I
> also want granular control over each Oracle instance.

If you have multiple instances, use systemd's unit instance concept:

http://0pointer.de/blog/projects/instances.html

As I don't really know Oracle I cannot really tell you how to start it
best, but I hope the hints above are useful.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list