Chanler

Chanler

"Dark Horse MySQL" Four, Master-Slave Replication

Overview#

Master-slave replication refers to the process of transferring DDL and DML operations from the master database to the slave server through binary logs (binlog), and then re-executing these logs on the slave, also known as redo, to keep the data in sync between the master and slave.

Advantages:

  1. In case of master failure, it can switch to the slave.
  2. Read-write separation.
  3. The slave can perform backups, and can still read even with a global lock.

image.png|500

Principle#

Process:

  1. When the master processes a transaction commit, it records data changes (row or statement - DDL, DML) to the binary log file (binlog).
  2. The slave reads the master’s binary log file (binlog) and writes it to the slave's relay log.
  3. The slave redoes the events in the relay log to achieve consistency between master and slave.

image.png|500

Setup#

Server Configuration#

image.png|500

Master Configuration#

image.png|500

image.png|500

Slave Configuration#

Read-only applies only to ordinary users; users with super privileges can still perform insert, delete, and update operations. Super privileges can be disabled by setting super-read-only = 1 or super_read_only = 1.

image.png|500

image.png|500

image.png|500

This article was synchronized and updated to xLog by Mix Space. The original link is https://blog.0xling.cyou/posts/mysql/mysql-4

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.