...
- We will rely on Mysql's Connector properties to achieve Master-Master DB HA
- We need to have at least 2 nodes which are connected through 2-way replication and should be consecutive in connector's url
- The following configuration need to be done in my.cnf of each mysql server to clean up bin log files automatically.
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)
- To change the bin log files location please use the following property in my.cnf of each mysql server
log-bin=/var/lib/mysql/binlog/bin-log (Remember here “bin-log” is the file prefix)
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.
- Master :
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mysqld according to the
# instructions in http://fedoraproject.org/wiki/Systemd
server-id=1
default-storage-engine=InnoDB
character-set-server=utf8
transaction-isolation=READ-COMMITTED
log-bin=mysql-bin
innodb_flush_log_at_trx_commit=1
sync_binlog=1
binlog-format=ROW
#Bin logs cleanup configuration
expiry_logs_days=10
max_binlog_size=100M
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
- Slave
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mysqld according to the
# instructions in http://fedoraproject.org/wiki/Systemd
server-id=2
default-storage-engine = InnoDB
character-set-server = utf8
transaction-isolation = READ-COMMITTED
log-bin=mysql-bin
innodb_flush_log_at_trx_commit=1
sync_binlog=1
binlog-format=ROW
#Parameters to solve split brain problem
auto_increment_increment=10
auto_increment_offset=2
#Bin logs cleanup configuration
expiry_logs_days=10
max_binlog_size=100M
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
Limitations/Things DBHA is not supported
- Currently Monitoring of Slave by admin is not possible
- Monitoring events are not integrated with MSSplit Brain problem will cause the sync issues
Appendix
- What if I want to do a Manual Switch over from Master-1 to Master-2?
- Put a 2 way replication as above and do not enable the db ha in db.properties. I.e put the value false against the following property in db.properties
db.ha.enabled=false
...