Configure automatic failover
Automatic failover provides continuous high availability of OpsCenter for managing mission-critical data on DataStax Enterprise (DSE) clusters without manual intervention or downtime.
Currently, OpsCenter allows one backup instance to a primary instance in an active-passive configuration. The Best Practice Service includes an OpsCenter Failover Enabled rule that recommends enabling failover. When no backup is configured, the rule fails and sends an alert. After enabling failover, the rule passes the next time it runs if it detected a correctly configured backup OpsCenter instance.
If a non-DSE cluster (such as DataStax Community or open source Apache Cassandra®) is added after enabling automatic failover, OpsCenter fires an alert that automatic failover will not work, and the backup OpsCenter instance shuts down.
Failover behavior
The primary and backup OpsCenter instances send and listen for heartbeat messages on stomp channels to communicate status with each other.
The primary OpsCenter sends a heartbeat message regardless of whether a backup OpsCenter instance is configured.
The primary OpsCenter instance listens for messages from the heartbeat reply stomp channel to determine if a backup instance is configured.
The primary_opscenter_location configuration file you create on the backup OpsCenter instance contains the IP address of the primary OpsCenter instance that the backup OpsCenter instance monitors.
The configured backup OpsCenter instance listens for heartbeat messages from the primary OpsCenter instance to determine whether the primary OpsCenter instance is up.
If the backup OpsCenter instance detects no heartbeat from the primary OpsCenter instance during the configured window (60 seconds by default), the backup OpsCenter instance initiates the failover process and automatically assumes the responsibilities of the primary OpsCenter instance.
The backup OpsCenter instance automatically reconfigures the agents by automatically changing stomp_interface in address.yaml to connect to the backup instance instead of the failing primary instance.
|
To enable failover, your agents' |
Failover recovery
After a failover, the former backup OpsCenter instance that took over as primary remains the primary OpsCenter instance.
At that point, configure another backup OpsCenter by re-creating the primary_opscenter_location file that points the new backup instance to the IP address of the primary instance to monitor.
If you are configuring the former primary OpsCenter instance as the new backup instance, ensure the server is healthy again before restarting the server.
The primary_opscenter_location is set when you enable failover.
If a failover occurred due to a network split, the former primary OpsCenter instance must be manually shut down, and another backup instance configured when network connectivity has been restored.
Upon startup, each OpsCenter instance generates a unique id (uuid), which is stored in the failover_id file.
In the event of a network split, a failover_id uniquely identifies each OpsCenter instance to agents and prevents both OpsCenter instances from running operations post-failover, which could corrupt data.
The location of failover_id file depends on the type of installation and is configurable with failover_configuration_directory when you enable failover.
Failover aftereffects
After an automatic failover, minimal manual intervention (if any) is required for recovery, depending on the root cause of the failover and what processes were in progress at that time. Generally, the effects of failing over are similar to restarting OpsCenter, with a few notable exceptions:
-
Alerts: Trigger as normal. An exception is an alert firing and unfiring within the failover window, in which case the alert is never triggered.
-
Authentication: Logs out existing user sessions. User sessions do not persist. Users must log in again.
-
Backup: Skips a scheduled backup if it falls within the failover window. Backup does not occur until the next scheduled time.
-
Restore: Continues the restore operation if failover occurred mid-restore. However, the result of the restore cannot be communicated because the backup OpsCenter was unaware the restore transpired.
-
Repair Service: Resumes from the last saved state. Be sure to mirror the Repair Service directory. An OpsCenter instance failure does not affect repairs currently running on any nodes. New repairs do not continue until an automatic failover successfully completes or the OpsCenter instance that failed is brought up again.
-
Provisioning: Provisioning jobs that were in progress when the primary Lifecycle Manager (LCM) fails attempt to complete on the primary instance, and may fail. LCM does not attempt to automatically resume jobs on the backup OpsCenter, but you can manually run the job again to allow it to complete.
Enable automatic failover
You can configure automatic failover from a primary OpsCenter instance to a designated backup OpsCenter instance. Enabling failover requires minimal initial set up on the backup OpsCenter instance.
-
Make sure that the primary and secondary OpsCenter instances are running the same OpsCenter version.
DataStax cannot guarantee results if the instances are running different OpsCenter versions.
Additionally, the OpsCenter daemon (
opscenterd) and the DataStax Agent must be running the same version before configuring high availability. -
Make sure that your agents'
address.yamlfiles aren’t being managed by a third-party configuration management system.During failover, OpsCenter automatically changes the
stomp_interfaceproperty inaddress.yamlto point to the backup OpsCenter instance. If a separate configuration management system is managingaddress.yaml, that change might be undone when the configuration management system pushes its next update. -
Set up a hostname or IP that can switch between primary and backup OpsCenter instances to prevent changes to the OpsCenter web URL if a failover occurs.
If you do not set up a hostname or IP for seamless URL switching post-failover, inform your OpsCenter users of any alternate URL they can use to access OpsCenter in the event of a failover.
To override the primary OpsCenter URL that is generated by OpsCenter during failover, set the
override_primary_redirect_urloption inopscenterd.conf. -
Mirror the configuration directories stored on the primary OpsCenter instance to the backup OpsCenter instance using the method you prefer, such as NFS mount or rysnc.
For instructions on backing up the active OpsCenter instance to the standby instance, see Back up critical configuration data.
-
Create and run an automated script to keep the mirrored directories in sync.
The following examples of cron scripts run rsync to synchronize the configuration directories every 5 minutes:
- Package installation
-
*/5 * * * * /usr/bin/rsync -az /etc/opscenter USER@BACKUP_HOST:/etc/opscenter*/5 * * * * /usr/bin/rsync -az /var/lib/opscenter/ssl USER@BACKUP_HOST:/var/lib/opscenter/ssl - Tarball installation
-
*/5 * * * * /usr/bin/rsync -az install_location/conf USER@BACKUP_HOST:install_location/conf*/5 * * * * /usr/bin/rsync -az install_location/ssl USER@BACKUP_HOST:install_location/ssl
When a failover occurs, you must manually stop the sync scripts on the former primary OpsCenter instance and start the sync scripts on the new primary OpsCenter instance. Failure to do so will result in configuration changes on the new primary OpsCenter instance being overwritten by stale files from the former primary OpsCenter instance.
-
Optional: Customize the failover configuration properties in the
[failover]section of theopscenterd.conffile.[failover] heartbeat_period = 20 heartbeat_reply_period = 360 heartbeat_fail_window = 120 failover_configuration_directory = /myrsyncdir/opscenter/failover/ override_primary_redirect_url = https://opscenter:9999 -
If you modified
opscenterd.conf, Restart OpsCenter to apply the changes. -
On the backup OpsCenter instance, in the failover directory, create a
primary_opscenter_locationconfiguration file that indicates the IP address of the primary OpsCenter daemon to monitor.Create the file at the appropriate location for your installation type:
-
Package installation:
/var/lib/opscenter/failover/primary_opscenter_location -
Tarball installation:
INSTALL_DIRECTORY/failover/primary_opscenter_location
-
-
Make sure the
primary_opscenter_locationfile only contains the IP address of the primary OpsCenter instance and nothing more:cat primary_opscenter_location55.100.200.300 -
Ensure the user running OpsCenter has at least read permission for the
primary_opscenter_locationfile.Before the backup OpsCenter instance can take over as the primary OpsCenter instance, the backup OpsCenter instance deletes the
primary_opscenter_locationfile in the event of a failover. After a failover, re-create theprimary_opscenter_locationfile on the newly designated backup OpsCenter instance.
Maintain failover when upgrading OpsCenter
If failover is enabled, follow the recommended procedure for upgrading OpsCenter to ensure that the upgrade succeeds and failover continues to work after the upgrade.
Troubleshoot failover
In most cases, the backup OpsCenter instance selects the correct IP address for reconfiguring agents after a failover as described in Failover behavior.
If for some reason the incorrect IP address is not automatically selected to update all agents, explicitly set the report_interface property in opscenterd.conf on the backup OpsCenter instance.
The location of the opscenterd.conf file depends on the type of installation:
-
Package installations:
/etc/opscenter/opscenterd.conf -
Tarball installations:
INSTALL_DIRECTORY/conf/opscenterd.conf
This workaround assumes the snitch is not Ec2MultiRegionSnitch.