Home Database Mysql Tutorial MySQL high availability architecture MMM architecture

MySQL high availability architecture MMM architecture

Aug 16, 2019 pm 02:13 PM
mysql

MMM (Multi-Master Replication Manager, multi-master replication management architecture)


Main role

Monitor and manage MySQL The master-master replication topology is used, and when the current master server fails, master-slave switching and failover between the master and master-slave servers are performed.

Related recommendations: [mysql tutorial]

Main functions:

● Monitor the health status of MySQL master-slave replication (active Master-master replication in active mode (master-master), master-master replication in active-passive mode (master-master-standby))

● Perform failover when the master database goes down and automatically configure other slave DBs to new Replication of the master DB

● Provides a virtual IP that can be mastered, written (read), and can automatically migrate the virtual IP when there is a problem with the master and slave servers

Architecture:

MySQL high availability architecture MMM architecture

Resources:

MySQL high availability architecture MMM architecture

## Deployment:

配置主主复制及主从同步集群
安装主从节点所需要的支持包(perl)
安装及配置 MMM 工具集
允许 MMM 监控服务
测试配置
Copy after login

Demonstration:

● Topology diagram (VIP: visual IP)

MySQL high availability architecture MMM architecture

Steps:

1、配置主(100)<->主(101)[参考: [Tony 老师搭建 MySQL 主从服务器](https://learnku.com/articles/31832)]
2、配置主(100)<->从(102)   [参考: [Tony 老师搭建 MySQL 主从服务器](https://learnku.com/articles/31832)]
3、 安装
     rpm -vih <http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm>
     rpm -Uvh <http://rpms.remirepo.net/enterprise/remi-release-7.rpm>
4、 yum clean all && yum makecache
5、更改yum源配置
    yum search mmm  # 查询mmm支持包
    yum -y install mysql-mmm-agent.noarch #每个服务器都需要安装mmm代理
    yum -y install mysql-mmm*  #监控服务器安装监控服务
    systemctl status mysql-mmm-agent
    systemctl start mysql-mmm-agent
    systemctl stop mysql-mmm-agent
    systemctl restart mysql-mmm-agent
6、建立账号
    CREATE USER repl@&#39;192.168.71.%&#39; identified by &#39;123456&#39;; //创建,建议从服务器IP段 ①
    CREATE USER mmm_monitor@&#39;192.168.71.%&#39; identified by &#39;123456&#39;; //创建,建议从服务器IP段 ①
    CREATE USER mmm_agent@&#39;192.168.71.%&#39; identified by &#39;123456&#39;; //创建,建议从服务器IP段 ①
7、账号授权
    GRANT replication client on *.* to &#39;mmm_monitor&#39;@&#39;192.168.71.%&#39; identified by &#39;123456&#39;;   #用于MMM监控服务器使用,在master上建立
    GRANT super,replication client ,process on *.* to &#39;mmm_agent&#39;@&#39;192.168.71.%&#39; identified by &#39;123456&#39;;    #MMM代理服务,改变故障转移和主从切换
    GRANT REPLICATION SLAVE ON *.* TO repl@&#39;192.168.71.%&#39;; //授权 复制账号
8、配置MMM(数据库节点配置,三台均配置)
    cd /etc/mysq-mmm/
    vim mmm_common.conf
    配置< host default >:
        网口:cluster_interface 
        pid和bin路径:默认
        replication_user:repl
        replication_password:123456
        agent_user:mmm_agent
        agent_password:123456
    配置< host db1 >:
        ip :192.168.71.244
        mode :master
        peer:db2
    配置 < host db2 > :
        ip:192.168.71.223
        mode:master
        peer:db1
    配置< host db3 >:
        ip:192.168.71.220
        mode:slave
    配置< role writer >
        hosts : db1,db2
        ips:192.168.71.90
        mode:exclusive( 唯一的)
    配置 < role reader >
        hosts:db1,db2,db3
        ips:192.168.71.91,192.168.71.92,192.168.71.93
        mode:balanced(平衡的)
    复制配置文件到其他服务器
        scp mmm_common.conf root@192.168.71.223:/etc/mysql-mmm/
        scp mmm_common.conf root@192.168.71.220:/etc/mysql-mmm/
    vim mysql-agent.conf (三台服务器对应设置为:db1,db2,db3)
9、监控节点配置(192.168.71.220,只配置监控节点)
    vim mmm_mon.conf  #监控数据文件
    配置< host default >
        monitor_user :mmm_monitor
        monitor_password:123456
    配置monitor
        ping_ips:192.168.71.244,192.168.71.223,192.168.71.220
10、启动MMM服务
    /etc/init.d/mysql-mmm-agent start(三台服务器均启动代理服务)
    /etc/init.d/mysql-mmm-monitor start (监控服务器启动监控服务)
11、查看监控信息
    mmm_control  
    mmm_control show #查看集群状态
    mmm_control checks all #检查集群状态
    mmm_control ping #检查与监控服务器连接状态
    mmm_control set_online/offline #设置服务器上线/下线
    mmm_control help #查看帮助
12、查看服务器虚拟IP状态
13、测试
    关闭db1的数据库:/etc/init.d/mysqld stop
    查看监控服务器上集群状态:mmm_control show
    查看DB3的主从状态
Copy after login

FAQ:

**通过mmm_control checks all 检查服务器状态**
Q1:
    UNKNOWN: Error occurred: install_driver(mysql) failed: Can&#39;t load &#39;/usr/lib64/perl5/vendor_perl/auto/DBD/mysql/mysql.so&#39; for module DBD::mysql: libmysqlclient.so.18: cannot open shared object file: No such file or directory at /usr/lib64/perl5/DynaLoader.pm line 190, <STDIN> line 1.
A1:
    perl-DBD-MySQL安装出问题
        S1:rpm -qa |grep -i DBD  #查看DBD安装
        S2:rpm -e --nodeps perl-DBD-MySQL-4.023-6.el7.x86_64 #卸载DBD
        S3:rpm -qa |grep -i DBD #查看卸载状态
        S4:wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm #下载MySQLserver,可根据系统选择具体版本
        S5:rpm -ivh mysql-community-release-el7-5.noarch.rpm #rpm MySQLserver
        S6:yum install mysql-community-server #yum安装
        S7:yum install perl-DBD-MySQL    #重新安装
        S8:systemctl restart mysql-mmm-monitor #重启
        S9:mmm_control checks all  + mmm_control show ->正常
Q2:
    当M1宕机时,MMM架构自动切换至M2,插入数据,S未更新,M1重启时,S仍未更新
A2:
    插入S一条空事务,记录与M2时相同即可。
Q3:
    handler error HA_ERR_KEY_NOT_FOUND; the event&#39;s master log mysql-bin.000002, end_log_pos 673 #跳过插入 | 更新 | 删除
A3:
    stop slave;
    insert into user(`username`) values(&#39;1&#39;);
    set global sql_slave_skip_counter=1;
    start slave;
Q4:
    The slave I/O thread stops because master and slave have equal MySQL server ids #切换主从发现,server_id相同
A4:
    show variables like &#39;**server_id**&#39;;
    vim /etc/my.cnf    修改server_id 值
**配置多线程**
stop slave #在从上,停止链路复制
set global slave_parallel_type = &#39;logical_clock&#39;;  #设置逻辑时钟的方式
set global slave_parallel_workers = 4;      #设置并发线程数
start slave;
Copy after login

The above is the detailed content of MySQL high availability architecture MMM architecture. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1655
14
PHP Tutorial
1253
29
C# Tutorial
1227
24
MySQL's Role: Databases in Web Applications MySQL's Role: Databases in Web Applications Apr 17, 2025 am 12:23 AM

The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

How to start mysql by docker How to start mysql by docker Apr 15, 2025 pm 12:09 PM

The process of starting MySQL in Docker consists of the following steps: Pull the MySQL image to create and start the container, set the root user password, and map the port verification connection Create the database and the user grants all permissions to the database

Laravel Introduction Example Laravel Introduction Example Apr 18, 2025 pm 12:45 PM

Laravel is a PHP framework for easy building of web applications. It provides a range of powerful features including: Installation: Install the Laravel CLI globally with Composer and create applications in the project directory. Routing: Define the relationship between the URL and the handler in routes/web.php. View: Create a view in resources/views to render the application's interface. Database Integration: Provides out-of-the-box integration with databases such as MySQL and uses migration to create and modify tables. Model and Controller: The model represents the database entity and the controller processes HTTP requests.

Solve database connection problem: a practical case of using minii/db library Solve database connection problem: a practical case of using minii/db library Apr 18, 2025 am 07:09 AM

I encountered a tricky problem when developing a small application: the need to quickly integrate a lightweight database operation library. After trying multiple libraries, I found that they either have too much functionality or are not very compatible. Eventually, I found minii/db, a simplified version based on Yii2 that solved my problem perfectly.

Laravel framework installation method Laravel framework installation method Apr 18, 2025 pm 12:54 PM

Article summary: This article provides detailed step-by-step instructions to guide readers on how to easily install the Laravel framework. Laravel is a powerful PHP framework that speeds up the development process of web applications. This tutorial covers the installation process from system requirements to configuring databases and setting up routing. By following these steps, readers can quickly and efficiently lay a solid foundation for their Laravel project.

How to install mysql in centos7 How to install mysql in centos7 Apr 14, 2025 pm 08:30 PM

The key to installing MySQL elegantly is to add the official MySQL repository. The specific steps are as follows: Download the MySQL official GPG key to prevent phishing attacks. Add MySQL repository file: rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm Update yum repository cache: yum update installation MySQL: yum install mysql-server startup MySQL service: systemctl start mysqld set up booting

MySQL vs. Other Programming Languages: A Comparison MySQL vs. Other Programming Languages: A Comparison Apr 19, 2025 am 12:22 AM

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages ​​such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages ​​have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

MySQL and phpMyAdmin: Core Features and Functions MySQL and phpMyAdmin: Core Features and Functions Apr 22, 2025 am 12:12 AM

MySQL and phpMyAdmin are powerful database management tools. 1) MySQL is used to create databases and tables, and to execute DML and SQL queries. 2) phpMyAdmin provides an intuitive interface for database management, table structure management, data operations and user permission management.

See all articles