mysqlfailover – Installation and Operations tutorial

by nivas on March 6, 2015

Configuration

 

1) Download the utilities. Python connector is a prerequisite and this needs to be installed along with mysql utilities rpm

wget http://dev.mysql.com/get/Downloads/Connector-Python/mysql-connector-python-2.0.2-1.el6.noarch.rpm

wget http://dev.mysql.com/get/Downloads/MySQLGUITools/mysql-utilities-1.5.3-1.el6.noarch.rpm

 

2) Install the RPMs. “Mysqlfailover –help” will confirm the install of the utilities

rpm –ivh mysql-connector-python-2.0.2-1.el6.noarch.rpm

rpm -ivh mysql-utilities-1.5.3-1.el6.noarch.rpm

 

3) Set the GTID MODE to ON. GTID mode is a prerequisite for mysqlfailover. GTID tracks the transaction IDs for replication instead of tracking log file and position

log-bin=1

gtid_mode=ON

enforce_gtid_consistency=true

log-slave-updates=1

4) Setup replication using change master to command like below. Notice the difference in the change master to statement. We are not giving the binary log file and position

CHANGE MASTER TO

MASTER_HOST = ’104.xxx.xx.xx’,

MASTER_PORT = 3306,

MASTER_USER = ‘slaveuser’,

MASTER_PASSWORD = ‘slavepass’,

MASTER_AUTO_POSITION = 1;

 

5) Setup report host. Report host has to be updated on the slave. You can validate this configuration by issuing “show slave hosts” on the master server

report-host is the variables that needs to be updated in my.cnf on slave

e.g report-host=100.xx.xx.x

 

6) Master-info-repository has to be set to TABLE on slave. Implement the below changes in slave configuration

master-info-repository=TABLE

log-slave-updates=1

 

Operations

 

1)    Checking health: Below command can be issued to check the status of the replication servers. This will connect to all slaves and list the health of each server. If you do not see any of the slave servers please go and fix it

mysqlfailover –master=root:sairam@localhost:3306 –discover-slaves-   login=root:sairam health

 

2)    Testing failover : Run the below command and kill mysql on the master server. Status should automatically get updated and the failover should start . Once failover is successful , old master can be configured to slave manually

 

mysqlfailover –master=root:sairam@localhost:3306 –discover-slaves-login=root:sairam –failover-mode=auto –force

 

3)    Running as daemon : Below command can be used to run in the background. Process will run in the background and initiate the transfer when needed

 

mysqlfailover –master=root:sairam@localhost:3306 –discover-slaves-login=root:sairam –failover-mode=auto –force –deamon start

 

4)    Post failover operations : You can use execute after option to execute post failover actions . For e.g if heartbeat is installed you can initiate failover of virtual IP as a post failover action

 

 

Comments on this entry are closed.

Previous post:

Next post: