An analysis of MySQL schema of open source database

Source: Internet
Author: User
Tags percona

Database is the core of all application systems, so to ensure the stable, efficient and safe operation of the database is the most important work of all enterprises. Once a database system fails to provide services, it may cause the entire system to fail to continue working. Therefore, a successful database architecture needs to be fully considered in terms of high-availability design. Here's a look at how to build a highly available MySQL database system.

A DBA or an OPS student should know that a single point of any device or service poses a huge risk because once the physical machine is down or the service module crash, if a replacement device cannot be found in a short period of time, is bound to affect the entire application system. So how to ensure that no single point is our important work, the use of MySQL High-availability program can be a good solution to this problem, generally have the following:

First, using MySQL 's own Replication to achieve high availability

MySQL comes with Replication is what we often call master-slave replication (AB replication), by making a slave to the master server, Quickly switch the business to the slave while the primary server is down, ensuring that the application is in good working condition. Using AB replication for high-availability scenarios is also divided into several different architectures:

1, the general MASTER---SLAVE solution

The common MASTER---SLAVE is one of the most common architecture schemes used by most small and medium-sized companies at home and abroad, the main advantage is simple, less equipment (lower cost), convenient maintenance. This architecture solves the problem of single point, and also can solve the system performance problem to a great extent. You can take one or more SLAVE(Master-slave cascade replication) behind a master, but this architecture requires a master Must be able to meet all of the system's write requests, or you need to do a horizontal split to share the pressure of reading.

Figure A

Figure II

Figure one to figure two shows: solve the single point problem and the use of read and write separation to achieve improved performance process.

2.DUAL MASTER combined with cascade replication

Dual-Master is a more reasonable scheme derived from the above scheme. The benefit of this scenario is that when any one of the two primary servers is hung up, the entire architecture is not resized.

Might

Figure Four

Figure Five

The process is as shown. But figure five is a very special caseMaster-bWhat happens if you go down? The first thing we can be sure of is all of ourWritethe request is not affected, and allReadrequests can also be accessed normally, but allSlavereplication will be interrupted,Slavethe data above will begin to lag. All we need to do is put all theSlavemakeChange MASTER tooperation, change fromMaster Afor replication. Because allSlavereplication is impossible to advance the original data source, so you canSlaveabove theRelay Logthe timestamp information in theMaster Athe timestamp information in the control, to find the exact starting point of replication, so as to avoid the loss of data.

Second, using MYSQL CLUSTER to achieve the overall high availability

For now, the use of MYSQL CLUSTER to achieve an overall high availability (ie , NDB CLUSTER) is not widely available in domestic companies. the NDB CLUSTER node is actually a multi-node MySQL server, but does not contain data, so any machine can be used as long as it is installed. When a SQL node in a cluster is crash , the data is not lost because the node does not have specific data. Six:

Figure Six

Iii. high availability through MySQL 's derivative products

In the current MySQL Implementation of highly available derivative products, the popularity and popularity of the higher is galera CLUSTER and PERCONA Xtrdb CLUSTER (PXC). Related content This article is not open to tell, interested students can consult the relevant information for further understanding. The two clusters are implemented in a similar way, and figure eight:

Figure Seven

Figure Eight

Iv. comparison of advantages and disadvantages of various high-availability schemes

In the introduction of various high-availability designs, readers may have discovered that, regardless of the scheme, there are unique advantages, but there are more or less limitations. This section will do a pros and cons analysis of the above major scenarios, for everyone to choose the process of reference.

1.MySQL Replication

Advantages: Simple deployment, ease of implementation, maintenance is not complex, is the nature of MySQL support features. It is easy to switch between the main and standby machines, and the primary and standby switch can be done automatically through the third party software or a script written by itself.

Disadvantage: If the master host hardware fails and cannot be recovered, it may result in some data loss that is not delivered to the Slave end.

2.MySQL Cluster (NDB)

Advantage: Very high availability, very good performance. Each piece of data has at least one copy on top of the different hosts, and redundant copies of the data are synchronized in real time.

Disadvantage: Maintenance is more complex, the product is newer, there are some bugs, not necessarily applicable to the core of the online system.

3,galera CLUSTER and PERCONA xtrdb CLUSTER(PXC)

Advantage: Very high reliability, all nodes can read and write each data at the same time, at least one copy on the different hosts, and redundant data copy in real-time synchronization.

Disadvantage: As the size of the cluster expands, performance will become worse.

4, have to mention the DRBD Disk network mirroring scheme

Architecturally, it's a bit like Replication, but it's the process of synchronizing data through third-party software, which is more reliable than Replication , but also sacrificing performance.

Advantage: Software is powerful, data is mirrored across physical hosts at the underlying block device level, and different levels of synchronization can be configured based on performance and reliability requirements. IO operations are maintained in order to meet the database's demanding data consistency requirements.

Disadvantage: Non-Distributed File system environments cannot support mirrored data at the same time, performance and reliability are contradictory and cannot be applied to environments that are both demanding. Maintenance costs are higher than MySQL Replication.

After saying the pros and cons of a variety of common architectures, the rest is how to choose the right architecture to use in a real-world production environment. In this respect everyone has their own ideas and experience, the specific plan is the best of opinion. In the daily work of the structure of the perfect is not an overnight, but a constantly evolving process of optimization and improvement.

A push in the database also experienced from a single point to master-slave to master-slave + High-availability process, but also experienced from a single mysql+redis to mysql+redis+es , finally to the present Mysql+redis+es+codis and so on evolution. Each time the evolution is to solve the actual problems and pain points in the production environment. Single from MySQL No one architecture can solve all the problems (pain points), you need to choose a suitable architecture according to the actual situation. the MySQL cluster implementation is very flexible, and it is a challenge for MySQL workers to choose a suitable architecture, and we are constantly studying and learning the power of MySQL.

An analysis of MySQL schema of open source database

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.