High Availability Cluster of mmm, one of mysql series

mmm High Availability Cluster Introduction:

 High Availability Cluster Introduction: The main standby mode, when the main can not provide services, the standby host replaces it to provide services.

This process is transparent to the client.

I. Preparatory Work

1. Prepare five linux servers: master (192.168.4.122), master (192.168.4.123)

From (192.168.4.126), from (192.168.4.127), management host (192.168.4.128)

User name of four hosts as master and slave: tongbu, password: 123456

2. The master and the master and the backup make the master-slave mode mutually, and the two slave servers make the master and backup slave mode mutually.

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

II. Installation and configuration of Mysql-mmm

1. Installation: First install dependency packages: yum-y install perl-*

  cd mysql-mmm-2.2.1/       

  make install     //Enter the unzipped directory and install it directly

2. Configuration file description: cd/etc/mysql-mmm

 mmm_agent.conf             //Data Node Host File (Four mysql Servers)

 mmm_common.conf       //Common Profile (required for all five hosts)

 mmm_mon.conf            //Manage host files (192.168.4.128)

 mmm_tools.conf           //management tool

3. Modify the configuration file of the data node: mmm_agent.conf (four mysql servers modified)

  include mmm_common.conf    //load file

 this db1      //Names defined in clusters

Name planning: Naming by role and ip address

master122,master123,slave126,slave127

4. Modify the configuration of the management node (192.168.4.128)mmm_mon.conf

1 include mmm_common.conf

 2 

 3 <monitor>

 4         ip                      192.168.4.128                               //Monitor IP Address of Local Machine

 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 //Monitored IP Address

 9 </monitor>

10 

11 <host default>

12         monitor_user                    monitor   //User name of monitoring database to monitor whether four database services are normal

13         monitor_password            123456   //The user name above needs to be authorized on 122 hosts

14 </host>

5. Modify the common configuration file: mmm_common.conf (all five hosts need)

Modify it on one host and send it to the other four hosts

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     //Users of this machine for master-slave synchronization

      replication_password     123456

     agent_user                     agent     //User Name Detected by Agent

     agent_password             123456

</host>

<host master122>

     ip                              192.168.4.122

     mode                         master     //Pattern

     peer                           master123  //Identity-peer hosts

</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   //Two backup virtual IP

    mode                         exclusive  //Exclusive Mode

</role>

<role reader>

    hosts                         slave126, slave127

    ips                             192.168.4.101, 192.168.4.102

    mode                         balanced //Equilibrium model

</role>

6. Add two authorization accounts on 4.122 host: monitor, agent

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

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

3. Start Data Node Service and Manage mmm_monitor Service on Node Host

1. Install startup dependency packages on five hosts: the following three rpm packages or tar packages

 Resolve dependency packages that start agent services:

 Algorithm-Diff-1.1902.tar.gz

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

 Proc-Daemon-0.03.tar.gz

2. Install the three packages above

   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. Install the package for obtaining VIP: Net-ARP-1.0.8.tgz (installed on four mysql services)

  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 agent Service: Start on Five Servers

    /etc/init.d/mysql-mmm-agent start   //Start up service

    netstat -ntulp | grep 9989  //Check the port number to see if the service is started

   cat /var/log/mysql-mmm/mmm_agentd.log //start log

5. Start the mmm_monitor service on the host of the management node

   /etc/init.d/mysql-mmm-monitor start  //start-up

   netstat -ntulp | grep 9988    //Check whether to start

   ls /var/log/mysql-mmm/mmm_mond.log //log file

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. Setting up on-line: All four sets of mmm_control set_online need to be set up

mmm_control set_online master122

mmm_control set_online master123

mmm_control set_online slave126

mmm_control set_online slave127

View after setting: 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. // / You can see that you got two ip addresses

IV. Testing

1. Adding a connection user to the data node that accesses the database only needs to create an authorized account on 4.122.

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

2. Client testing:

mysql -h192.168.4.100 -uadmin -p123456

After login, add, delete and modify the database, and then four mysql

Verify correctness on the server

3. Manually shut down the main mysql server of 4.122.

See whether the client can access, add, delete, modify and check.

After 4 and 4.122 are manually started, you first need to set it online: mmm_control set_online master 122

But VIP corresponds to 4.123, which will not automatically switch over.

Must first put 4.123:mmm_control set_offline master 123,

This way 4.122 will get VIP.

Keywords: MySQL Database RPM Makefile

Added by coldfiretech on Fri, 28 Jun 2019 20:36:22 +0300