Oracle19c Start and Stop Service
Oracle19c Start and Stop Service
The systemctl command is used to stop, start, restart and check the status of a specified
service. Unlike the service command, most systemctl commands do not produce any status
output on the command line. Services can be referenced with or without the ".service" suffix.
# systemctl stop httpd
# systemctl stop httpd.service
The output from the systemctl status command is quite different to that of the service
command.
# systemctl status httpd
httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled)
Active: active (running) since Sun 2014-04-20 09:26:18 BST; 32min ago
Main PID: 16314 (httpd)
Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/se
CGroup: /system.slice/httpd.service
├─16314 /usr/sbin/httpd -DFOREGROUND
├─16315 /usr/sbin/httpd -DFOREGROUND
├─16316 /usr/sbin/httpd -DFOREGROUND
├─16317 /usr/sbin/httpd -DFOREGROUND
├─16318 /usr/sbin/httpd -DFOREGROUND
└─16319 /usr/sbin/httpd -DFOREGROUND
system-config-services
On Fedora the "Service Configuration" dialog is available from the menu (System >
Administration > Services) or directly from the command line by running the system-config-
services command.
The "Enable" and "Disable" buttons are used to toggle the auto-start on reboot for each
service. The "Start", "Stop" and "Restart" buttons affect the current state of the service.
Creating Linux Services
As an example, in this section we will create a new service to automatically start/stop an Oracle
database. This assumes the Oracle database is not using Oracle Restart and the "start_all.sh"
and "stop_all.sh" scripts are already present, as described here.
Create the service file called "/lib/systemd/system/dbora.service".
[Unit]
Description=The Oracle Database Service
After=syslog.target network.target
[Service]
# systemd ignores PAM limits, so set any necessary limits in the service.
# Not really a bug, but a feature.
# https://bugzilla.redhat.com/show_bug.cgi?id=754285
LimitMEMLOCK=infinity
LimitNOFILE=65535
#Type=simple
# idle: similar to simple, the actual execution of the service binary is delayed
# until all jobs are finished, which avoids mixing the status output with s
RemainAfterExit=yes
User=oracle
Group=oinstall
Restart=no
ExecStart=/bin/bash -c '/home/oracle/scripts/start_all.sh'
ExecStop=/bin/bash -c '/home/oracle/scripts/stop_all.sh'
[Install]
WantedBy=multi-user.target
Thanks to Javier and Mark in the comments for their suggestions about using RemainAfterExit,
User and Group in this file.
If you are using NFS storage, you need to define the dependency between Oracle and NFS.
[Unit]
Description=The Oracle Database Service
Requires=rpc-statd.service network.target nfs.service nfs-mountd.service local-fs
After=syslog.target network.target nfs.service nfs-mountd.service local-fs.target
[Service]
# systemd ignores PAM limits, so set any necessary limits in the service.
# Not really a bug, but a feature.
# https://bugzilla.redhat.com/show_bug.cgi?id=754285
LimitMEMLOCK=infinity
LimitNOFILE=65535
#Type=simple
# idle: similar to simple, the actual execution of the service binary is delayed
# until all jobs are finished, which avoids mixing the status output with s
Type=idle
RemainAfterExit=yes
User=oracle
Group=oinstall
Restart=no
ExecStart=/bin/bash -c '/home/oracle/scripts/start_all.sh'
ExecStop=/bin/bash -c '/home/oracle/scripts/stop_all.sh'
[Install]
WantedBy=multi-user.target
Thanks to Fr3dY in the comments for pointing out the NFS dependency management using
Requires and After and the issue with systemd and PAM limits.