Controlling Oracle Management Cloud agent to startup at boot can be a little complicated. Often admins KLUDGE up shell scripts to make it work, but there is a cleaner way using systemd commands.systemd is one of the core components of a Oracle Linux 7 deployment. Is is also part of the RHEL7 deployment. It controls demons, allows admins to easily start and stop services. It is not just the daemon, but also an entire suite of components, and is often considered a blackbox to many Linux admins. This post will show how to make the OMC cloudagent managed by systemd.
These steps assume that OMC is installed in /u01/omc and using the oracle user.
The first step is to create three wrapper scripts to start, stop and check the status
These are assuming that OMC is installed into /u01/omc
You will need to copy these files into /u01
The following files goes into /u01/omc/omc_start
#!/bin/bash
su – “oracle” -c “/u01/omc/agent_inst/bin/omcli start agent”
The following files goes into /u01/omc/omc_status
#!/bin/bash
su – “oracle” -c “/u01/omc/agent_inst/bin/omcli status agent”
The following files goes into /u01/omc/omc_stop
#!/bin/bash
su – “oracle” -c “/u01/omc/agent_inst/bin/omcli stop agent”
Finally , create a new file usr/lib/systemd/system/omc.service
[Unit]
Description=OMC daemon
Documentation=http://www.talesformthedatacenter.com
After=network.target syslog.target
[Service]
# see man systemd.service
Type=oneshot
ExecStart=/u01/omc/omc_start
RemainAfterExit=true
ExecStop=/u01/omc/omc_stop
StandardOutput=journal
[Install]
WantedBy=multi-user.target
Then check the omc.service, to make sure there are no errors. No output is good!
systemd-analyze verify /usr/lib/systemd/system/omc.service
Next enable the service, that will startup OMC on reboot
systemctl enable omc.service
Now verify that it is enabled
systemctl list-unit-files | grep omc.service
Now the normal systemctl commands will work,
systemctl start omc.service
systemctl stop omc.service
systemctl status omc.service
Hopefully this helps you get OMC running on Oracle Linux 7 as a proper service.
actually, here is working config
[Unit]
Description=Oracle Management Cloud Agent
After=network.target
[Service]
Type=forking
LimitNOFILE=4096
ExecStart=/opt/omcs/agent_inst/bin/omcli start agent
ExecStop=/opt/omcs/agent_inst/bin/omcli stop agent
User=omcagent
Group=omcagent
[Install]
WantedBy=multi-user.target