Separate database for master and backup gateway?

Is it possible to have different database connections for master and backup gateways, so when master gateway is down, backup gateway will read/write data in different database? These databases are synched for both to have same data.

Not directly, but I can think of a few possible ways to do this.

  1. Look into your database server’s “high-availability” provisioning. Every DB provider calls it something different, but they all generally follow the same mechanism - one IP address/endpoint is provided, which transparently to the application connects to different databases on the backend. If you’ve already got data replication, this should be fairly easy to switch on, and is the recommended approach; this is something databases have already put many, many more hours into testing than we ever could.

For some slightly “hackier” workarounds:

  1. Use the “Failover” DB connection settings. If you make two connections, one to each DB on the master, then in firewall settings or some other config on the backup prevent it from connecting to the “master” DB, it will automatically and transparently fail over to the secondary.
  2. Specify an arbitrary hostname for the (correct) DB connection in the hosts file on both the master and backup. Exact configuration will depend on your OS, but basically, putting something into hosts will tell the local machine to always look for a given host at the specified IP address. So you could have a hosts entry for localdatabase with an IP pointed at whatever’s appropriate. Then set the DB connection on the master to use that custom hostname, which will automatically resolve to the other server on the backup gateway.

Thank you @PGriffith for your reply.
In the 1st option, since we have one endpoint that will be configured in both master and backup Ignition gateways, it will be a DB server that will decide which DB is connected to an active gateway at given point in time. We can not explicitly make connection of a gateway with the database we want. Is this understanding correct?

Yes, that’s correct - it would be up to your database(s) to determine which is active at any given time. This is generally preferred, since the same backing mechanism can also do the data replication between the given instances.

Thanks a lot for your help!