CentOS7 MySQLのフェイルオーバー環境を構築する

シェアする

MySQLのフェイルオーバー環境を構築します。

MySQLのフェイルオーバー環境を実現するには、MySQLのレプリケーション機能と「MHA for MySQL」を使います。

「MHA(Master HA) for MySQL」とは、レプリケーションされた構成のマスターサーバをHA化するためのツールです。

MHA for MySQLについては、下記のURLを参照。
 https://code.google.com/p/mysql-master-ha/

環境

構築する環境を判りやすくするため、サーバは4台構成にすることにします。
下記が、それぞれのサーバごとの役割です。 

ms00・・・・・・MHAマネージャーノード
ms01・・・・・・MHAノード(マスターサーバ)
ms02・・・・・・MHAノード(スレーブサーバ1)
ms03・・・・・・MHAノード(スレーブサーバ2)

MySQLのインストール

最初に、MySQLをMHAノードとなるサーバにインストールを行ないます。

  • MHAノード(マスターサーバ)
[ms01]# yum list installed | grep maria <LF>
mariadb-libs.x86_64    1:5.5.44-1.el7_1    @updates
[ms01]
# yum -y remove mariadb-libs <LF> <= MySQLを利用するので削除
    :
Removed:
  mariadb-libs.x86_64 1:5.5.44-1.el7_1
 
Dependency Removed:
  postfix.x86_64 2:2.10.1-6.el7
 
Complete!
[ms01]# yum -y install wget <LF> <= MySQLのrepoファイルのパッケージを入手するため
    :
Installed:
  wget.x86_64 0:1.14-10.el7_0.1
 
Complete!
[ms01]# cd /tmp <LF>
[ms01]# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm <LF>
    :
2015-11-07 ... - ‘mysql-community-release-el7-5.noarch.rpm’ saved [6140/6140]
[ms01]# yum -y install mysql-community-release-el7-5.noarch.rpm <LF>
    :
Installed:
  mysql-community-release.noarch 0:el7-5
 
Complete!
[ms01]# yum info mysql-community-server <LF>
    :
Available Packages
Name    : mysql-community-server
Arch    : x86_64
Version : 5.6.27
Release : 2.el7
Size    : 58 M
Repo    : mysql56-community/x86_64
    :
[ms01]# yum -y install mysql-community-server <LF> <= MySQLのインストール
    :
Installed:
  mysql-community-server.x86_64 0:5.6.27-2.el7
 
Dependency Installed:
  mysql-community-client.x86_64 0:5.6.27-2.el7
  mysql-community-common.x86_64 0:5.6.27-2.el7
  mysql-community-libs.x86_64 0:5.6.27-2.el7
  net-tools.x86_64 0:2.0-0.17.20131004git.el7
  perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7
  perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7
  perl-DBI.x86_64 0:1.627-4.el7
  perl-Data-Dumper.x86_64 0:2.145-3.el7
  perl-IO-Compress.noarch 0:2.061-2.el7
  perl-Net-Daemon.noarch 0:0.48-5.el7
  perl-PlRPC.noarch 0:0.2020-14.el7
 
Complete!
[ms01]# systemctl disable mysqld <LF> <= 構築中は、自動起動しないようにする
rm '/etc/systemd/system/multi-user.target.wants/mysqld.service'
rm '/etc/systemd/system/mysql.service'
  • MHAノード(スレーブサーバ1)
[ms02]# yum -y remove mariadb-libs <LF>
    :
Removed:
  mariadb-libs.x86_64 1:5.5.44-1.el7_1
 
Dependency Removed:
  postfix.x86_64 2:2.10.1-6.el7
 
Complete!
[ms02]# yum -y install wget <LF>
    :
Installed:
  wget.x86_64 0:1.14-10.el7_0.1
 
Complete!
[ms02]# cd /tmp <LF>
[ms02]# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm <LF>
    :
2015-11-07 ... - ‘mysql-community-release-el7-5.noarch.rpm’ saved [6140/6140]
[ms02]# yum -y install mysql-community-release-el7-5.noarch.rpm <LF>
    :
Installed:
  mysql-community-release.noarch 0:el7-5
 
Complete!
[ms02]# yum info mysql-community-server <LF>
    :
Available Packages
Name    : mysql-community-server
Arch    : x86_64
Version : 5.6.27
Release : 2.el7
Size    : 58 M
Repo    : mysql56-community/x86_64
    :
[ms02]# yum -y install mysql-community-server <LF>
    :
Installed:
  mysql-community-server.x86_64 0:5.6.27-2.el7
 
Dependency Installed:
  mysql-community-client.x86_64 0:5.6.27-2.el7
  mysql-community-common.x86_64 0:5.6.27-2.el7
  mysql-community-libs.x86_64 0:5.6.27-2.el7
  net-tools.x86_64 0:2.0-0.17.20131004git.el7
  perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7
  perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7
  perl-DBI.x86_64 0:1.627-4.el7
  perl-Data-Dumper.x86_64 0:2.145-3.el7
  perl-IO-Compress.noarch 0:2.061-2.el7
  perl-Net-Daemon.noarch 0:0.48-5.el7
  perl-PlRPC.noarch 0:0.2020-14.el7
 
Complete!
[ms02]# systemctl disable mysqld <LF>
rm '/etc/systemd/system/multi-user.target.wants/mysqld.service'
rm '/etc/systemd/system/mysql.service'
  • MHAノード(スレーブサーバ2)
[ms03]# yum -y remove mariadb-libs <LF>
    :
Removed:
  mariadb-libs.x86_64 1:5.5.44-1.el7_1
 
Dependency Removed:
  postfix.x86_64 2:2.10.1-6.el7
 
Complete!
[ms03]# yum -y install wget <LF>
    :
Installed:
  wget.x86_64 0:1.14-10.el7_0.1
 
Complete!
[ms03]# cd /tmp <LF>
[ms03]# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm <LF>
    :
2015-11-07 ... - ‘mysql-community-release-el7-5.noarch.rpm’ saved [6140/6140]
[ms03]# yum -y install mysql-community-release-el7-5.noarch.rpm <LF>
    :
Installed:
  mysql-community-release.noarch 0:el7-5
 
Complete!
[ms03]# yum info mysql-community-server <LF>
    :
Available Packages
Name    : mysql-community-server
Arch    : x86_64
Version : 5.6.27
Release : 2.el7
Size    : 58 M
Repo    : mysql56-community/x86_64
    :
[ms03]# yum -y install mysql-community-server <LF>
    :
Installed:
  mysql-community-server.x86_64 0:5.6.27-2.el7
 
Dependency Installed:
  mysql-community-client.x86_64 0:5.6.27-2.el7
  mysql-community-common.x86_64 0:5.6.27-2.el7
  mysql-community-libs.x86_64 0:5.6.27-2.el7
  net-tools.x86_64 0:2.0-0.17.20131004git.el7
  perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7
  perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7
  perl-DBI.x86_64 0:1.627-4.el7
  perl-Data-Dumper.x86_64 0:2.145-3.el7
  perl-IO-Compress.noarch 0:2.061-2.el7
  perl-Net-Daemon.noarch 0:0.48-5.el7
  perl-PlRPC.noarch 0:0.2020-14.el7
 
Complete!
[ms03]# systemctl disable mysqld <LF>
rm '/etc/systemd/system/multi-user.target.wants/mysqld.service'
rm '/etc/systemd/system/mysql.service'

SSH設定

MySQL-MHAを動作させるために、鍵交換方式(パスワード無し)で互いのサーバ間でSSH接続ができるようにする必要があります。
この後の構築時操作を便利にするためにも、この段階で設定します。

  • MHAマネージャーノード
[ms00]# ssh-keygen -f /root/.ssh/id_rsa -q -N "" <LF>
[ms00]# ls -l /root/.ssh/* <LF>
-rw-------. 1 root root 1679 Nov  7 07:33 /root/.ssh/id_rsa <= 秘密鍵
-rw-r--r--. 1 root root  414 Nov  7 07:33 /root/.ssh/id_rsa.pub <= 公開鍵
[ms00]# mv /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys <LF>
[ms00]# chmod 400 /root/.ssh/authorized_keys <LF>
[ms00]# chmod 400 /root/.ssh/id_rsa <LF>
[ms00]# ssh ms01 "mkdir /root/.ssh" <LF> <= ディレクトリ作成
root@ms01's password: rootpass
[ms00]# ssh ms02 "mkdir /root/.ssh" <LF>
root@ms02's password: rootpass
[ms00]# ssh ms03 "mkdir /root/.ssh" <LF>
root@ms03's password: rootpass
[ms00]# scp /root/.ssh/id_rsa ms01:/root/.ssh <LF> <= 秘密鍵の配置
root@ms01's password: rootpass
id_rsa  100%  1600     0.4KB/s   00:00
[ms00]# scp /root/.ssh/id_rsa ms02:/root/.ssh <LF>
root@ms02's password: rootpass
id_rsa  100%  1600     0.4KB/s   00:00
[ms00]# scp /root/.ssh/id_rsa ms03:/root/.ssh <LF>
root@ms03's password: rootpass
id_rsa  100%  1600     0.4KB/s   00:00
[ms00]# scp /root/.ssh/authorized_keys ms01:/root/.ssh <LF> <= 公開鍵の配置
root@ms01's password: rootpass
authorized_keys   100%  400     0.4KB/s   00:00
[ms00]# scp /root/.ssh/authorized_keys ms02:/root/.ssh <LF>
root@ms02's password: rootpass
authorized_keys   100%  400     0.4KB/s   00:00
[ms00]# scp /root/.ssh/authorized_keys ms03:/root/.ssh <LF>
root@ms03's password: rootpass
authorized_keys   100%  400     0.4KB/s   00:00
[ms00]# ssh ms01 "chmod 400 /root/.ssh/id_rsa" <LF> <= 秘密鍵のパーミッション変更
[ms00]# ssh ms02 "chmod 400 /root/.ssh/id_rsa" <LF>
[ms00]# ssh ms03 "chmod 400 /root/.ssh/id_rsa" <LF>
[ms00]# ssh ms01 "chmod 400 /root/.ssh/authorized_keys" <LF> <= 公開鍵のパーミッション変更
[ms00]# ssh ms02 "chmod 400 /root/.ssh/authorized_keys" <LF>
[ms00]# ssh ms03 "chmod 400 /root/.ssh/authorized_keys" <LF>

レプリケーション環境設定

・MHAノード(マスターサーバ)

[ms01]# systemctl start mysqld <LF> <= MySQL起動
[ms01]# systemctl status mysqld <LF>
mysqld.service - MySQL Community Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled)
   Active: active (running) since Sat 2015-11-07 08:40:07 JST; 39s ago
    :
[ms01]# ls -l /var/lib/mysql <LF> <= 作成されたファイル確認
total 110604
-rw-rw----. 1 mysql mysql       56 Nov  7 08:40 auto.cnf
-rw-rw----. 1 mysql mysql 12582912 Nov  7 08:40 ibdata1
-rw-rw----. 1 mysql mysql 50331648 Nov  7 08:40 ib_logfile0
-rw-rw----. 1 mysql mysql 50331648 Nov  7 08:39 ib_logfile1
drwx------. 2 mysql mysql     4096 Nov  7 08:40 mysql
srwxrwxrwx. 1 mysql mysql        0 Nov  7 08:40 mysql.sock
drwx------. 2 mysql mysql     4096 Nov  7 08:40 performance_schema
[ms01]# mysql -u root <LF>
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.27 MySQL Community Server (GPL)
    :
mysql> update mysql.user set password=password('rootpass') where user = 'root';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4  Changed: 4  Warnings: 0
mysql> flush privileges; <= 権限情報の再読み込み
Query OK, 0 rows affected (0.00 sec)
mysql> quit;
Bye
[ms01]# mysql -u root -p <LF>
Enter password: rootpass <= 設定したパスワードでログイン
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.27 MySQL Community Server (GPL)
    :
mysql> quit;
Bye
[ms01]# mysql_secure_installation <LF>
 
 
 
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
 
In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
 
Enter current password for root (enter for none): rootpass
OK, successfully used password, moving on...
 
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
 
You already have a root password set, so you can safely answer 'n'.
 
Change the root password? [Y/n] n
 ... skipping.
 
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.
 
Remove anonymous users? [Y/n] Y
 ... Success!
 
Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.
 
Disallow root login remotely? [Y/n] Y
 ... Success!
 
By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.
 
Remove test database and access to it? [Y/n] Y
 - Dropping test database...
ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist
 ... Failed!  Not critical, keep moving...
 - Removing privileges on test database...
 ... Success!
 
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
 
Reload privilege tables now? [Y/n] Y
 ... Success!
 
 
 
 
All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.
 
Thanks for using MySQL!
 
 
Cleaning up...
[ms01]# mysql -u root -p <LF>
Enter password: rootpass
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.27 MySQL Community Server (GPL)
    :
mysql> show databases; <= インストール直後の状態を見ておく
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.01 sec)
 
mysql> select user,host from mysql.user; <= インストール直後の状態を見ておく
+------+-----------+
| user | host      |
+------+-----------+
| root | 127.0.0.1 |
| root | ::1       |
| root | localhost |
+------+-----------+
3 rows in set (0.00 sec)
 
mysql> grant replication slave on *.* to 'repluser'@'192.168.1.%' identified by 'replpass';
Query OK, 0 rows affected (0.00 sec)
 
mysql> grant all privileges on *.* to 'root'@'192.168.1.%' identified by 'rootpass';
Query OK, 0 rows affected (0.01 sec)
 
mysql> select user,host from mysql.user;
+----------+-------------+
| user     | host        |
+----------+-------------+
| root     | 127.0.0.1   |
| repluser | 192.168.1.% | <= 作成したユーザー
| root     | 192.168.1.% | <= 作成したユーザー
| root     | ::1         |
| root     | localhost   |
+----------+-------------+
4 rows in set (0.00 sec)
  
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
 
mysql> quit;
Bye
[ms01]# cp -p /etc/my.cnf /etc/my.cnf.original <LF>
[ms01]# vim /etc/my.cnf <LF>
[mysqld]
    :
log-bin=mysqld-bin <= バイナリログの有効化
server-id=11 <= サーバごとにユニークな番号
    :
[ms01]# systemctl restart mysqld <LF> <= my.cnfの設定を有効にするため再起動
[ms01]# mysql -u root -p <LF>
Enter password: rootpass
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.27 MySQL Community Server (GPL)
    :
mysql> install plugin rpl_semi_sync_master soname 'semisync_master.so';
Query OK, 0 rows affected (0.01 sec)
 
mysql> install plugin rpl_semi_sync_slave soname 'semisync_slave.so';
Query OK, 0 rows affected (0.00 sec)
 
mysql> show plugins;
+----------------------+--------+----------------+--------------------+---------+
| Name                 | Status | Type           | Library            | License |
+----------------------+--------+----------------+--------------------+---------+
| binlog               | ACTIVE | STORAGE ENGINE | NULL               | GPL     |
|   :                  |   :    |   :            |  :                 |  :      |
| partition            | ACTIVE | STORAGE ENGINE | NULL               | GPL     |
| rpl_semi_sync_master | ACTIVE | REPLICATION    | semisync_master.so | GPL     | <= 確認
| rpl_semi_sync_slave  | ACTIVE | REPLICATION    | semisync_slave.so  | GPL     | <= 確認
+----------------------+--------+----------------+--------------------+---------+
44 rows in set (0.00 sec)
 
mysql> quit;
Bye
[ms01]# vim /etc/my.cnf <LF>
[mysqld]
    :
log-bin=mysqld-bin
server-id=11
rpl_semi_sync_master_enabled=1 <= 準同期のマスター用プラグイン有効化
rpl_semi_sync_slave_enabled=1 <= 準同期のスレーブ用プラグイン有効化
    :
[ms01]# systemctl restart mysqld <LF> <= my.cnfの設定を有効にするため再起動
[ms01]# mysql -u root -p <LF>
Enter password: rootpass
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.27-log MySQL Community Server (GPL)
    :
mysql> show global variables like "rpl_semi_sync_master%";
+------------------------------------+-------+
| Variable_name                      | Value |
+------------------------------------+-------+
| rpl_semi_sync_master_enabled       | ON    | <= 確認
| rpl_semi_sync_master_timeout       | 10000 |
| rpl_semi_sync_master_trace_level   | 32    |
| rpl_semi_sync_master_wait_no_slave | ON    |
+------------------------------------+-------+
4 rows in set (0.00 sec)
 
mysql> flush tables with read lock; <= 更新系クエリーを抑止(参照系クエリーは抑止されない)
Query OK, 0 rows affected (0.00 sec)
 
mysql> quit;
Bye
[ms01]# cd / && tar zcf /tmp/var_lib_mysql.tar.gz ./var/lib/mysql <LF> <= バックアップ
tar: ./var/lib/mysql/mysql.sock: socket ignored
[ms01]# mysql -u root -p <LF>
Enter password: rootpass
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.27-log MySQL Community Server (GPL)
    :
mysql> show master status\G
*************************** 1. row ***************************
             File: mysqld-bin.000002  <= 重要(メモをとっておく)
         Position: 120                <= 重要(メモをとっておく)
     Binlog_Do_DB:
 Binlog_Ignore_DB:
Executed_Gtid_Set:
1 row in set (0.00 sec)
 
mysql> unlock tables; <= 更新系クエリーを解除
Query OK, 0 rows affected (0.00 sec)
 
mysql> quit;
Bye
[ms01]# scp /tmp/var_lib_mysql.tar.gz ms02:/tmp <= スレーブサーバ1にコピー
var_lib_mysql.tar.gz   100%  720KB 720.2KB/s   00:00    
[ms01]# scp /tmp/var_lib_mysql.tar.gz ms03:/tmp <= スレーブサーバ2にコピー
var_lib_mysql.tar.gz   100%  720KB 720.2KB/s   00:00
  • MHAノード(スレーブサーバ1)
[ms02]# systemctl start mysqld <LF>
[ms02]# systemctl status mysqld <LF>
mysqld.service - MySQL Community Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled)
   Active: active (running) since Sun 2015-11-08 12:18:50 JST; 10s ago
    :
[ms02]# ls -l /var/lib/mysql <LF>
total 110604
-rw-rw----. 1 mysql mysql       56 Nov  8 12:18 auto.cnf
-rw-rw----. 1 mysql mysql 12582912 Nov  8 12:18 ibdata1
-rw-rw----. 1 mysql mysql 50331648 Nov  8 12:18 ib_logfile0
-rw-rw----. 1 mysql mysql 50331648 Nov  8 12:18 ib_logfile1
drwx------. 2 mysql mysql     4096 Nov  8 12:18 mysql
srwxrwxrwx. 1 mysql mysql        0 Nov  8 12:18 mysql.sock
drwx------. 2 mysql mysql     4096 Nov  8 12:18 performance_schema
[ms02]# systemctl stop mysqld <LF>
[ms02]# mv /var/lib/mysql /var/lib/mysql.gomi <LF> <= 退避(いらない)
[ms02]# cd / && tar zxf /tmp/var_lib_mysql.tar.gz <LF> <= アーカイブの展開
[ms02]# ls -l /var/lib/mysql <LF>
total 110612
-rw-rw----. 1 mysql mysql       56 Nov  7 08:40 auto.cnf <= UUIDが被るので不要(再起動で自動作成)
-rw-rw----. 1 mysql mysql 12582912 Nov  8 12:05 ibdata1
-rw-rw----. 1 mysql mysql 50331648 Nov  8 12:05 ib_logfile0
-rw-rw----. 1 mysql mysql 50331648 Nov  7 08:39 ib_logfile1
drwx------. 2 mysql mysql     4096 Nov  7 08:40 mysql
-rw-rw----. 1 mysql mysql      143 Nov  8 12:05 mysqld-bin.000001 <= 不要
-rw-rw----. 1 mysql mysql      143 Nov  8 12:05 mysqld-bin.000002 <= 不要
-rw-rw----. 1 mysql mysql       20 Nov  8 12:05 mysqld-bin.index <= 不要
drwx------. 2 mysql mysql     4096 Nov  7 08:40 performance_schema
[ms02]# \rm /var/lib/mysql/*-bin.?????? <LF>
[ms02]# \rm /var/lib/mysql/*-bin.index <LF>
[ms02]# mv /var/lib/mysql/auto.cnf /var/lib/mysql/auto.cnf.original <LF>
[ms02]# cp -p /etc/my.cnf /etc/my.cnf.original <LF>
[ms02]# vim /etc/my.cnf <LF>
    :
log-bin=mysqld-bin
server-id=12
    :
[ms02]# systemctl start mysqld <LF>
[ms02]# mysql -u root -p <LF>
Enter password: rootpass <= コピーしているのでパスワードは設定された状態
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.27-log MySQL Community Server (GPL)
    :
mysql> show plugins;
+----------------------+--------+----------------+--------------------+---------+
| Name                 | Status | Type           | Library            | License |
+----------------------+--------+----------------+--------------------+---------+
| binlog               | ACTIVE | STORAGE ENGINE | NULL               | GPL     |
|   :                  |   :    |   :            |  :                 |  :      |
| partition            | ACTIVE | STORAGE ENGINE | NULL               | GPL     |
| rpl_semi_sync_master | ACTIVE | REPLICATION    | semisync_master.so | GPL     | <= 確認
| rpl_semi_sync_slave  | ACTIVE | REPLICATION    | semisync_slave.so  | GPL     | <= 確認
+----------------------+--------+----------------+--------------------+---------+
43 rows in set (0.00 sec)
 
mysql> quit;
Bye
[ms02]# vim /etc/my.cnf <LF>
    :
log-bin=mysqld-bin
server-id=12
rpl_semi_sync_master_enabled=1 <= 準同期のマスター用プラグイン有効化
rpl_semi_sync_slave_enabled=1 <= 準同期スレーブ用のプラグイン有効化
    :
[ms02]# systemctl restart mysqld <LF>
[ms02]# mysql -u root -p <LF>
Enter password: rootpass
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.27-log MySQL Community Server (GPL)
    :
mysql> show global variables like "rpl_semi_sync_slave%";
+---------------------------------+-------+
| Variable_name                   | Value |
+---------------------------------+-------+
| rpl_semi_sync_slave_enabled     | ON    | <= 確認
| rpl_semi_sync_slave_trace_level | 32    |
+---------------------------------+-------+
2 rows in set (0.00 sec)
 
mysql> change master to
    -> master_host='ms01',
    -> master_user='repluser',
    -> master_password='replpass',
    -> master_log_file='mysqld-bin.000002',
    -> master_log_pos=120;                    <= マスターサーバへの接続情報変更
Query OK, 0 rows affected, 2 warnings (0.36 sec)
 
mysql> show warnings\G  <= ワーニングが出力されるが無視する
*************************** 1. row ***************************
  Level: Note
   Code: 1759
Message: Sending passwords in plain text without SSL/TLS is extremely insecure.
*************************** 2. row ***************************
  Level: Note
   Code: 1760
Message: Storing MySQL user name or password information in the master
         info repository is not secure and is therefore not recommended.
         Please consider using the USER and PASSWORD connection options for START SLAVE;
         see the 'START SLAVE Syntax' in the MySQL Manual for more information.
2 rows in set (0.00 sec)
 
mysql> start slave; <= スレーブスレッドの開始
Query OK, 0 rows affected (0.06 sec)
 
mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: ms01
                  Master_User: repluser
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysqld-bin.000002
          Read_Master_Log_Pos: 120
               Relay_Log_File: mysqld-relay-bin.000002
                Relay_Log_Pos: 284
        Relay_Master_Log_File: mysqld-bin.000002
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
    :
1 row in set (0.00 sec)
 
mysql> quit;
Bye
  • MHAノード(スレーブサーバ2)
[ms03]# systemctl start mysqld <LF>
[ms03]# systemctl status mysqld <LF>
mysqld.service - MySQL Community Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled)
   Active: active (running) since Sun 2015-11-08 12:18:50 JST; 10s ago
    :
[ms03]# ls -l /var/lib/mysql <LF>
total 110604
-rw-rw----. 1 mysql mysql       56 Nov  8 12:18 auto.cnf
-rw-rw----. 1 mysql mysql 12582912 Nov  8 12:18 ibdata1
-rw-rw----. 1 mysql mysql 50331648 Nov  8 12:18 ib_logfile0
-rw-rw----. 1 mysql mysql 50331648 Nov  8 12:18 ib_logfile1
drwx------. 2 mysql mysql     4096 Nov  8 12:18 mysql
srwxrwxrwx. 1 mysql mysql        0 Nov  8 12:18 mysql.sock
drwx------. 2 mysql mysql     4096 Nov  8 12:18 performance_schema
[ms03]# systemctl stop mysqld <LF>
[ms03]# mv /var/lib/mysql /var/lib/mysql.gomi <LF>
[ms03]# cd / && tar zxf /tmp/var_lib_mysql.tar.gz <LF>
[ms03]# ls -l /var/lib/mysql <LF>
total 110612
-rw-rw----. 1 mysql mysql       56 Nov  7 08:40 auto.cnf
-rw-rw----. 1 mysql mysql 12582912 Nov  8 12:05 ibdata1
-rw-rw----. 1 mysql mysql 50331648 Nov  8 12:05 ib_logfile0
-rw-rw----. 1 mysql mysql 50331648 Nov  7 08:39 ib_logfile1
drwx------. 2 mysql mysql     4096 Nov  7 08:40 mysql
-rw-rw----. 1 mysql mysql      120 Nov  8 12:05 mysqld-bin.000001
-rw-rw----. 1 mysql mysql       20 Nov  8 12:05 mysqld-bin.index
drwx------. 2 mysql mysql     4096 Nov  7 08:40 performance_schema
[ms03]# \rm /var/lib/mysql/*-bin.?????? <LF>
[ms03]# \rm /var/lib/mysql/*-bin.index <LF>
[ms03]# mv /var/lib/mysql/auto.cnf /var/lib/mysql/auto.cnf.original <LF>
[ms03]# cp -p /etc/my.cnf /etc/my.cnf.original <LF>
[ms03]# vim /etc/my.cnf <LF>
    :
log-bin=mysqld-bin
server-id=13
    :
[ms03]# systemctl start mysqld <LF>
[ms03]# mysql -u root -p <LF>
Enter password: rootpass
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.27-log MySQL Community Server (GPL)
    :
mysql> show plugins;
+----------------------+--------+----------------+--------------------+---------+
| Name                 | Status | Type           | Library            | License |
+----------------------+--------+----------------+--------------------+---------+
| binlog               | ACTIVE | STORAGE ENGINE | NULL               | GPL     |
|   :                  |   :    |   :            |  :                 |  :      |
| partition            | ACTIVE | STORAGE ENGINE | NULL               | GPL     |
| rpl_semi_sync_master | ACTIVE | REPLICATION    | semisync_master.so | GPL     |
| rpl_semi_sync_slave  | ACTIVE | REPLICATION    | semisync_slave.so  | GPL     |
+----------------------+--------+----------------+--------------------+---------+
44 rows in set (0.00 sec)
 
mysql> quit;
Bye
[ms03]# vim /etc/my.cnf <LF>
    :
log-bin=mysqld-bin
server-id=13
rpl_semi_sync_master_enabled=1
rpl_semi_sync_slave_enabled=1
    :
[ms03]# systemctl restart mysqld <LF>
[ms03]# mysql -u root -p <LF>
Enter password: rootpass
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.27-log MySQL Community Server (GPL)
    :
mysql> show global variables like "rpl_semi_sync_slave%";
+---------------------------------+-------+
| Variable_name                   | Value |
+---------------------------------+-------+
| rpl_semi_sync_slave_enabled     | ON    |
| rpl_semi_sync_slave_trace_level | 32    |
+---------------------------------+-------+
2 rows in set (0.00 sec)
 
mysql> change master to
    -> master_host='ms01',
    -> master_user='repluser',
    -> master_password='replpass',
    -> master_log_file='mysqld-bin.000002',
    -> master_log_pos=120;
Query OK, 0 rows affected, 2 warnings (0.36 sec)
 
mysql> show warnings\G
*************************** 1. row ***************************
  Level: Note
   Code: 1759
Message: Sending passwords in plain text without SSL/TLS is extremely insecure.
*************************** 2. row ***************************
  Level: Note
   Code: 1760
Message: Storing MySQL user name or password information in the master
         info repository is not secure and is therefore not recommended.
         Please consider using the USER and PASSWORD connection options for START SLAVE;
         see the 'START SLAVE Syntax' in the MySQL Manual for more information.
2 rows in set (0.00 sec)
 
mysql> start slave;
Query OK, 0 rows affected (0.08 sec)
 
mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: ms01
                  Master_User: repluser
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysqld-bin.000002
          Read_Master_Log_Pos: 120
               Relay_Log_File: mysqld-relay-bin.000002
                Relay_Log_Pos: 284
        Relay_Master_Log_File: mysqld-bin.000002
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
    :
1 row in set (0.00 sec)
 
mysql> quit;
Bye

MHAのインストール

  • MHAマネージャーノード
[ms00]# yum -y remove mariadb-libs <LF>
    :
Removed:
  mariadb-libs.x86_64 1:5.5.44-1.el7_1
 
Dependency Removed:
  postfix.x86_64 2:2.10.1-6.el7
 
Complete!
[ms00]# yum -y install wget <LF>
    :
Installed:
  wget.x86_64 0:1.14-10.el7_0.1
 
Complete!
[ms00]# cd /tmp <LF>
[ms00]# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm <LF>
    :
2015-11-09 ... - ‘mysql-community-release-el7-5.noarch.rpm’ saved [6140/6140]
[ms00]# yum -y install mysql-community-release-el7-5.noarch.rpm <LF>
    :
[ms00]# yum info mysql-community-server <LF>
    :
Available Packages
Name    : mysql-community-server
Arch    : x86_64
Version : 5.6.27
Release : 2.el7
Size    : 58 M
Repo    : mysql56-community/x86_64
    :
[ms00]# yum -y install mysql-community-server <LF>
    :
Installed:
  mysql-community-server.x86_64 0:5.6.27-2.el7
 
Dependency Installed:
  mysql-community-client.x86_64 0:5.6.27-2.el7
  mysql-community-common.x86_64 0:5.6.27-2.el7
  mysql-community-libs.x86_64 0:5.6.27-2.el7
  net-tools.x86_64 0:2.0-0.17.20131004git.el7
  perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7
  perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7
  perl-DBI.x86_64 0:1.627-4.el7
  perl-Data-Dumper.x86_64 0:2.145-3.el7
  perl-IO-Compress.noarch 0:2.061-2.el7
  perl-Net-Daemon.noarch 0:0.48-5.el7
  perl-PlRPC.noarch 0:0.2020-14.el7
 
Complete!
[ms00]# wget https://72003f4c60f5cc941cd1c7d448fc3c99e0aebaa8.googledrive.com/\
> host/0B1lu97m8-haWeHdGWXp0YVVUSlk/\
> mha4mysql-node-0.57-0.el7.noarch.rpm <LF> <= MHA-Nodeの入手
    :
2015-11-09 ... - ‘mha4mysql-node-0.57-0.el7.noarch.rpm’ saved [35360/35360]
[ms00]# yum -y install mha4mysql-node-0.57-0.el7.noarch.rpm <LF> <= MHA-Nodeインストール
    :
Installed:
  mha4mysql-node.noarch 0:0.57-0.el7
 
Dependency Installed:
  perl-DBD-MySQL.x86_64 0:4.023-5.el7
 
Complete!
[ms00]# wget https://72003f4c60f5cc941cd1c7d448fc3c99e0aebaa8.googledrive.com/\
> host/0B1lu97m8-haWeHdGWXp0YVVUSlk/\
> mha4mysql-manager-0.57-0.el7.noarch.rpm <LF> <= MHA-Managerの入手
    :
2015-11-09 ... - ‘mha4mysql-manager-0.57-0.el7.noarch.rpm’ saved [81080/81080]
[ms00]# yum -y install perl-Parallel-ForkManager --enablerepo=epel <LF> <= 前提パッケージ
    :
Installed:
  perl-Parallel-ForkManager.noarch 0:1.05-1.el7
 
Complete!
[ms00]# yum -y install perl-Log-Dispatch --enablerepo=epel <LF> <= 前提パッケージ
    :
Installed:
  perl-Log-Dispatch.noarch 0:2.41-1.el7.1
 
Dependency Installed:
  perl-Class-Load.noarch 0:0.20-3.el7
  perl-Data-OptList.noarch 0:0.107-9.el7
  perl-Email-Date-Format.noarch 0:1.002-15.el7
  perl-IO-Socket-IP.noarch 0:0.21-4.el7
  perl-IO-Socket-SSL.noarch 0:1.94-3.el7
  perl-List-MoreUtils.x86_64 0:0.33-9.el7
  perl-MIME-Lite.noarch 0:3.030-1.el7
  perl-MIME-Types.noarch 0:1.38-2.el7
  perl-Mail-Sender.noarch 0:0.8.21-2.el7
  perl-Mail-Sendmail.noarch 0:0.79-21.el7
  perl-MailTools.noarch 0:2.12-2.el7
  perl-Module-Implementation.noarch 0:0.06-6.el7
  perl-Module-Runtime.noarch 0:0.013-4.el7
  perl-Net-LibIDN.x86_64 0:0.12-15.el7
  perl-Net-SMTP-SSL.noarch 0:1.01-13.el7
  perl-Net-SSLeay.x86_64 0:1.55-3.el7
  perl-Package-DeprecationManager.noarch 0:0.13-7.el7
  perl-Package-Stash.noarch 0:0.34-2.el7
  perl-Package-Stash-XS.x86_64 0:0.26-3.el7
  perl-Params-Util.x86_64 0:1.07-6.el7
  perl-Params-Validate.x86_64 0:1.08-4.el7
  perl-Sub-Install.noarch 0:0.926-6.el7
  perl-Sys-Syslog.x86_64 0:0.33-3.el7
  perl-TimeDate.noarch 1:2.30-2.el7
  perl-Try-Tiny.noarch 0:0.12-2.el7
 
Complete!
[ms00]# yum -y install mha4mysql-manager-0.57-0.el7.noarch.rpm <LF> <= MHA-Managerインストール
    :
Installed:
  mha4mysql-manager.noarch 0:0.57-0.el7
 
Dependency Installed:
  perl-Config-Tiny.noarch 0:2.14-7.el7
 
Complete!
[ms00]# mkdir /var/lib/mysqlmha <LF> <= MHAの作業ディレクトリ
[ms00]# mkdir /var/log/mysqlmha <LF> <= MHAのログ出力ディレクトリ
  • MHAノード(マスターサーバ)
[ms01]# cd /tmp <LF>
[ms01]# wget https://72003f4c60f5cc941cd1c7d448fc3c99e0aebaa8.googledrive.com/\
> host/0B1lu97m8-haWeHdGWXp0YVVUSlk/\
> mha4mysql-node-0.57-0.el7.noarch.rpm <LF> <= MHA-Nodeの入手
    :
2015-11-09 ... - ‘mha4mysql-node-0.57-0.el7.noarch.rpm’ saved [35360/35360]
[ms01]# yum -y install mha4mysql-node-0.57-0.el7.noarch.rpm <LF> <= MHA-Nodeインストール
    :
Installed:
  mha4mysql-node.noarch 0:0.57-0.el7
 
Dependency Installed:
  perl-DBD-MySQL.x86_64 0:4.023-5.el7
 
Complete!
[ms01]# mkdir /var/lib/mysqlmha <LF>
[ms01]# mkdir /var/log/mysqlmha <LF>
  • MHAノード(スレーブサーバ1)
[ms02]# cd /tmp <LF>
[ms02]# wget https://72003f4c60f5cc941cd1c7d448fc3c99e0aebaa8.googledrive.com/\
> host/0B1lu97m8-haWeHdGWXp0YVVUSlk/\
> mha4mysql-node-0.57-0.el7.noarch.rpm <LF> <= MHA-Nodeの入手
    :
2015-11-09 ... - ‘mha4mysql-node-0.57-0.el7.noarch.rpm’ saved [35360/35360]
[ms02]# yum -y install mha4mysql-node-0.57-0.el7.noarch.rpm <LF> <= MHA-Nodeインストール
    :
Installed:
  mha4mysql-node.noarch 0:0.57-0.el7
 
Dependency Installed:
  perl-DBD-MySQL.x86_64 0:4.023-5.el7
 
Complete!
[ms02]# mkdir /var/lib/mysqlmha <LF>
[ms02]# mkdir /var/log/mysqlmha <LF>
  • MHAノード(スレーブサーバ2)
[ms03]# cd /tmp <LF>
[ms03]# wget https://72003f4c60f5cc941cd1c7d448fc3c99e0aebaa8.googledrive.com/\
> host/0B1lu97m8-haWeHdGWXp0YVVUSlk/\
> mha4mysql-node-0.57-0.el7.noarch.rpm <LF> <= MHA-Nodeの入手
    :
2015-11-09 ... - ‘mha4mysql-node-0.57-0.el7.noarch.rpm’ saved [35360/35360]
[ms03]# yum -y install mha4mysql-node-0.57-0.el7.noarch.rpm <LF> <= MHA-Nodeインストール
    :
Installed:
  mha4mysql-node.noarch 0:0.57-0.el7
 
Dependency Installed:
  perl-DBD-MySQL.x86_64 0:4.023-5.el7
 
Complete!
[ms03]# mkdir /var/lib/mysqlmha <LF>
[ms03]# mkdir /var/log/mysqlmha <LF>

MHA設定

MHAの動作定義を設定します。

[ms00]# vim /etc/mysqlmha.conf <LF>
[server default]
user=root
password=rootpass
manager_workdir=/var/lib/mysqlmha
manager_log=/var/log/mysqlmha/mha.log
remote_workdir=/var/lib/mysqlmha
repl_user=repluser
repl_password=replpass
ssh_user=root
 
[server1]
hostname=ms01
[server2]
hostname=ms02
[server3]
hostname=ms03
[ms00]# chmod 600 /etc/mysqlmha.conf <LF>
[ms00]# touch /etc/masterha_default.cnf <LF>
[ms00]# masterha_check_ssh --conf=/etc/mysqlmha.conf <LF> <= SSH設定の確認
    :
 - [info] All SSH connection tests passed successfully.
[ms00]# masterha_check_repl --conf=/etc/mysqlmha.conf <LF> <= レプリケーション設定の確認
    :
ms01(192.168.1.221:3306) (current master)
 +--ms02(192.168.1.222:3306)
 +--ms03(192.168.1.223:3306)
    :
MySQL Replication Health is OK. <= 確認

 MHA Manager起動と動作確認

ノードが全て稼働している状態で起動します。

[ms00]masterha_manager --conf=/etc/mysqlmha.conf & <LF>
[1] 11182
 - [info] Reading default configuration from /etc/masterha_default.cnf..
 - [info] Reading application default configuration from /etc/mysqlmha.conf..
 - [info] Reading server configuration from /etc/mysqlmha.conf..
[ms00]# ps -ef | grep masterha | grep -v grep <LF>
root 11188 11169 0 03:53 ... perl /usr/bin/masterha_manager --conf=/etc/mysqlmha.conf

ここで、マスターサーバを停止してみます。

[ms01]# systemctl stop mysqld <LF>
[ms01]# systemctl status mysqld <LF>
mysqld.service - MySQL Community Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled)
   Active: inactive (dead)
    :

すると、マネージャーノード側の標準出力にバラバラとメッセージが出力されます。
そして、MHA-Managerは役目を終えると停止します。

    :
  Creating /var/lib/mysqlmha if not exists..    ok.
  Checking output directory is accessible or not..    ok.
  Binlog found at /var/lib/mysql, up to mysqld-bin.000002
 - [info] Reading default configuration from /etc/masterha_default.cnf..
 - [info] Reading application default configuration from /etc/mysqlmha.conf..
 - [info] Reading server configuration from /etc/mysqlmha.conf..

[1]+  Done                    masterha_manager --conf=/etc/mysqlmha.conf
[ms00]ls /var/lib/mysqlmha/mysqlmha.failover.complete <LF>
/var/lib/mysqlmha/mysqlmha.failover.complete <= 切替完了となるとゼロバイトファイルができる

出力されたログをみることで、どのような動きをしているかがわかりますが、切替時のポイントとなる部分を見てみます。

[ms00]# view /var/log/mysqlmha/mha.log <LF>
    :
All other slaves should start replication from here.
Statement should be:                       <= 旧マスターをスレーブとする時に便利(実際は1行で出力)
CHANGE MASTER TO
 MASTER_HOST='ms02 or 192.168.1.222',
 MASTER_PORT=3306,
 MASTER_LOG_FILE='mysqld-bin.000001',
 MASTER_LOG_POS=120,
 MASTER_USER='repluser',
 MASTER_PASSWORD='xxx';
    :
----- Failover Report -----

mysqlmha: MySQL Master failover ms01(192.168.1.221:3306) to ms02(192.168.1.222:3306) succeeded

Master ms01(192.168.1.221:3306) is down!
    :

では、旧マスターサーバをスレーブサーバとして起動します。

[ms01]# systemctl start mysqld <LF>
[ms01]# mysql -u root -p <LF>
Enter password: rootpass
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.27-log MySQL Community Server (GPL)
    :
mysql> CHANGE MASTER TO
    ->  MASTER_HOST='ms02',
    ->  MASTER_PORT=3306,
    ->  MASTER_LOG_FILE='mysqld-bin.000001',
    ->  MASTER_LOG_POS=120,
    ->  MASTER_USER='repluser',
    ->  MASTER_PASSWORD='replpass';
Query OK, 0 rows affected, 2 warnings (0.54 sec)
mysql> start slave;
 

Query OK, 0 rows affected (0.08 sec)

次に、MHAも起動します。

[ms00]# masterha_check_ssh --conf=/etc/mysqlmha.conf <LF> <= SSH設定の確認
    :
 - [info] All SSH connection tests passed successfully.
[ms00]# masterha_check_repl --conf=/etc/mysqlmha.conf <LF> <= レプリケーション設定の確認
    :
ms02(192.168.1.222:3306) (current master) <= マスターとスレーブの構成が判ります
 +--ms01(192.168.1.221:3306)
 +--ms03(192.168.1.223:3306)
    :
MySQL Replication Health is OK.
# \rm /var/lib/mysqlmha/mysqlmha.failover.complete <LF> <= 再開する場合は削除必要
# masterha_manager --conf=/etc/mysqlmha.conf & <LF>
- [info] Reading default configuration from /etc/masterha_default.cnf..
- [info] Reading application default configuration from /etc/mysqlmha.conf..
- [info] Reading server configuration from /etc/mysqlmha.conf..

IPアドレスのフェイルオーバー

マスターのフェイルオーバー環境は完成しましたが、このままでは、マスターが切り替わる度に、IPアドレスが変わってしまいますので、仮想IPアドレスを設定して、マスターが切り替わる際に、IPアドレスが移動できるようにします。

[ms01]# ifconfig <LF>
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.131  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::5054:ff:fe52:696c  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:52:69:6c  txqueuelen 1000  (Ethernet)
        RX packets 3079556  bytes 356371808 (339.8 MiB)
        RX errors 0  dropped 758269  overruns 0  frame 0
        TX packets 42800  bytes 3532426 (3.3 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 46  bytes 3993 (3.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 46  bytes 3993 (3.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[ms01]# ifconfig eth0:1 192.168.1.135 netmask 255.255.255.0 up <LF>
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.131  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::5054:ff:fe52:696c  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:52:69:6c  txqueuelen 1000  (Ethernet)
        RX packets 3079556  bytes 356371808 (339.8 MiB)
        RX errors 0  dropped 758269  overruns 0  frame 0
        TX packets 42800  bytes 3532426 (3.3 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0:1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.135  netmask 255.255.255.0  broadcast 192.168.1.255
        ether 52:54:00:52:69:6c  txqueuelen 1000  (Ethernet)

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 46  bytes 3993 (3.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 46  bytes 3993 (3.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

IPアドレスをフェールオーバーするには、IPアドレスを切り替えるためのスクリプトを用意して、定義ファイルにそのスクリプトを指定します。

[ms00]# vim /etc/mysqlmha.conf <LF>
    :
master_ip_failover_script=/usr/bin/master_ipaddr_failover.pl --virtual_ip=192.168.1.135 --orig_master_vip_eth=eth0:1 --new_master_vip_eth=eth0:1
    :

サンプルファイルは、下記のURLを参考にして作成しました。
https://github.com/riywo/MHA-Manager/blob/master/samples/scripts/master_ip_failover