Get the App
SLTechnology News&Howtos  ›  Database  › 

Cascade replication is transformed into one master and two slaves

Shulou Source: shulou.com Published: 2022-06-01 09:17:34 10月03日 Update

1. As shown in the figure, if cascade replication is converted into one master and two slaves?

GTID copy processing method:

Just stop copying S2 and change it to M again.

S2:

stop slave;

reset slave all;

change master to M;

start slave

Traditional copy processing methods (more complex):

(1) Stop copying S1, at which point S1 and S2 stop at the same location.

(2) Perform show slave status on S1\G

root@localhost [testdb]>show slave status\G

*************************** 1. row ***************************

Slave_IO_State:

Master_Host: 192.168.91.22

Master_User: repl

Master_Port: 3306

Connect_Retry: 60

Master_Log_File: mysql-bin.000008

Read_Master_Log_Pos: 917

Relay_Log_File: relay-bin.000011

Relay_Log_Pos: 718

Relay_Master_Log_File: mysql-bin.000008

Slave_IO_Running: No

Slave_SQL_Running: No

Exec_Master_Log_Pos: 917

(3) Change S2 to the main library M

change master to

master_host='192.168.91.22',

master_port=3306,

master_user='repl',

master_password='147258',

master_log_file='mysql-bin.000008 ',

master_log_pos='917 ';

(4) Finally, start S1 replication

2. As shown in the figure, how can one master and two slaves be converted into cascade replication?

GTID copy processing method:

Simple, direct S2change to the main library S1

Traditional copy processing methods:

(1) Make both S1 and S2 copy error at a certain point, such as 1032 error, so that both copies stop at the same position, determine the master_log_file and master_log_pos positions

(2) Change S2 to S1

(3) Fix S1 error

Tags: Method processing location tradition error as shown in figure complex at the same time time Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Shulou Technology Huawei Docker Apple