In order to expand the scalability of the application system, we often need to scale out the database. The scale out design increases the overall processing capability of the system by adding database processing nodes, that is, increase the number of database servers to share the pressure. In this way, the scalability of the system is enhanced, and the cost is reduced. However, the system architecture is complicated and maintenance is difficult. System downtime or failure is inevitable. Therefore, theoretically, the security of the system (data may be lost) is reduced, and the availability is also reduced. To improve data security and high system availability, it is easy to avoid spof risks in all software and hardware, and store multiple copies of all data. Technically speaking, it can be achieved through the database replication technology. MySQL replication technology is one of the implementation methods of database replication.
There are several optional architecture solutions for MySQL replication, such as the general replication architecture master-slave solution, dual master architecture solution, and cascade replication architecture solution, today, we will focus on the simplest master-slave solution,The architecture diagram is as follows:
This architecture scheme, that is, a MySQL server as the master server, is mainly responsible for writing data to the application client, and allows others to copy data as the source of the slave MySQL server. The data on those slave servers is a full backup of the master server data, which is relatively real-time backup. The backup data is mainly used by the client to read data, generally, the data read Pressure on application systems is higher than that on Data Writing, especially for Web application systems.