Database High Availability architecture to find out

Saw a lot of high-availability architecture applications and services, we take a look at it highly available database.

Solutions of highly available data storage are by replicating data to a plurality of storage devices, data redundancy is achieved by way of high availability. Common high-availability architecture has standby, master-slave, The Lord, clustering, partitioning, then we talk about the advantages and disadvantages of each architecture.

Standby architecture

1, the basic architecture topology is as follows
image

The overall structure is simple, almost all databases provide a standby copy functions, such as Mysql, Oracle, MongoDB and so on. In this architecture, the role of library equipment is mainly responsible for data backup, business is not involved in the actual reading and writing operations, if the standby machine into a host requires manual operation.

2, advantages and disadvantages of
the advantages of master and slave architecture is simple, specific performance:

  • For the client, no sense the presence of backup machine, even after disaster recovery, backup machine is the original manual intervention to modify the hosts, clients simply need to modify the connection address, application architectures do not need to make any changes;
  • Preparation and host only needs to copy the data, and does not require standby switching state judgment such complex operations.

The disadvantage of this architecture is also obvious:

  • Preparation machine is mainly used for data backup, the cost of waste will result if there is no application architecture design separate read and write
  • After the failure requires manual intervention, it can not automatically recover, while off than the manual processing efficiency is low, the recovery process is prone to error.

Master-slave architecture

Master-slave architecture with master and slave architecture is only one word, but a large gap for practical application architecture. The primary and standby database architecture is not involved in business operations, and in the master-slave architecture from the library is required to participate in business operations, application architecture needs to be done separate read and write, to write to write the main library, and read from the read from the library .

1, the basic architecture of the main topology is as follows
image

2, advantages and disadvantages of
this architecture is very useful when a small amount of the write and read a lot. You can be apportioned to a plurality of the read library preparation, reducing the pressure of the primary library, from the library to the main reservoir until the cause too great a burden, or from among primary bandwidth reaches a bottleneck.

Compared to standby architecture, it has the following advantages:

  • Failure in the main library, read related business can continue to run
  • From outside the library to provide the ability to read, play a hardware performance
  • Different from the library can provide for different roles

Disadvantages:

  • Master-slave architecture required to provide business read from the library, if the master-slave replication latency big, there will be inconsistencies in the data;
  • Requiring modifications to the application architecture, generally added to separate read and write, the complexity of the apparatus is higher than the master;
  • After the failure requires manual intervention, it can not automatically recover, while off than the manual processing efficiency is low, the recovery process is prone to error.

From the switching master

The above two architectures there are two common problems:

  • After the failure of the main library, you can not write
  • After the main library out of the question requires manual intervention to switch from the main library to library, but not in time or manual switching and fail over issues that may arise.

Based on the above two issues we need an automatic switching architecture, when the main library out of the failure can be automatically replaced by the main library from Coetzee, operation and maintenance personnel do not need to intervene.
To achieve master-slave switching architecture must be considered a key point: There must be a mechanism to monitor the operational state of the database node, in order to decide whether to switch.
This architecture we generally introduces a third-party intermediary, database node periodically report their status information to a third party intermediary; or a third-party intermediary timed to pull database database node status;
image

advantage:

  • Solve the problem of human intervention, greatly reducing downtime, protect the life safety of operation and maintenance personnel to some extent
    Cons:
  • Architecture complex, after the introduction of third-party intermediaries need to ensure availability of third-party intermediaries.

Here we recommend a look at the mysql MHAarchitecture, or use ZK, Keepalived built himself a master-slave switch architecture.

The Lord Architecture

The Lord called master-master replication architecture, the two databases are the master database, copy the data to each other, the client can pick Renyiyitai database read and write operations.
image

Compared to switching from the master, the master of a host architecture has the following advantages:

  • Two databases are the main library, there is no concept of handover
  • Clients do not need to distinguish between the different roles of hosts, casually read and write database operations Which issue.
  • Simple architecture

But allows write to the two main database is a very dangerous thing:

  • AB growth from two database using a primary key, A library is inserted user id 1, id B after the library is inserted into a user data collision
  • While the database data updates will be a big problem, adding table AB library tbhas a field col, a value of 1. A library as executed update tb set col = col +1, B library to perform update tb set col = col * 2, after executing the final data becomes a value 4, the value of the other into a database 3, and no replication errors, once a problem requires a long time to positioning.
    So the main primary architecture must be able to ensure that two-way replication of data, design data, there are strict requirements, generally applicable to those temporary and can be lost, the data can be covered scene.

Please pay attention to individual public number: JAVA Rizhilu

avatar

Guess you like

Origin www.cnblogs.com/jianzh5/p/11865645.html