Auto-Starting HVR Scheduler after Unix or Linux Boot
This section describes about how to enable automatic restart of HVR Scheduler when a Unix or Linux machine is rebooted.
Based on the daemon type available in the server where HVR is installed, one of the following configuration methods can be used for enabling automatic restart of HVR processes.
Configuring Systemd
On a Unix/Linux server with systemd, create a service to enable HVR Scheduler to auto-start after a system reboot or service failure.
The following steps should be performed as user root to configure systemd:
Create a unit file hvrscheduler.service in /etc/systemd/system directory. The unit file should contain the following:
[Unit] Description=HVR Scheduler Service # Database service is only needed if hub database is on the same system as hvrscheduler After=network.target hvr.socket database.service [Service] # The process start-up type 'forking' allows this service to spawn new processes Type=forking Environment="HVR_HOME=/home/hvruser/hvr/hvr_home" Environment="HVR_CONFIG=/home/hvruser/hvr/hvr_config" Environment="HVR_TMP=/home/hvruser/hvr/hvr_tmp" # This should be the same user that logs into HVR GUI User=hvr ExecStart=/home/hvruser/hvr/hvr_home/bin/hvrscheduler -horacle myhubdb/mypwd # Restart this service to after a crash Restart=always # The number of seconds to wait before attempting a restart RestartSec=5s [Install] WantedBy=multi-user.target
1. The HVR Scheduler service should start only after the Hub's database service (database.service) has started. Otherwise, after reboot the HVR Scheduler will fail immediately while trying to connect to the hub database.
2. The DB connection string syntax (in ExecStart) differs for each database. For more information about DB connection string syntax in HVR commands, see Calling HVR on the Command Line (channel is not required in the DB connection string (in ExecStart) to start HVR Scheduler).
To enable and start the service, execute the following commands:
systemctl enable hvrscheduler
systemctl start hvrscheduler
To verify whether the service is active, execute the following command:
systemctl status hvrscheduler
Sample output:
hvrscheduler.service - HVR Scheduler Loaded: loaded (/etc/systemd/system/hvrscheduler.service; disabled; vendor preset: disabled) Active: active (running) since Mon 2020-02-17 10:03:18 EST; 14min ago Process: 7587 ExecStart=/home/hvruser/hvr/hvr_home/bin/hvrscheduler -horacle myhubdb/mypwd mychannel Main PID: 7588 (hvrscheduler) CGroup: /system.slice/hvrscheduler.service ├─7588 hvrscheduler -horacle myhubdb/mypwd mychannel ├─7589 hvrscheduler -swork -horacle myhubdb/mypwd mychannel ├─7591 hvr hvrstats -h mysql -horacle myhubdb/mypwd mychannel ├─7592 hvr ora_mysql-cap-ora ├─7593 hvr -shvrstats-1 └─7594 hvr -shvrstats-1
Configuring Init
For a Unix/Linux server without systemd, xinetd, or inetd, use HVR's script file hvr_boot (available in hvr_home/lib) and a user-defined configuration file hvrtab to enable HVR Scheduler to auto-start after a system reboot.
The script file hvr_boot allows you to start and stop HVR processes (both HVR Scheduler and HVR Remote Listener) defined in the configuration file hvrtab. The script file hvr_boot should only be executed by the root user.
The following steps should be performed as user root to configure init:
Create the configuration file hvrtab in the /etc directory. Each line of this configuration file should contain four or more parameters separated by a space in the following format:
username port_or_hub hvr_home hvr_config [options]
- username: Indicates the Unix/Linux username under which HVR runs.
- port_or_hub: Indicates a TCP/IP port number (for HVR Remote Listener) or the username and password of the hub database (for HVR Scheduler). The DB connection string syntax for the hub database differs for each database. For DB connection string syntax, see Calling HVR on the Command Line.
- hvr_home: Indicates the path for $HVR_HOME.
- hvr_config: Indicates the path for $HVR_CONFIG.
- [options]: Indicates an optional parameter to pass other options to the HVR process. For more information about the options, see hvrremotelistener and hvrscheduler.
Sample configuration file:
# This hvrtab file starts a Remote Listener and two HVR schedulers (one for an Oracle hub and one for an Ingres hub). # The Oracle password is encrypted. For more information, see documentation for command hvrcrypt. root 4343 /home/hvruser/hvr/hvr_home /home/hvruser/hvr/hvr_config mylinuxuser orahubdb/!{DszmZY}! /home/hvruser/hvr/hvr_home /home/hvruser/hvr/hvr_config -EHVR_TMP=/home/hvruser/hvr/hvr_tmp -EORACLE_HOME=/opt/oracle -EORACLE_SID=prod mylinuxuser inghubdb /home/hvruser/hvr/hvr_home /home/hvruser/hvr/hvr_config -EHVR_TMP=/home/hvruser/hvr/hvr_tmp -EII_SYSTEM=/opt/ingres -EHVR_PUBLIC_PORT=50001
Lines starting with a hash (#) are treated as comments.
Copy the script file hvr_boot (available in hvr_home/lib) to the init.d directory and create symlinks to the rc.d directory.
For an Oracle RAC, the script file hvr_boot can be enrolled in the cluster with command crs_profile.
The HVR Scheduler service should start only after the Hub's database service has started. Otherwise, after reboot the HVR Scheduler will fail immediately while trying to connect to the hub database.
For non-Solaris machines, this can be achieved using the start and stop sequence number in the boot filename. The start sequence of hvr_boot must be bigger than the start sequence of the DBMS service, and the stop sequence must be smaller than the stop sequence of the DBMS.
For Solaris SMF, this can be achieved by editing the file hvr_boot.xml and replacing the string svc:/milestone/multi–user–server with the name of the DBMS service (e.g. svc:/application/database/oracle).
The following example uses start sequence 97 and stop sequence 03 (except HP–UX which uses 997 and 003 because it requires three digits).
On AIX, to start and stop HVR for run level 2:
cp hvr_boot /etc/rc.d/init.d
ln -s /etc/rc.d/init.d/hvr_boot /etc/rc.d/rc2.d/S97hvr_boot
ln -s /etc/rc.d/init.d/hvr_boot /etc/rc.d/rc2.d/K03hvr_boot
On HP–UX, to start and stop HVR for run level 3:
cp hvr_boot /sbin/init.d
ln -s /sbin/init.d/hvr_boot /sbin/rc3.d/S997hvr_boot
ln -s /sbin/init.d/hvr_boot /sbin/rc3.d/K003hvr_boot
On Linux, to start HVR for run levels 3 and 5 and stop for all run levels:
cp hvr_boot /etc/init.d
ln -s /etc/init.d/hvr_boot /etc/rc.d/rc3.d/S97hvr_boot
ln -s /etc/init.d/hvr_boot /etc/rc.d/rc5.d/S97hvr_boot
ln -s /etc/init.d/hvr_boot /etc/rc.d/rc0.d/K03hvr_boot
ln -s /etc/init.d/hvr_boot /etc/rc.d/rc1.d/K03hvr_boot
ln -s /etc/init.d/hvr_boot /etc/rc.d/rc2.d/K03hvr_boot
ln -s /etc/init.d/hvr_boot /etc/rc.d/rc3.d/K03hvr_boot
ln -s /etc/init.d/hvr_boot /etc/rc.d/rc4.d/K03hvr_boot
ln -s /etc/init.d/hvr_boot /etc/rc.d/rc5.d/K03hvr_boot
ln -s /etc/init.d/hvr_boot /etc/rc.d/rc6.d/K03hvr_boot
On Solaris 8 or 9, to start and stop HVR for run level 2 (which implies level 3):
cp hvr_boot /etc/init.d
ln -s /etc/init.d/hvr_boot /etc/rc2.d/S97hvr_boot
ln -s /etc/init.d/hvr_boot /etc/rc2.d/K03hvr_boot
On Solaris 10 and higher;
For newer Solaris versions, the script file hvr_boot must be registered in the Solaris's System Management Facility (SMF). Also, the file hvr_boot.xml (available in hvr_home/lib) should be copied to the init.d directory.
cp /opt/hvr/hvr_home/lib/hvr_boot /lib/svc/method
cp /opt/hvr/hvr_home/lib/hvr_boot.xml /var/svc/manifest/application
svccfg
import /var/svc/manifest/application/hvr_boot.xml
quit
svcadm enable svc:/application/hvr_boot
To check if the service is running:
svcs -a|grep hvr
Sample output:
16:00:29 svc:/application/hvr_boot:default