MySQL database high availability architecture

Reprint https://www.2cto.com/database/201612/572250.html

1. MHA

MHA: mysql-master-ha: mysql master high availability management tool

Automate master failover with management nodes, quickly promote slaves to master (usually 10-

30s) without affecting replication consistency, used with any storage engine.

The management node requires ssh to connect to the mysql server, which is a relatively mature solution in terms of high availability.

Main features:

1. Automatic monitoring and failover of the primary server

2. Interactive server failover

3. Non-interactive primary failover

4. The main components of online switching master-slave server are:

   1)master mysql

   2)slave mysql

   3)slave mysql

 

2. MMM

MMM: Master-Master Replication Manager for MySQL (mysql master-master replication manager)

1. This is a scalable scripting suite for monitoring, failover and management of mysql master-master replication configuration ( only one node can be written to at any time )

2. This suite can also load balance any number of slave servers in a standard master-slave configuration , so you can use it to start a virtual ip on a set of servers that live in replication

3. In addition, it also has scripts for data backup and resynchronization between nodes.

4. MySql itself does not provide a replication failover (failover) solution. The server failover can be achieved through the MMM solution, thereby realizing the high availability of mysql. MMM can not only provide the function of floating IP, but what is more valuable is that if the current master server hangs, it will automatically transfer your back-end slave server to the new master server for synchronous replication without manually changing the synchronization configuration.

 

3. Hertbeat+DRBD+MySql high availability solution

The HeartBeat double-click hot standby software is used to ensure the high stability and continuity of the database, and the data consistency is guaranteed by the tool DRBD. By default, only one mysql is working. When there is a problem with the primary sql server, the system will automatically switch to the standby server to continue to provide services. When the primary database is repaired, the service will be switched back to continue to be provided by the primary mysql server. It is suitable for scenarios where the database access volume is not too large, the access volume will not grow too fast in the short term, and the high availability of the database is required.

 

 

 4. Mysql cluster MySQL Cluster

In fact, it is a completely distributed database system implemented without shared storage devices, which is mainly implemented by the NDB Cluster (NDB for short) storage engine. When MySQL Cluster was just born, it can be said to be an in-memory database that can persist data. All data and indexes must be loaded in memory to run normally, but the latest MySQL Cluster version can only store all indexes and indexes. The index data can be loaded in the memory, and the actual data can not be loaded into the memory. The architecture is shown in the following figure:

 It can be seen from the above figure that MySQL Cluster is composed of a group of computers, and each computer runs a variety of processes, including MySQL server, NDB Cluster data node, and management server. The functions of the three nodes are as follows:

1. Management (MGM) node

      The role of this type of node is to manage other nodes within the MySQL Cluster, such as providing configuration data, starting and stopping nodes, running backups, and so on. Since such nodes are responsible for managing the configuration of other nodes, they should be started before other nodes. The MGM node is started with the command "ndb_mgmd".

2. Data Node

      This type of node is used to save Cluster data. The number of data nodes is related to the number of replicas and is a multiple of fragments. For example, with two replicas, each with two fragments, then there are 4 data nodes. However, it is not necessary to set up multiple copies. Data nodes are started with the command "ndbd".

3. SQL node

      This is the node used to access Cluster data. For MySQL Cluster, client nodes are traditional MySQL servers using the NDB Cluster storage engine. Typically, SQL nodes are started using the command "mysqld –ndbcluster" or "mysqld" after adding "ndbcluster" to "my.cnf".

 

 5. MySQL/Galera Cluster - Multi-Master High Availability Load Balancing

Galera is a MySQL (also supports MariaDB, Percona) synchronous multi-master cluster software, currently only supports InnoDB engine. The replication function of Galera cluster is implemented based on Galera library. In order to allow MySQL to communicate with Galera library, the wsrep API is specially developed for MySQL. The Galera cluster is included in the Percona and MariaDB releases.

The main function:

1. Synchronous replication

2. True multi-master, that is, all nodes can read and write the database at the same time

3. Automatic node member control, failed nodes are automatically cleared

4. New nodes join data automatic replication

5. True Parallel Replication, Row Level

6. Users can directly connect to the cluster, which is completely consistent with MySQL

Galera is essentially a wsrep provider that runs API interfaces that depend on wsrep. The Wsrep API defines a series of application callbacks and replication call libraries to implement transactional database synchronous writeset replication and similar applications. The goal is to achieve abstract, isolated replication from application details. While the primary goal of this interface is authentication-based multi-master replication, it is equally applicable to both asynchronous and synchronous master-slave replication.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325139269&siteId=291194637