Traditional replication on MariaDB upgraded to GTID replication

Check the replication status in the slave library, and pay attention to the replication delay. It is best to have no delay, and it does not matter.

SHOW SLAVE STATUS\G
- Relay_Master_Log_File: mysql-bin.000027
- Exec_Master_Log_Pos: 310094849
- Master_Log_File: mysql-bin.000027
- Read_Master_Log_Pos: 310094849

1. Execute the command from the library to stop the current replication:

STOP SLAVE;

2. View and record the location information of the relay log execution:

SHOW SLAVE STATUS\G
- Relay_Master_Log_File: mysql-bin.000027
- Exec_Master_Log_Pos: 310094849

3. View the GTID location corresponding to the execution location of the slave library in the main library

SELECT BINLOG_GTID_POS('mysql-bin.000027', 300050472);
+------------------------------------------------+
| BINLOG_GTID_POS('mysql-bin.000027', 300050472) |
+------------------------------------------------+
| 192-1681233-35567846                           |
+------------------------------------------------+

4. Go back to the starting position of the slave library setting GTID, that is, the location information queried from the master library in the third step

SET GLOBAL gtid_slave_pos = '192-1681233-35567846';

5. Reset the main library information

CHANGE MASTER TO MASTER_HOST='192.168.1.233', # 主机
                 MASTER_PORT=3306,            # 端口
                 MASTER_USER='replicator',    # 用户
                 MASTER_PASSWORD='replpass',  # 密码
                 MASTER_USE_GTID=slave_pos;   # 位置

6. Start replication

START SLAVE;

7. Check Replication Status

SHOW SLAVE STATUS\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 192.168.1.233
                  Master_User: replicate
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000027
          Read_Master_Log_Pos: 310094849
               Relay_Log_File: relay-bin.000002
                Relay_Log_Pos: 10045104
        Relay_Master_Log_File: mysql-bin.000027
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB: 
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: 
  Replicate_Wild_Ignore_Table: 
                   Last_Errno: 0
                   Last_Error: 
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 310094849
              Relay_Log_Space: 10045407
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File: 
           Master_SSL_CA_Path: 
              Master_SSL_Cert: 
            Master_SSL_Cipher: 
               Master_SSL_Key: 
        Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error: 
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 1681233
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
                   Using_Gtid: Slave_Pos
                  Gtid_IO_Pos: 192-1681233-35580793
      Replicate_Do_Domain_Ids: 
  Replicate_Ignore_Domain_Ids: 
                Parallel_Mode: optimistic
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it

You can see that Using_Gtid has a value, and Gtid_IO_Pos is constantly changing. So far, traditional replication has been changed to GTID replication.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325268979&siteId=291194637