At this time, the Slave server has successfully connected to the Master server and is ready to receive and execute Binlog events.

Author: Zen and the Art of Computer Programming

1 Introduction

In MySQL master-slave replication, when a Slave (slave server) establishes a connection with the Master (master server) and synchronizes successfully, the Slave will be in a "waiting" state, waiting to obtain updated data changes from the Master. As shown below:

However, if the Slave is in a waiting state for a long time, or the network condition is poor, causing the Slave to be unable to obtain data changes on the Master, it will affect the normal operation of the database. Therefore, how to effectively monitor and maintain Slave servers and prevent failures is an issue worth studying. This article will explore related issues and give corresponding solutions.

2.Basic concepts and terminology

2.1 Binlog

MySQL's binary log (Binary log), also called binlog, is used to record events when the MySQL server executes transactions and modifies data. By setting the parameter server_id, you can configure different server_id for different MySQL servers. The contents recorded in binlog include:

1. All DDL statements: including CREATE, ALTER, DROP, etc.; 2. All DML statements: including INSERT, UPDATE, DELETE, etc.; 3. Includes only data modification events, excluding modification events defined by the table structure; 4. Includes all Committed transactions will not be recorded even if rolled back; 5. The executed SQL statements are recorded, but they may be different due to parsers, optimizers, etc.

2.2 Heartbeat

The MySQL Slave server implements the Heartbeat function, periodically sends a heartbeat message to the Master server, and waits for the Master's response. If it exceeds a certain time

Guess you like

Origin blog.csdn.net/universsky2015/article/details/132914113