只有在主庫上執行才能有效抵輸出:
具體文檔如下:
# 在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*/;
https://www.cnblogs.com/igoodful/p/11922379.html
在MYSQL的主從復制中 ,通過命令show master status,可以查看master數據庫當前正在使用的二進制日志及當前執行二進制日志位置
show master logs,查看所有二進制日志列表 ,和show binary logs 同義。
show master status為空解決辦法
默認yum安裝了mysql,現在想調試一下主從,結果發現執行show master status為空。
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 2
Server version: 5.0.95 Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;’ or ‘h’ for help. Type ‘c’ to clear the current input statement.
mysql>
mysql> show master status;
Empty set (0.00 sec)
原來搞錯了主要配置文件的路徑,yum默認安裝mysql在/usr/shara/mysql下
需要執行:
cp /usr/shara/mysql/my-medium.cnf /etc/my.cnf
然后在my.cnf [mysqld]下加上主從配置就可以了。
server-id=1 #指定server ID
log-bin = /home/mysql-bin.log #開啟binlog
重啟mysql
mysql> show master status;
+——————+———-+————–+——————+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+——————+———-+————–+——————+
| mysql-bin.000001 | 98 | | |
+——————+———-+————–+——————+
1 row in set (0.00 sec)
http://imkerwin.com/166.html