8i | 9i | 10g | 11g | 12c | 13c | 18c | Misc | PL/SQL | SQL | RAC | WebLogic | Linux

Home » Misc » Here

Comments for Linux Services (systemd, systemctl)


Javier said...

I had to add RemainAfterExit=yes in the [Service] section of the service descriptor. Otherwise, the shutdown.sh script gets called short after the startup.sh script finishes (using Centos7).

Mark said...

Javier, same here re having to add RemainAfterExit=yes. I also added User and Group to avoid su;

[Service]
Type=oneshot
RemainAfterExit=yes
User=oracle
Group=oinstall
ExecStart=/u01/app/oracle/product/12.1.0/dbhome_1/bin/dbstart /u01/app/oracle/product/12.1.0/dbhome_1
ExecStop=/u01/app/oracle/product/12.1.0/dbhome_1/bin/dbshut /u01/app/oracle/product/12.1.0/dbhome_1

Tim... said...

Hi.

Thanks for the suggestions. I've added these to the article and given you both a shout out. :)

Cheers

Tim...

frodo2000 said...

My version of service descriptor that use ORACLE_HOME variable:
[Service]
Type=oneshot
RemainAfterExit=yes
User=oracle
Group=oinstall
Environment="ORACLE_HOME=/u01/app/oracle/product/12.1.0.2/db_1"
ExecStart=/bin/sh -c "${ORACLE_HOME}/bin/dbstart $ORACLE_HOME &"
ExecStop=/bin/sh -c "${ORACLE_HOME}/bin/dbshut $ORACLE_HOME"

Tim... said...

Hi.

Calling a script is much more flexible, as it allows you to start as many services as you like, and also allows you to control the startup/shutdown order.

Cheers

Tim...

Phillip said...

ExecStart=/home/oracle/scripts/startup.sh >> /home/oracle/scripts/startup_shutdown.log 2>&1 &
ExecStop=/home/oracle/scripts/shutdown.sh >> /home/oracle/scripts/startup_shutdown.log 2>&1

The service is not outputting anything to the startup_shutdown.log file. I've created the file and changed the permission on it. Started the dbora.service as root and nothing is writing to that file.

Tim... said...

Hi.

That's because all service output using systemd is visible from the status command. This start/stop log is just to catch anything that "goes astray". :) If you want to capture output, change the startup and shutdown scripts to direct out internally.

Cheers

Tim...

Fr3dY said...

On RHEL 7, NFS volumes were unmounted before stopping Oracle, causing file corruption.
Here's my fix:

[Unit]
Description=Oracle Database Service
Requires=rpc-statd.service network.target nfs.service nfs-mountd.service local-fs.target remote-fs.target
After=syslog.target network.target nfs.service nfs-mountd.service local-fs.target rpc-statd.service remote-fs.target

Fr3dY said...

Oh my... now the following message appears on alert.log regarding hugepages usage:

Per process system memlock (soft) limit = 64K

Fixed it by adding the following to the [Service] section:

LimitMEMLOCK=infinity
LimitNOFILE=65535

If not defined, systemd wasn't using oracle's limits :(

Fabio said...

great article! but does the startup.sh and shutdown.sh can handle multiple DBs?

Tim... said...

Hi.

It's up to you to cope with that in the startup.sh and shutdown.sh. You can either call dbstart and dbshut, or manually switch side and startup.

Cheers

Tim...

Fabio said...

Thanks Tim!

Jan said...

Whatever I've tried so far, but Oracle Linux 7.2 keeps killing PMON processes, before systems runs the shutdown.sh script in which my database is stoped with "shutdown immediate" and the listener is stopped as well. Works perfect when I run "system stop dbora". But during shutdown ally hoes down in flash; checking alert log later shows that Database went down due to dead PMON.
Startup is working.

Jan said...

Correction to text above systems should be systemD, "system stop dbora" should read "systemctl stop dbora" . I a trying to have systemD stop my environment (db plus listener) but before the script immediate stops the database, shutdown already has killed all processes.

Tim... said...

Hi.

Try using "Type=idle", which is like simple, but puts the service to the end of the startup sequence, and therefore the beginning of the shutdown sequence.

Cheers

Tim...

Victor Shulyak said...

limits.conf also sets stack and nproc. I've added LimitSTACK=32768K LimitNPROC=16384 and oracle will not start. It seems working.

Victor Shulyak said...

I meant 'oracle will start', sorry, can't edit comment.

Leo Hernandez said...

I can easily determine that the processes have been killed by simply replacing my ExecStop script with one that does a 'ps -ef | grep ora' and outputs to a file. When I review that file after a reboot, it shows none of the background processes for oracle.

Leo Hernandez said...

I'm using Type=idle, but systemd is killing Oracle background processes before it can stop the service.

Ugo Bellavance said...

Anyone has a host with multiple Oracle DB instance and successfully managed them through systemd? By the way, if you use sqlplus to stop, then start your DB that was originally started using systemd is a call for problems. The most important problem is that it will ignore the limits set in the systemd file and probably not use the huge pages, leading to swapping/trashing scenario.

Ugo Bellavance said...

Also, systemd will see the service as down and will not stop it cleanly at shutdown.

Tim... said...

Hi.

If you use dbstart/dbshut it will start/stop all databases with a Y in the /etc/oratab. If you are using a start_all.sh/stop_all.sh script, it is up to you make sure the scripts start and stop the DBs correctly. It's not magic. :)

Limits should be specified in systemd file and on the OS as normal, then there are no problems.

Cheers

Tim...

DO NOT ask technical questions here! They will be deleted!

These comments should relate to the contents of a specific article. Constructive criticism is good. Advertising and offensive comments are bad and will be deleted!