Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build MySQL Master-Slave copy Classic Architecture

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to build MySQL master-slave copy classic architecture". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to build MySQL master-slave copy classic architecture".

Today, let's take a moment to build the master-slave replication architecture of MySQL. Otherwise, everyone's previous master-slave replication project may not be good for verification testing.

Before we begin, let's briefly talk about the principle of MySQL master-slave replication. The MySQL replication process is divided into three steps:

Master logs the changes to the binary log (binary log). These recording processes are called binary log events, binary log events

Slave copies the binary log events of master to its relay log (relay log)

Slave redoes events in the relay log to apply changes to its own database. MySQL replication is asynchronous and serialized.

To put it simply, the slave node reads the binlog from the master for data synchronization.

I believe that many people have already heard the cocoons in their ears to the above principle. Not to mention that there are many middleware specializing in replication on the market, the principle is the same as above.

Let's start to configure the master-slave replication classic architecture of MySQL. Windows (configuration file is my.ini file) and slave is Linux (configuration file is my.cnf). So that all systems can take into account.

The first step is to create an account on the master database that can read the master library binlog.

The second step is to configure the following after [mysqld] in the my.ini file of the main library.

Step 3, after modifying the configuration file, restart the service: service mysqld restart.

If startup fails, use cat / var/log/mysqld.log | tail-30 to view the log of mysql startup failure and find a solution from the log content.

The fourth step is to check the current binary log name and offset of the master server. The purpose of this operation is to recover the data from this point after starting from the slave database.

Now that the configuration of the master library is finished, let's start with the configuration of the slave library.

The slave library is a Linux, so we log in and configure the my.cnf file.

The first step is to configure the following after [mysqld] in the my.cnf file.

Restart the database after the configuration is complete. If the restart fails, an error is reported. The following SQL statement is executed directly on the slave library.

Then restart the slave node to see the status of the slave node.

When Slave_IO_Running: Yes and Slave_SQL_Running: Yes are displayed as YES in the result, it indicates that the building is successful.

Note: in order to ensure the success of the construction and not be affected by the firewall, you can turn off the firewalls on both the master and slave servers.

Thank you for your reading, the above is the content of "how to build MySQL master-slave copy classic architecture". After the study of this article, I believe you have a deeper understanding of how to build MySQL master-slave copy classic architecture, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report