Currently Cloud Stack has only one active master DB setup. Going forward it should support multiple Master/Slave cluster setup to enable High Availability of the Database.
To Achieve Active/Active cluster set up (Multiple masters and slaves).
It has the following limitations
We can use Mysql's 2-way replication (Master-Master replication setup) along with connector's configuration to read/write data from one of the slave if master goes down.
#High Availability And Cluster Properties
db.ha.enabled=false (change it to true to enable db ha)
db.ha.loadBalanceStrategy=com.cloud.utils.db.StaticStrategy
#cloud stack Database
db.cloud.slaves=localhost,localhost (Comma separated list of slave hosts)
db.cloud.autoReconnect=true
db.cloud.failOverReadOnly=false
db.cloud.reconnectAtTxEnd=true
db.cloud.autoReconnectForPools=true
db.cloud.secondsBeforeRetryMaster=3600
db.cloud.queriesBeforeRetryMaster=5000
db.cloud.initialTimeout=3600
#usage Database
db.usage.slaves=localhost,localhost (Comma separated list of slave hosts)
db.usage.autoReconnect=true
db.usage.failOverReadOnly=false
db.usage.reconnectAtTxEnd=true
db.usage.autoReconnectForPools=true
db.usage.secondsBeforeRetryMaster=3600
db.usage.queriesBeforeRetryMaster=5000
db.usage.initialTimeout=3600
expire_logs_days=10 (Number of days to keep the bin log files)
max_binlog_size=100M (The max size of each bin log file)
auto_increment_increment = 10
Tells to the mysql node that auto increment values to be incremented by 10 instead of default value 1
For Example, In a table X the last auto incremented value is 10 and the same will be replicated to Slave so offset on both the mysql nodes is 10 and now split brain occurred and MS1 is talking to DB1 and MS2 is talking to DB2 and both get the request to add entry to the table X. Now in DB1 the auto increment value will return 11 and in DB2 the auto increment value will return 20 and both will get synced with each other and new offset will set to 20 on both DB1 and DB2
.
auto_increment_offset = 2
Tells to the mysql node that the starting point of the auto increment column value to be start with.
The second property is relevant only when split brain occurs on fresh setup.
my.cnf Configuration Details (Asynchronous)
The mysql configuration to support DB HA in mysql server is goes into /etc/my.cnf file and varies a little bit between master and slave.
Q: How fast the fail over will happen if master goes down?
A: It is actually the piing time out which controls this factor. The mysql connector property that controls this is "loadBalancePingTimeout".
Currently this property is not exposed through db.properties so it uses the default pint time out value which is 0(Mean no ping time out)
(http://dev.mysql.com/doc/connector-j/en/connector-j-reference-configuration-properties.html)
Q: What Mysql DB Versions are supported when DB HA is enabled?
A: The RHEL/CentOS versions supported by the Current ACS versions will get mysql versions of 5.1.X. So by defualt DB HA is also supported for these mysql versions only.
Q: Asynchronous replication V/S Semi-Synchronous Replication which one to use?
A: As Semi-Synchronous replication is supported by 5.5+ on wards so currently we support only Asynchronous replication only.
Q: How much latency is expected in syncing up when DB-HA is enabled?
A: The Synchronization between 2 master nodes is immediate and latency is depending on the actual network latency between 2 master nodes. There is no parameter to control this. The only thing we can get from master server nodes is how many seconds it is behind the other master server.
The following parameter gives us the above value when we so "Show slave status" on any master mysql prompt : "Seconds_Behind_Master"
(http://dev.mysql.com/doc/refman/5.7/en/show-slave-status.html)
Q: What Network topologies(Same Zone, Multiple Zones) are suggested?
A: .As mentioned in previous question, as long as we make sure the network latency between 2 master nodes is as much less as possible we can use any topology. There are no recommended practices on this in mysql documentation
another way is circular chaining where all can act as master