MySQL high availability architecture

When considering the highly available architecture of the MySQL database, it is mainly considered from the following aspects:

  1. If the database is down or unexpectedly interrupted, you can restore the availability of the database as soon as possible, reduce downtime as much as possible, and ensure that the business will not be interrupted due to database failure.
  2. The data of the non-primary node used for backup, read-only copy and other functions should be consistent with the data of the primary node in real time or eventually.
  3. When a database switch occurs in a business, the contents of the database before and after the switch should be consistent, and the business will not be affected due to missing or inconsistent data.

Speaking of MySQL's high availability, we have to mention replication, which is the foundation of MySQL's high availability. The following are the problems solved by "copy":

  1. Implement data backup
  2. If there is a slave server, after the master server fails, the write function of the slave server is enabled to provide highly available use functions
  3. Off-site disaster recovery
  4. Scale out the load master server: write, slave server: read

Master-slave replication process

Different replication agreements:

Highly available replication architecture

Mysql high availability architecture

MySQL Cluster architecture

Restrict the storage engine to the NDB storage engine:

MySQL + MMM architecture

MMM is Master-Master Replication Manager for MySQL (mysql master master replication manager), is a set of scalable script suites for monitoring, failover and management of mysql master master replication configuration (only one node can be written at any time In), this suite can also be based on the standard master-slave configuration for any number of slave servers to load balance reading, so you can use it to start a virtual ip on a group of replication servers Script for data backup and resynchronization between nodes.
 MySQL itself does not provide a solution for replication failover. The MMM solution can achieve server failover, thereby achieving high availability of mysql.

Features of this program:

  1. High security, stability, and good scalability
  2.  At least three or more servers are required
  3.  For dual master (master-slave replication requirements are higher)
  4. It can also achieve read-write separation

MySQL + MHA architecture

MHA should also be a relatively mature and common solution in the MySQL high-availability program. It was developed by the Japanese. During the failover process of MySQL, MHA can achieve fast and automatic switching operations, and it can also maintain data consistency to the maximum .

Features of this architecture:

  1. Simple installation and deployment, does not affect the existing structure
  2. Automatic monitoring and failover
  3. Ensure data consistency
  4. Failover mode can use manual or automatic multi-directional selection
  5. Wide adaptability (applicable to any storage engine)

summary

As people's requirements for data consistency continue to increase, more and more methods are tried to solve the problem of distributed data consistency, such as optimization of MySQL itself, optimization of MySQL cluster architecture, Paxos, Raft, 2PC algorithm The introduction and so on.

The use of distributed algorithms to solve the problem of MySQL database data consistency is also increasingly accepted by people. A series of mature products such as PhxSQL, MariaDB Galera Cluster, Percona XtraDB Cluster, etc. are more and more popular. Scale use.

With the GA of the official MySQL Group Replication, the use of distributed protocols to solve data consistency problems has become the mainstream direction. It is expected that more and more excellent solutions will be proposed, and MySQL high availability problems can be better solved.

Published 6 original articles · received 1 · views 655

Guess you like

Origin blog.csdn.net/DY1316434466/article/details/105439633