mysql comprehensive principle ~ GTID

1 Introduction
  The only is a global transaction ID (global transaction identifier) belongs to the global
2 constituting the
   UUID + transaction_id in
. 3 format
   7a07cd08-ACIb-11e2-9fcf-0010184e9e08: 1-N
    the binlog = SESSION.GTID_NEXT the SET @@ ''
. 4 Concepts and Variables interpretation
   1 previous-GTIDs can be seen, each beginning binlog are recorded from GTID open to the sum of the binlog file before the binlog GTID executing transactions, even if not open GTID, also recorded
   2 gtid_executed table
    1 status: not manually change
    2 content : the sum of the transaction has been performed GTID, RESET MASTER clears the value
    3 mysql5.6 recorded in memory, it is necessary to open the relay logging for persistence (GTID_LOG_EVENT)
       mysql5.7 to achieve a lasting innodb_table not from the library Intermediate logs need to open the
4 trigger change content (applies to gtid_executed gtid_purged variable)
     1, Ltd. Free Join gtid_purged the SET = '' common to build from the library
     empty executed in table 2 reset master
    3 gtid_purged status: You can manually change the contents: binlog has been deleted transaction GTID, it is a subset of GTID_EXECUTED of
    4 gtid_owned status: No manual changes: the currently executing transactions GTID  
    5 binlog_gtid_simple_recovery status: You can manually change the contents: This option set to true, it will enhance the implementation of mysql recovery performance. Because of this and start binlog mysql-server log cleaning faster. When this parameter is true, mysql-server simply open the oldest and newest of these two binlog files, parameter values and gtid_executed gtid_purged parameters can be calculated based on these files Previous_gtids_log_event or Gtid_log_event. This ensures that when mysql-server restart or clean binlog, simply open two binlog files. The default is true aim is to speed up the scanning operation for the binlog of lost_gtid.
    6 gtid_executed_compression_period status: You can manually change the contents: compression, reducing the space occupied, the default is 1000, which means make a compression After each 1000 transaction for gtid_executed compression table
    7 from the associated master
      receiver 1 Retrieved_Gtid_Set to GTID transaction received attention GTID transaction may be inconsistent
       GTID 2 Executed_Gtid_Set transaction have been performed including synchronization and manual purge NATURAL two parts
5 mysql 5.6 open GTID
    gtid the ON-MODE =
    Consistency =-gtid-Enforce. 1
    log-Slave-Updates. 1 =
    binlog_format = Row
. 6 MySQL 5.7.6 online open GTID
   master and slave need to be performed
   to achieve steps:
   1. All Server execution
      set @@ global.enforce_gtid_consistency = warn; 
      special attention : this step is a step to build off with a warning not appear.
  2. Perform all the Server:
     the SET @@ global.enforce_gtid_consistency = ON;
  execution 3. All Server (do not care about the first final, but to perform complete):
     the SET @@ global.gtid_mode = off_permissive;
  4. Execution:
    set @@ global.gtid_mode = on_permissive; 
    essence GTID log in this step raw logs are brought, this step is called do not care about any node, but real management is recommended on the first execution in the slave, then go on the master carried out.
  5. Verify binlog conventional copying is completed, the value 0
    Show Status like 'ongoing_anonymous_transaction_count';
    requires all nodes are identified as 0.
  6. Analyzing all nodes show status like 'ongoing_anonymous_transaction_count'; zero
      for all nodes may be performed at: flush logs; log for switching bit.
  7. All the nodes enable gtid_mode
     SET ON @@ global.gtid_mode =
  8. The gtid_mode = on the configuration to the configuration file
      gtid_mode = on
      enforce_gtid_consistency = ON
  9. The nodes enable automatic discovery Gtid replication:
     STOP Slave;
     Change to Master master_auto_position 1 =;
     Start Slave;
     Precautions: only 1 greater than mysql 5.7.6 version to support the switch from traditional online copy to copy GTID
                 2 on gtid_mode option term explanation, to control new things is what produces patterns
                 GTID_MODE = OFF: no Normal_GTID, from the master to only accept ANONYMOUS_GTID
                 GTID_MODE = OFF_PERMISSIVE: no Normal_GTID, acceptable from the master ANONYMOUS_GTID & Normal_GTID
                 GTID_MODE = ON_PERMISSIVE: generating Normal_GTID, acceptable from a master & Normal_GTID ANONYMOUS_GTID
                 GTID_MODE the ON =: generating Normal_GTID, only accept Normal_GTID from the master
                 . 3 GTID main line switch regardless of whether uniformity generated GTID log, because it does not affect synchronization, only from the final step will really adopt GTID synchronization
   supplement
    1 GTID and parallel replication is two things, even if not open GTID, binlog will contain something parallel to copy the required
    2 versions across open GTID replication may be a problem, so it is not recommended to play , first with a conventional copying, then line switch
    3 reset master will clear gtid_purged gtid_executed content, caution
    4 mysqldump for export in GTID pattern comprises two-part operation
        1 set_log_bin = 0 for introducing GTID does not generate the local operation of the operation
        2 performed manually set global gitd_purged = '' importing a collection of transactions are deleted, updated variables gtid_purged + gtid_executed object library
        3 If you want to export GTID infos can increase --set-gtid-purged = OFF (not recommended)
        4 If the first structures derived from the library, you should first reset master Empty GTID corresponding table, resulting in obtaining the legacy prevent errors before collection GTID
   5 master_auto_position is how to find the location of
        1 is sent from the library collection to gtid_executed Master
        2 Master according to gtid_executed send scanned from a library binlog
        3 binlog start scanning forward from the latest, whether the need to record Previous-GTIDs record the beginning of the judgment according to each binlog , so
        4 to find corresponding to a binlog Salve
   . 6 handover availability

      1 If switching from the old from the new primary point, no longer need to provide high availability binlog and postion in the main, you can get the latest data from the above scanning mechanism
       2 remember high availability must be carried out after the completion of the new primary application relay-log reset master. Then the new master's binlog contains the application content binlog former team, to keep the old case of missing data caused the error does not occur from the point to the new primary

       3 after completion of the handover by the old master will find show slave status plurality GTID record, the old master, and new master comprising

Guess you like

Origin www.cnblogs.com/danhuangpai/p/11332555.html
Recommended