Failover parameter in /etc/enswitch/databases.ini

From Integrics Wiki
Jump to: navigation, search

In the configuration file /etc/enswitch/databases.ini the following parameter is available:

failover = yes

This is NOT related to any HA failover setup for the database.

The 'failover' parameter is used to set up failover connections to alternative database addresses that use the same database handle.

An example use case for this would be if a report server was set up to run reports on slave db servers, then 'failover' could be set to yes in order to select a second slave db server, in case the first one was not available.

So, if HA is set for the database system, then the 'failover' parameter has limited functionality.

Multiple machines for the same handle can be configured and Enswitch will read the configuration stanzas sequentially. There is no theoretical limit on how many stanzas can be set with the same handle.

The example below shows the database configuration on a server that uses three db servers with the same database handle.

Setting 'failover = yes' for the db1.example.com host means that if the database connection to db1.example.com fails, then Enswitch will attempt to connect to the next machine (db2.example.com) that is configured for the same handler (select/cdrs).

Setting 'failover = no' for the db2.example.com host means that if the database connection to db2.example.com fails, then Enswitch will not attempt any further connections, even if subsequent stanzas are configured with "failover = yes".

So, in this example if the database connection to db2.example.com fails, then a connection to db3.example.com will not be attempted.

Setting the 'failover' parameter to 'yes' or 'no' on the last host of a handle will not make any difference because Enswitch will not attempt any further connections during that batch of connection attempts and will log an error.

The connection attempts will begin again from the start after 10 secs, as is the standard behavior of Enswitch.

[select/cdrs]
database = enswitch
host = db1.example.com
port = 3306
username = enswitch
password = any
failover = yes

[select/cdrs]
database = enswitch
host = db2.example.com
port = 3306
username = enswitch
password = any
failover = no

[select/cdrs]
database = enswitch
host = db3.example.com
port = 3306
username = enswitch
password = any
failover = yes