mysql学习——观察GTID

主备环境已经ok,已打开GTID功能

 

mysql> show master status \G
*************************** 1. row ***************************
             File: master-bin.000005
         Position: 154
     Binlog_Do_DB: 
 Binlog_Ignore_DB: 
Executed_Gtid_Set: 
1 row in set (0.00 sec)

 

创建表并插入一条数据

mysql> create table lzldb.tab1 as select * from mysql.tables limit 1;
ERROR 1786 (HY000): Statement violates GTID consistency: CREATE TABLE ... SELECT.


mysql> create table lzldb.tab2(a int);
Query OK, 0 rows affected (0.06 sec)

mysql> insert into lzldb.tab2 values(1);
Query OK, 1 row affected (0.02 sec)

mysql> commit;
Query OK, 0 rows affected (0.00 sec)

mysql> show master status \G
*************************** 1. row ***************************
             File: master-bin.000005
         Position: 572
     Binlog_Do_DB: 
 Binlog_Ignore_DB: 
Executed_Gtid_Set: a9521767-c5a0-11ea-a743-08002792ac2c:1-2
1 row in set (0.00 sec)

mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 127.0.0.1
                  Master_User: replicator
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: master-bin.000005
          Read_Master_Log_Pos: 572
               Relay_Log_File: slave-relay-bin.000010
                Relay_Log_Pos: 787
        Relay_Master_Log_File: master-bin.000005
             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: 572
              Relay_Log_Space: 1209
              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: 1001
                  Master_UUID: a9521767-c5a0-11ea-a743-08002792ac2c
             Master_Info_File: /data/mysql3308/master.info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
           Master_Retry_Count: 86400
                  Master_Bind: 
      Last_IO_Error_Timestamp: 
     Last_SQL_Error_Timestamp: 
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
           Retrieved_Gtid_Set: a9521767-c5a0-11ea-a743-08002792ac2c:1-2   --有事务了以后,slave就会有gtid记录。刚搭建的slave,如果没有事务,这两行是没有的
            Executed_Gtid_Set: a9521767-c5a0-11ea-a743-08002792ac2c:1-2

                Auto_Position: 0
         Replicate_Rewrite_DB: 
                 Channel_Name: 
           Master_TLS_Version: 
1 row in set (0.00 sec)

 

查看binlog,并分析binlog
mysql> show binary logs;
+-------------------+-----------+
| Log_name          | File_size |
+-------------------+-----------+
| master-bin.000001 |       825 |
| master-bin.000002 |      4061 |
| master-bin.000003 |       177 |
| master-bin.000004 |       177 |
| master-bin.000005 |       824 |
+-------------------+-----------+
5 rows in set (0.01 sec)

使用mysqlbinlog查看binlog的内容

mysqlbinlog --no-defaults --database=lzldb  --start-datetime='2020-08-07 00:00:00' --stop-datetime='2020-08-07 18:00:00'  master-bin*> binloglzl1.log

 

截取片段:
# at 453
#200807 15:54:33 server id 1001  end_log_pos 501 CRC32 0xa43fdff7       Table_map: `lzldb`.`tab2` mapped to number 220
# at 501
#200807 15:54:33 server id 1001  end_log_pos 541 CRC32 0xed17d3b5       Write_rows: table id 220 flags: STMT_END_F

BINLOG '
uQgtXxPpAwAAMAAAAPUBAAAAANwAAAAAAAEABWx6bGRiAAR0YWIyAAEDAAH33z+k
uQgtXx7pAwAAKAAAAB0CAAAAANwAAAAAAAEAAgAB//4BAAAAtdMX7Q==
'/*!*/;   --数据操作已加密

# at 541
#200807 15:54:33 server id 1001  end_log_pos 572 CRC32 0x642b9289       Xid = 25


COMMIT /* added by mysqlbinlog *//*!*/;
# at 219
 

你可能感兴趣的:(MYSQL,BASIC,MYSQL,SLAVE,GTID,mysqlbinlog)