mysql Series -------- mmm HA Cluster

mmm high availability cluster description:

 高可用集群介绍:主备模式,当主不能提供服务的时候备用主机接替它提供服务。

This process is transparent to the client.

First, the preparatory work

1, five preparations linux server: main (192.168.4.122), standby (192.168.4.123)

从(192.168.4.126),从(192.168.4.127),管理主机(192.168.4.128)

Username call the shots from the four hosts: tongbu, Password: 123456

2, each of the primary and standby master-slave mode is made, both made from the server from the standby

3, IP planning, write-vip = 192.168.4.100, read-vip = 192.168.4.101 / 192.168.4.102

Second, the installation configuration Mysql-mmm

1, the installation: first install dependencies: yum -y install perl- *

  cd mysql-mmm-2.2.1/       

  make install     //进入解压后的目录,然后直接安装

2, profile Description: cd / etc / mysql-mmm

 mmm_agent.conf             //数据节点主机文件(四台mysql服务器)

 mmm_common.conf       //公共配置文件 (五台主机都需要)

 mmm_mon.conf            //管理主机文件(192.168.4.128)

 mmm_tools.conf           //管理工具

3, modify the data node configuration file: mmm_agent.conf (four mysql server modifications)

  include mmm_common.conf    //加载文件

 this db1      //定义在集群中的名称

Name planning: According to the role and named ip address

master122,master123,slave126,slave127

4, configuration change management node (192.168.4.128) mmm_mon.conf

1 include mmm_common.conf

 2 

 3 <monitor>

 4         ip                      192.168.4.128                               //监控本机的IP地址

 5         pid_path                /var/run/mmm_mond.pid

 6         bin_path                /usr/lib/mysql-mmm/

 7         status_path             /var/lib/misc/mmm_mond.status

 8         ping_ips                192.168.4.122, 192.168.4.123, 192.168.4.126, 192.168.4.127 //被监控的IP地址

 9 </monitor>

10 

11 <host default>

12         monitor_user                    monitor   //监控数据库的用户名,用来监测四台数据库服务是否正常

13         monitor_password            123456   //上面的用户名需在122那台主机上添加授权

14 </host>

5, modify public profile: mmm_common.conf (five hosts are required)

在一台主机上修改,然后传送给其它四台主机

active_master_role      writer

<host default>

      cluster_interface           eth0

      pid_path                       /var/run/mmm_agentd.pid

      bin_path                       /usr/lib/mysql-mmm/

      replication_user             tongbu     //本机用于主从同步的用户

      replication_password     123456

     agent_user                     agent     //代理程序去检测的用户名

     agent_password             123456

</host>

<host master122>

     ip                              192.168.4.122

     mode                         master     //模式

     peer                           master123  //身份对等的主机

</host>

<host master123>

     ip                              192.168.4.123

     mode                         master

     peer                           master122

</host>

<host slave126>

     ip                              192.168.4.126

     mode                         slave

</host>

<host slave127>

     ip                              192.168.4.127

     mode                         slave

</host>

<role writer>

    hosts                         master122, master123

    ips                             192.168.4.100   //两台主备的虚拟IP

    mode                         exclusive  //独占模式

</role>

<role reader>

    hosts                         slave126, slave127

    ips                             192.168.4.101, 192.168.4.102

    mode                         balanced //均衡模式

</role>

6, add two accounts on the 4.122 authorized host: monitor, agent

grant replication client on . to monitor@'%' identified by '123456';

grant replication client,process,super on . to agent@'%' identified by '123456';

Three, mmm_monitor service on start-up data service node and the management node host

1, installed on the host-initiated five dependencies: The following three tar rpm package or package

 解决启动agent服务的依赖包:

 Algorithm-Diff-1.1902.tar.gz

 perl-Log-Log4perl-1.26-1.el6.rf.noarch.rpm

 Proc-Daemon-0.03.tar.gz

2, mounting the above three packets

   yum -y install gcc  gcc-c++

   cd mysql-mmm/

   tar -zxf Algorithm-Diff-1.1902.tar.gz

   cd Algorithm-Diff-1.1902/

   perl Makefile.PL

   make

   make install

   cd ..

   rpm -ivh perl-Log-Log4perl-1.26-1.el6.rf.noarch.rpm

   tar -zxf Proc-Daemon-0.03.tar.gz

   cd Proc-Daemon-0.03/

   perl Makefile.PL

   make

   make install

3, installation of VIP packages will be retrieved: Net-ARP-1.0.8.tgz (installed on four mysql service)

  gunzip Net-ARP-1.0.8.tgz

  tar -xf Net-ARP-1.0.8.tar

  cd Net-ARP-1.0.8/

  perl Makefile.PL

  make && make install

4, start the agent service: Start on five servers

    /etc/init.d/mysql-mmm-agent start   //启动服务

    netstat -ntulp | grep 9989  //查看端口号,查看服务是否启动

   cat /var/log/mysql-mmm/mmm_agentd.log //启动日志

mmm_monitor service on 5, start the management node host

   /etc/init.d/mysql-mmm-monitor start  //启动

   netstat -ntulp | grep 9988    //查看是否启动

   ls /var/log/mysql-mmm/mmm_mond.log //日志文件

6, on the management host, view the monitoring information: mmm_control show

master122(192.168.4.122) master/AWAITING_RECOVERY. Roles:

master123(192.168.4.123) master/AWAITING_RECOVERY. Roles:

slave126(192.168.4.126) slave/AWAITING_RECOVERY. Roles:

slave127(192.168.4.127) slave/AWAITING_RECOVERY. Roles:

7, set up online: mmm_control set_online need to set four

mmm_control set_online master122

mmm_control set_online master123

mmm_control set_online slave126

mmm_control set_online slave127

After setting View: mmm_control show

master122(192.168.4.122) master/ONLINE. Roles: writer(192.168.4.100)

master123(192.168.4.123) master/ONLINE. Roles:

slave126(192.168.4.126) slave/ONLINE. Roles: reader(192.168.4.101)

slave127(192.168.4.127) slave/ONLINE. Roles: reader(192.168.4.102)

How to view IP:

ip addr show |. grep 192.168.4 // can get to see the two ip address

Fourth, the test

1, add a user to access the database connection in the data nodes, only need to create an account on the 4.122 Authorization

grant all on . to admin@'%' identified by '123456';

2, client test:

mysql -h192.168.4.100 -uadmin -p123456

After landing up, CRUD database, and then four mysql

On the server to verify correct

3, the manual 4.122 mysql this master server stopped,

To see whether the client has access to, CRUD and so on.

After 4,4.122 up manually, you first need to set up online: mmm_control set_online master122

But the VIP corresponding or 4.123, does not automatically switch over,

Must first 4.123: mmm_control set_offline master123,

Such 4.122 will get VIP

Guess you like

Origin blog.51cto.com/14421632/2415095
mmm