Rate This Document
Findability
Accuracy
Completeness
Readability

Querying the Replication Mode

Query the replication mode (traditional or GTID) of MySQL primary-secondary replication. The two replication modes have no performance difference, and GTID is recommended. The replication mode of the primary database must be the same as that of secondary databases.

  1. Log in to the primary database.
    1
    /usr/local/mysql/bin/mysql -uroot -p123456 -S /data/mysql/run/mysql.sock
    
  2. Query the replication mode of the primary database.
    1. Query the value of gtid_mode.
      If the value is ON, the GTID mode is used. Otherwise, the traditional mode is used.
      show variables like '%gtid_mode%';
    2. Query threads.
      If the value of Command in the I/O thread is Binlog Dump GTID, GTID-based replication is used. Otherwise, traditional replication is used.
      show processlist;

  3. Log in to a secondary database.
    1
    /usr/local/mysql/bin/mysql -uroot -p123456 -S /data/mysql/run/mysql.sock
    
  4. Query the replication mode of the secondary database.
    1. Query the value of gtid_mode.
      show variables like '%gtid_mode%';

      If the value is ON, GTID-based replication is used. Otherwise, traditional replication is used.

    2. Query the status of the secondary database.
      show slave status\G;

      If Executed_Gtid_Set in the command output has the same value as that of the same parameter in the command output of show master status; on the primary database, GTID-based replication is used. Otherwise, traditional replication is used.