1. Create unit file in the /etc/systemd/system/ directory and make sure it has correct file permissions. Execute as root:
[root@em12c ~]# touch /etc/systemd/system/Oracle_Listener_LISTENER.service
[root@em12c ~]# chmod 664 /etc/systemd/system/Oracle_Listener_LISTENER.service
2. Add the following content to the file: /etc/systemd/system/Oracle_Listener_LISTENER.service
[Unit]
Description=Oracle Listener (LISTENER)
After=network.target
[Service]
Type=forking
PIDFile=/home/oracle/scripts/LISTENER.pid
ExecStart=/bin/su - oracle -c "/home/oracle/scripts/lsnrstart.sh LISTENER"
ExecReload=/bin/su - oracle -c "/home/oracle/scripts/lsnrshut.sh LISTENER;/home/oracle/scripts/lsnrstart.sh LISTENER"
ExecStop=/bin/su - oracle -c "/home/oracle/scripts/lsnrshut.sh LISTENER"
[Install]
WantedBy=multi-user.target
3. Execute the following commands to reload the configuration and start the custom service:
[root@em12c ~]# systemctl daemon-reload
[root@em12c ~]# systemctl start Oracle_Listener_LISTENER.service [root@em12c ~]# systemctl enable Oracle_Listener_LISTENER.service
4. Create unit file in the /etc/systemd/system/ directory and make sure it has correct file permissions. Execute as root:
[root@em12c ~]# touch /etc/systemd/system/Oracle_Instance_orcl.service [root@em12c ~]# chmod 664 /etc/systemd/system/Oracle_Instance_orcl.service
5. Add the following content to the file: /etc/systemd/system/Oracle_Instance_orcl.service
[Unit]
Description=Oracle Instance (orcl)
After=network.target
Wants=Oracle_Listener_LISTENER.service
[Service]
Type=forking
PIDFile=/home/oracle/scripts/orcl.pid
ExecStart=/bin/su - oracle -c "/home/oracle/scripts/dbstart.sh orcl"
ExecReload=/bin/su - oracle -c "/home/oracle/scripts/dbshut.sh orcl;/home/oracle/scripts/lsnrstart.sh orcl"
ExecStop=/bin/su - oracle -c "/home/oracle/scripts/dbstart.sh orcl"
[Install]
WantedBy=multi-user.target
6. Execute the following commands to reload the configuration and start the custom service:
[root@em12c ~]# systemctl daemon-reload
[root@em12c ~]# systemctl start Oracle_Instance_orcl.service
[root@em12c ~]# systemctl enable Oracle_Instance_orcl.service
7. Check the service status:
[root@em12c ~]# systemctl |grep -e Oracle -e DESCRIPTION
UNIT LOAD ACTIVE SUB DESCRIPTION
Oracle_Instance_orcl.service loaded active running Oracle Instance (orcl)
Oracle_Listener_LISTENER.service loaded active running Oracle Listener (LISTENER)
[root@em12c ~]# systemctl list-unit-files|grep -e Oracle -e STATE
UNIT FILE STATE
Oracle_Instance_orcl.service enabled
Oracle_Listener_LISTENER.service enabled
[root@em12c ~]# systemctl status Oracle_Instance_orcl.service
Oracle_Instance_orcl.service - Oracle Instance (orcl)
Loaded: loaded (/etc/systemd/system/Oracle_Instance_orcl.service; enabled)
Active: active (running) since Thu 2015-10-29 00:15:20 SGT; 14s ago
Process: 15214 ExecStart=/bin/su - oracle -c /home/oracle/scripts/dbstart.sh orcl (code=exited, status=0/SUCCESS)
Main PID: 15295 (ora_smon_orcl)
CGroup: /system.slice/Oracle_Instance_orcl.service
‣ 15295 ora_smon_orcl
Oct 29 00:15:13 em12c.dbaglobe.com systemd[1]: Starting Oracle Instance (orcl)...
Oct 29 00:15:13 em12c.dbaglobe.com su[15214]: (to oracle) root on none
Oct 29 00:15:20 em12c.dbaglobe.com systemd[1]: Started Oracle Instance (orcl).
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment