When using RHEL 7 or OEL 7 you may want to enable the use of systemd to automatically start or stop Dbvnet and Dbvserver on system restart.
Problem Details
Problem Statement
Enable Dbvnet and Dbvserver auto start/stop using systemd for standby v8
Applicable Error Code
N/A
Affected Versions
Standby Version 8.0
Affected Platforms
RHEL 7 or OEL 7
Description
When using RHEL 7 or OEL 7 you may want to enable the use of systemd to automatically start or stop Dbvnet and Dbvserver on system restart.
This document will provide you with the sample configuration files and commands which you can use to enable this.
The assumption of this document is that you are familiar with systemd.
ON OEL8 or RHEL8 systems:
If you are on OEL8 or RHEL8 system, then for all the script examples below use following syntax:
[Unit]
Description=Dbvisit Standby - <component>
After=network-online.target
Otherwise components could fail to start due to interface not being completely ready.
Dbvnet:
Create a file in /usr/lib/systemd/system called dbvnet.service
cd /usr/lib/systemd/system/
chmod 755 dbvnet.service
Copy the text below to the dbvnet.service file. You might need to adjust the path where Dbvisit Standby is installed and ensure the standard Oracle user PATH is included within an environment setting to allow the uname unix command to be found. e.g. ($ORACLE_HOME for XE installation)
Environment=PATH=/u01/app/oracle/product/11.2.0/xe/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/opt/oracle/product/12cR1/db/bin
- in the example below /usr/dbvisit is the DBVISIT_BASE location:
# /usr/lib/systemd/system/dbvnet.service # # Dbvisit Standby - Dbvnet systemd unit file: # description: Dbvisit network infrastructure daemon. [Unit] Description=Dbvisit Standby - Dbvnet After=syslog.target network.target [Service] Type=simple RemainAfterExit=yes User=oracle Group=oinstall ExecStart=/usr/dbvisit/dbvnet/dbvnet -d start ExecStop=/usr/dbvisit/dbvnet/dbvnet -d stop [Install] WantedBy=multi-user.target
To enable the service:
# systemctl daemon-reload # systemctl enable dbvnet.service
Then to start and stop you can use:
# systemctl start dbvnet.service # systemctl stop dbvnet.service
Dbvagent:
Create a file in /usr/lib/systemd/system called dbvagent.service
cd /usr/lib/systemd/system/
chmod 755 dbvagent.service
Copy the text below to the dbvagent.service file. You might need to adjust the path where Dbvisit Standby is installed - in the example below /usr/dbvisit is the DBVISIT_BASE location:
# /usr/lib/systemd/system/dbvagent.service # # Dbvisit Standby - Dbvagent systemd unit file: # description: Dbvisit agent daemon. # [Unit] Description=Dbvisit Standby - Dbvagent After=syslog.target network.target [Service] Type=simple RemainAfterExit=yes User=oracle Group=oinstall ExecStart=/usr/dbvisit/dbvagent/dbvagent -d start ExecStop=/usr/dbvisit/dbvagent/dbvagent -d stop [Install] WantedBy=multi-user.target
To enable the service:
# systemctl daemon-reload # systemctl enable dbvagent.service
Then to start and stop you can use:
# systemctl start dbvagent.service # systemctl stop dbvagent.service
Dbvctl database start/stop:
Create a file in /usr/lib/systemd/system called dbvctl-<ddc_name>.service
cd /usr/lib/systemd/system/
chmod 755 dbvctl-<ddc_name>.service
Copy the text below to the dbvctl-<ddc_name>.service file. Be aware you need to set a correct name of DDC file (DBVTWO). It's an example only your one will be different. You might need to adjust the path where Dbvisit Standby is installed - in the example below /usr/dbvisit is the DBVISIT_BASE location:
#
# Dbvisit Standby - Dbvctl database start/stop systemd unit file:
# description: Dbvisit database start/stop daemon
#
[Unit]
Description=Dbvisit Standby - Dbvctl database service
After=syslog.target network.target
[Service]
Type=simple
RemainAfterExit=yes
User=oracle
Group=oinstall
ExecStart=/usr/dbvisit/standby/dbvctl -d DBVTWO -o start
ExecStop=/usr/dbvisit/standby/dbvctl -d DBVTWO -o stop
[Install]
WantedBy=multi-user.target
To enable the service:
# systemctl daemon-reload # systemctl enable dbvctl-dbvtwo.service
Then to start and stop you can use:
# systemctl start dbvctl-dbvtwo.service # systemctl stop dbvctl-dbvtwo.service
Dbvctl DDC daemon (optional):
It will start dbvctl DDC daemon. The database instance must be already started so there is a dependency on dbvctl-dbvtwo.service.
Create a file in /usr/lib/systemd/system called dbvctl-<ddc_name>-daemon.service
cd /usr/lib/systemd/system/
chmod 755 dbvctl-<ddc_name>-daemon.service
Copy the text below to the dbvctl-<ddc_name>-daemon.service file. Be aware you need to set a correct name of DDC file (DBVTWO). It's an example only your one will be different. You might need to adjust the path where Dbvisit Standby is installed - in the example below /usr/dbvisit is the DBVISIT_BASE location:
# /usr/lib/systemd/system/dbvctl-dbvtwo-daemon.service
#
# Dbvisit Standby - Dbvctl DDC daemon start/stop systemd unit file:
# description: Dbvisit DDC daemon start/stop daemon
#
[Unit]
Description=Dbvisit Standby - Dbvctl DDC daemon service
After=dbvctl-dbvtwo.service
[Service]
Type=simple
RemainAfterExit=yes
User=oracle
Group=oinstall
ExecStart=/usr/dbvisit/standby/dbvctl -d DBVTWO -D start
ExecStop=/usr/dbvisit/standby/dbvctl -d DBVTWO -D stop
[Install]
WantedBy=multi-user.target
To enable the service:
# systemctl daemon-reload # systemctl enable dbvctl-dbvtwo-deamon.service
Then to start and stop you can use:
# systemctl start dbvctl-dbvtwo-daemon.service # systemctl stop dbvctl-dbvtwo-daemon.service
Dbvserver:
Create a file in /usr/lib/systemd/system called dbvserver.service
cd /usr/lib/systemd/system/
chmod 755 dbvserver.service
Copy the text below to the dbvserver.service file. You might need to adjust the path where Dbvisit Standby is installed - in the example below /usr/dbvisit is the DBVISIT_BASE location:
# /usr/lib/systemd/system/dbvserver.service # # Dbvisit Standby - Dbvserver systemd unit file: # description: Dbvisit webserver daemon. # [Unit] Description=Dbvisit Standby - Dbvserver After=syslog.target network.target [Service] Type=simple RemainAfterExit=yes User=oracle Group=oinstall ExecStart=/usr/dbvisit/dbvserver/dbvserver -d start ExecStop=/usr/dbvisit/dbvserver/dbvserver -d stop [Install] WantedBy=multi-user.target
To enable the service:
# systemctl daemon-reload # systemctl enable dbvserver.service
Then to start and stop you can use:
# systemctl start dbvserver.service # systemctl stop dbvserver.service
It also possible to start Oracle listener as systemd service. You have to set the right ORACLE_HOME and listener name. Copy the text below to the dbvlistener.service file
# /usr/lib/systemd/system/dbvlistener.service # # Dbvisit Standby - Dbvlistener systemd unit file: # description: Dbvisit listener daemon. # [Unit] Description=Dbvisit Standby - Dbvlistener After=syslog.target network.target [Service] Type=simple RemainAfterExit=yes User=oracle Group=oinstall Environment="ORACLE_HOME=/u01/app/oracle/product/12.1.0.2/dbhome_1" ExecStart=/u01/app/oracle/product/12.1.0.2/dbhome_1/bin/lsnrctl start ExecStop=/u01/app/oracle/product/12.1.0.2/dbhome_1/bin/lsnrctl stop [Install] WantedBy=multi-user.target
To enable the service:
# systemctl daemon-reload # systemctl enable dbvlistener.service
Then to start and stop you can use:
# systemctl start dbvlistener.service # systemctl stop dbvlistener.service
It is recommended that you test these steps in your development or test environment prior to implementing in production as some adjustments might be required to meet your environment.
PAM Limits and systemd
#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
This is very important when using settings like LARGE PAGES. All limits, that are needed must be set in the service configuration. Eg.:
LimitMEMLOCK=209715200K
LimitNOFILE=655350
LimitNPROC=1638400
LimitSTACK=32768K
Thank you for the useful templates!
There seems to be a little glitch in all examples, though:
"chmod 755 "
Shouldn't that be something like "vi "?
Neither are said files there in the first place (chmod errs out) nor is mode 755 necessary for services.
Cheers,
Uwe