show master status


只有在主庫上執行才能有效抵輸出:

 

 

 

 

 

具體文檔如下:

# 在127.0.0.1:3306主庫上執行

tmp@127.0.0.1 ((none))> show variables like '%server%';
+---------------------------------+--------------------------------------+
| Variable_name                   | Value                                |
+---------------------------------+--------------------------------------+
| character_set_server            | utf8mb4                              |
| collation_server                | utf8mb4_general_ci                   |
| innodb_ft_server_stopword_table |                                      |
| server_id                       | 3232266753                           |
| server_id_bits                  | 32                                   |
| server_uuid                     | ceabbacf-0c77-11ea-b49f-2016d8c96b46 |
+---------------------------------+--------------------------------------+
6 rows in set (0.01 sec)
# 根據show variables like '%server_uuid%';
# 可以獲得當前mysql實例的server_uuid值

tmp@127.0.0.1 ((none))> show master status\G;
*************************** 1. row ***************************
             File: mysql-bin.000013
         Position: 269728976
     Binlog_Do_DB:
 Binlog_Ignore_DB:
Executed_Gtid_Set: 108cc4a4-0d40-11ea-9598-2016d8c96b66:1-5,
c42216ad-0d37-11ea-b163-2016d8c96b56:1-9,
ceabbacf-0c77-11ea-b49f-2016d8c96b46:1-1662590
1 row in set (0.00 sec)

ERROR:
No query specified

tmp@127.0.0.1 ((none))>

# 根據主庫上執行show master status\G;
# Executed_Gtid_Set值表明:每個server_uuid代表一個實例,有多個server_uuid表明這三個實例都曾經當過主庫,分別執行的事務個數都確定。在ceabbacf-0c77-11ea-b49f-2016d8c96b46實例上執行了1662590個事務,在c42216ad-0d37-11ea-b163-2016d8c96b56實例上執行了9個事務,在108cc4a4-0d40-11ea-9598-2016d8c96b66實例上執行了5個事務,但是並不知道這些實例之間事務執行的先后順序,當然同一個實例上的事務肯定是從1開始遞增,步長為1.結合該實例上的server_uuid可知道,當前主庫實例執行到了ceabbacf-0c77-11ea-b49f-2016d8c96b46:1-1662590這個位置上了。

# 根據File: mysql-bin.000013和Position: 269728976可知:當前寫的二進制日志文件名稱和位置是mysql-bin.000013:269728976,在文件mysql-bin.000013中有“end_log_pos 269728976”的地方就是這個位置,如下就是截取了mysql-bin.000013日志最后一部分內容:

# at 269728646
#191124 13:00:04 server id 3232266753  end_log_pos 269728707    GTID    last_committed=16       sequence_number=18      rbr_only=yes
/*!50718 SET TRANSACTION ISOLATION LEVEL READ COMMITTED*//*!*/;
SET @@SESSION.GTID_NEXT= 'ceabbacf-0c77-11ea-b49f-2016d8c96b46:1662590'/*!*/;
# at 269728707
#191124 13:00:04 server id 3232266753  end_log_pos 269728776    Query   thread_id=17    exec_time=0     error_code=0
SET TIMESTAMP=1574571604/*!*/;
BEGIN
/*!*/;
# at 269728776
#191124 13:00:04 server id 3232266753  end_log_pos 269728837    Rows_query
# update table_name set name='2' where id=2
# at 269728837
#191124 13:00:04 server id 3232266753  end_log_pos 269728890    Table_map: `apple`.`table_name` mapped to number 108
# at 269728890
#191124 13:00:04 server id 3232266753  end_log_pos 269728949    Update_rows: table id 108 flags: STMT_END_F
### UPDATE `apple`.`table_name`
### WHERE
###   @1=2 /* LONGINT meta=0 nullable=0 is_null=0 */
###   @2='8888' /* VARSTRING(1020) meta=1020 nullable=1 is_null=0 */
### SET
###   @1=2 /* LONGINT meta=0 nullable=0 is_null=0 */
###   @2='2' /* VARSTRING(1020) meta=1020 nullable=1 is_null=0 */
# at 269728949
#191124 13:00:04 server id 3232266753  end_log_pos 269728976    Xid = 119
COMMIT/*!*/;
SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/;
DELIMITER ;
# End of log file
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM