Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

MySQL-MMM High availability Cluster

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

A brief introduction to MMM

1. MMM (Master-Master replication manager for MySQL,MySQL Master replication Manager) is a set of scripts that support dual-master failover and dual-master daily management.

2. MMM is a flexible script program based on perl, which is used to monitor and fail over mysql replication, and to manage the configuration of MySQL Master-Master replication.

3. The highly available architecture of MMM is described as follows:

(1) mmm-mon: monitor the process, be responsible for all monitoring work, decide and handle all node role activities. This script needs to be run on the supervisor.

(2) mmm-agent: an agent process that runs on each MySQL server, completes monitoring probe work and performs simple remote service settings. This script needs to be run on the supervised machine.

(3) mmm-control: a simple script that provides commands for the mmm_mond process.

(4) the supervisor of mysql-mmm will provide multiple virtual IP (VIP), including a writable VIP and multiple readable VIP. Through regulatory management, these IP will be bound to the available MySQL. When a MySQL goes down, the supervisor will migrate the VIP to other MySQL.

Experimental environment: five centos7, four MySQL:m1 192.168.30.30, m2 192.168.30.31, S1 192.168.30.32, s2 192.168.30.35 one mmm_moniter:192.168.30.36 service firewalld stop setenforce 0

Second, install MySQL and MySQL-mmm

For experimental consistency, install MySQL and MySQL-mmm using yum source

Replace it with Ali Source

Yum install wget-y wget-O / etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo yum-y install epel-release yum clean all & & yum makecache

2 install mariadb on four MySQL servers

Yum-y install mariadb-server mariadb

Systemctl start mariadb

Systemctl enable mariadb

3-modify M1 main configuration file-

Vi / etc/my.cnf / /

Add the following in the appropriate location

[mysqld] log_error=/var/lib/mysql/mysql.errlog=/var/lib/mysql/mysql_log.loglog_slow_queries=/var/lib/mysql_slow_queris.logbinlog-ignore-db=mysql,information_schemacharacter_set_server=utf8log_bin=mysql_binserver_id=1log_slave_updatessync_binlog=1auto_increment_increment=2auto_increment_offset=1

Systemctl restart mariadb

Netstat-anpt | grep 3306

-when there is no problem, copy the configuration file to the other 3 database servers and start the server-

-Note: the server_id in the configuration file should be modified-

Then restart mariadb.

Systemctl start mariadb

Systemctl enable mariadb

4 configure master master replication-two master servers replicate each other

Mysql # enter the database

Show master status; / / record the log file name and location value, and view it on both hosts.

Since both of my databases are pure and do not perform any operations, the binary log files and location variables are the same, but the nature is different, one corresponding to the main server master1, the other corresponding to master2

M1

M2

Grant replication slave on *. * to 'replication'@'192.168.30.%' identified by' 123456servers; / / two main servers authorize each other to connect M1: change master to master_host='192.168.30.31',master_user='replication',master_password='123456',master_log_file='mysql_bin.000003',master_log_pos=410 / / master1 specifies the address of master2 and the corresponding binary log file and location variable m2: change master to master_host='192.168.30.30',master_user='replication',master_password='123456',master_log_file='mysql_bin.000003',master_log_pos=410; / / master2 specifies the address of master1 and the corresponding binary log file and location variable start slave; / / enable the replication function show slave status, respectively / / check the status separately as long as SlaveIORunning: Yes and SlaveSQLRunning: Yes are guaranteed to ok!

M1

M2

5 build a database to test master synchronization

Create database dba; / / you can see it on another host.

After the drop database dba; / / is deleted on the master, there is no other master, and the synchronization is successful.

6 establish master-slave synchronization

S1 and S2 point to either of the two masters respectively.

Show master status; checks the log status again on master1

Change master to master_host='192.168.30.30',master_user='replication',master_password='123456',master_log_file='mysql_bin.000003',master_log_pos=410; start slave; show slave status; to view replication status

S1

S2

-Test master-slave, master-master, synchronization

Set up the database and test the synchronization

Create database abc; / / created by either of the two masters

Show databases; / / View separately on the two slave servers

Install MMM---- on all servers

one

Yum-y install mysql-mmm-agent / / install the agent on four database servers

Yum-y install mysql-mmm-monitor / / install a monitor on another empty machine

2 after the installation, configure the mmm-agent side

Read-write separation needs to be implemented with amoeba. Click here to view details of amoeba read-write separation.

Cd / etc/mysql-mmm/

1) vi mmm_common.conf / / should be configured on all hosts, and multiple copies should be directly copied.

Specify the IP address and mode of each proxy host:

Configure read-write roles:

2) configure mmm_agent.conf (four databases excluding monitors) in turn

Vi / etc/mysql-mmm/mmm_agent.conf

3) configure mmm_mon.conf

Vi / etc/mysql-mmm/mmm_mon.conf / / configure the monitoring host

4) Authorization on the monitoring side and the agent side (on four database servers)

Mysql / / enter the database

Grant super, replication client, process on. To 'mmm_agent'@'192.168.30.%' identified by' 123456authorization; / / authorize for the agent

Grant replication client on. To 'mmm_monitor'@'192.168.30.%' identified by' 123456authorization; / / Authorization for the monitor

Flush privileges; / / Refresh permissions

Systemctl start mysql-mmm-agent / / four database servers start the mysql agent respectively

Systemctl enable mysql-mmm-agent / / Boot

Systemctl start mysql-mmm-monitor / / Monitoring host starts mysql monitoring terminal

Systemctl enable mysql-mmm-monitor / / Boot

Mmm_control show / / View the status of each node

Note: unable to view, wait a moment to continue to check, there will be response time *

Mmm_control checks all / / requires all kinds of OK

5) Fault testing

(1) stop master1

Systemctl stop mariadbmmm_control show / / View on the monitoring host

Verify that the virtual address 188 is moved to the master2

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report