mysql show master status為空值


問題

執行show master status,輸出結果為空:

mysql> show master status;
Empty set (0.00 sec)

原因

mysql沒有開啟日志。
查看log_bin選項:

mysql> show variables like '%log_bin%';
+---------------------------------+-------+
| Variable_name                   | Value |
+---------------------------------+-------+
| log_bin                         | OFF   |
| log_bin_basename                |       |
| log_bin_index                   |       |
| log_bin_trust_function_creators | OFF   |
| log_bin_use_v1_row_events       | OFF   |
| sql_log_bin                     | ON    |
+---------------------------------+-------+
6 rows in set (0.00 sec)

可以看到log_bin是OFF.

解決方法

在mysql 配置文件 /etc/my.cnf中

[mysqld]下添加:

log-bin=mysql-bin

log-bin配置項表示binlog的base name,產生的日志文件名稱類似,mysql-bin.00001,mysql-bin.00002,mysql-bin.00003。

保存,重啟mysql服務。

mysql> SHOW MASTER STATUS\G
*************************** 1. row ***************************
             File: master-bin.000002
         Position: 1307
     Binlog_Do_DB: test
 Binlog_Ignore_DB: manual, mysql
Executed_Gtid_Set: 3E11FA47-71CA-11E1-9E33-C80AA9429562:1-5
1 row in set (0.00 sec)

show master status命令列出了日志位點信息,包括binlog file,binlog position等。

如果使用了GTID(global transaction ID),Executed_Gtid_Set表示已經在這個master上執行的GTID集合,與這個server上的系統變量gtid_executed 含義相同。

如果該server是slave,則執行show slave status中是輸出的對應列Executed_Gtid_Set,含義也相同。

參考

http://www.vsbclub.com/info/1024/1673.htm
show master status
17.1.4.4 Binary Log Options and Variables


免責聲明!

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



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