Skip to content

Replication and Failover ​

A domain's server, the primary, can keep a copy of the domain on a backup server. The primary sends every change to the backup as it happens: critical files as they are written, and every database write, in order. If the primary is lost, you promote the backup, and it restarts as the domain's primary.

Promotion is manual. There is no automatic failover.

Replication needs module-replication (or module-all) in the primary's license. The backup needs no license.

Setting Up a Backup ​

In the steps below, the primary is xonasrv1, serving the domain xonaprd, and the backup is xonasrv2.

Step 1. Install the Backup Server ​

Install Situate on the backup machine using the server installation instructions. It should meet the same requirements as the primary.

When the installer asks what kind of server to install, enter b for BACKUP:

Enter (p) for PRIMARY, (b) for BACKUP: b

A backup server asks for no domain, admin user or license. It doesn't run a domain or a web server; it only receives replicated data.

The installer then asks for the replication port. The default is 14002.

Step 2. Open the Replication Port ​

The primary connects to the backup on the replication port. Allow TCP connections from the primary to the backup on that port (14002 by default). Nothing connects the other way.

Step 3. Add the Backup to the Domain ​

Add the backup server to the primary's domain as you would any other asset. See Managing Assets. This gives the backup the domain's server certificate, and from then on the backup accepts that domain's data.

Step 4. Turn On Replication ​

In the object browser, right-click the domain and select Domain Settings. On the Settings screen, under Replication, check Replicate this domain to a backup server, choose the backup's asset in Asset, and click Save.

The primary first sends the backup its critical files and its database, then sends every change as it happens. Watch the progress in the replication status below the settings; see Replication Status. Wait until the status shows Up to date. Until then, the backup doesn't have a complete copy of the database.

Step 5. Give the Backup a sit2- DNS Name ​

The UI looks for a domain's server at sit-<domain>, then sit2-<domain>, then sit3-<domain>, and uses the first one that is the domain's primary. Give the backup the DNS name sit2-<domain> (in our example, sit2-xonaprd), and users won't need a DNS change after a failover.

What Is and Isn't Replicated ​

  • One backup server can back up several domains. It keeps each domain's copy separately, under replica/<domain>/ in its install directory.
  • Writes made directly through the database port, for example with dbmgr.sh, aren't replicated.

Failing Over ​

After making sure the primary is down, run this on the backup:

bash
sudo /opt/situate/bin/situatectl promote xonaprd

For an instance other than the default, add -instance <instance> before promote.

The backup restarts as the domain's primary. Its data is current up to the last change it acknowledged. Workflow instances that were running on the old primary show as FAILED_SITUATE_RESTART.

promote refuses if the backup's copy of the database isn't known to be complete, for example because the first copy never finished. To promote anyway, add --force; older history may be missing.

After promotion:

  • Users: if the backup has a sit2-<domain> DNS name, the UI finds it with no change.
  • Agents: agents connect to the host name they are configured with. Point them, or the sit-<domain> alias, at the new primary.
  • Other domains: the server keeps backing up any other domains it backs up. A server can be primary for only one domain, so it can be promoted for only one domain at a time.

The promote steps are logged to logs/replica-switch.log. If any step fails, everything is put back and Situate starts in its old role.

When the Old Primary Comes Back ​

Before it starts any work, a primary asks its backup whether the backup has been promoted:

AnswerWhat happens
The backup was promotedThe old primary demotes itself and restarts as a backup. Its old data is set aside in replica/<domain>.stale-<timestamp>; it isn't merged
The backup is still a backupThe primary starts normally
No answer within 10 secondsThe primary assumes it is still the primary and starts normally
The backup is also a primary, but not a newer oneThe primary starts, and raises a "Two primary servers" alert

If a running primary reconnects to a backup that has been promoted in the meantime, it pauses its queues and demotes itself the same way.

Switching Back ​

To move the domain back to the original server, with A the old primary (now a backup) and B the current primary:

  1. Start A. It demotes itself and becomes a backup (see above).
  2. On B, turn on replication with A as the backup asset. Wait until B's replication status shows Up to date. A still has most of the database, so only the parts that differ are sent.
  3. On B, run situatectl switchover <domain>. B pauses its queues, lets running workflow instances finish (up to 5 minutes), waits until A has acknowledged every change, then restarts as a backup. If A doesn't catch up within 10 minutes, the switchover is abandoned and B's queues resume.
  4. On A, run situatectl promote <domain>.
  5. On A, turn on replication with B as the backup asset.

situatectl demote <domain> turns a primary into a backup without the switchover's checks. Use switchover for a planned hand-off.

Workload Automation and Orchestration