MySQL 5.7開啟二進制日志注意事項


最近才開始將部分MySQL 5.6升級到MySQL 5.7, 在開啟MySQL的二進制日志時,發現MySQL 5.7 MySQL 5.6已有細微區別。如果在my.cnf配置文件中,只設置了全局系統變量log_bin,沒有設置全局系統變量server_id的話,那么MySQL啟動不了,而且錯誤日志沒有任何錯誤信息。

 

查了一下官方文檔16.1.6.4 Binary Logging Options and Variables如下所示, 如果沒有設置全局系統變量server_id,那么MySQL就不允許啟動:

 

 

Setting this option causes the log_bin system variable to be set to ON (or 1), and not to the base name. The binary log file base name and any specified path are available as the log_bin_basename system variable.

If you specify the --log-bin option without also specifying a --server-id, the server is not allowed to start. (Bug #11763963, Bug #56739)

 

 

       官方文檔Changes in MySQL 5.7.3 (2013-12-03, Milestone 13)詳細介紹如下:

 

 

Important Change; Replication: It was possible to start the server with binary logging enabled but no server ID specified; in such cases, the server would set server_idto 1 (rather than 0) while slaves remained unable to connect.

Now --server-id must be used when starting the server with binary logging enabled, otherwise the server is unable to start. If --server-id=0 is used, this value is no longer changed by the server; in this case, updates are written to the binary log, but slaves are unable to connect. Using --server-id without specifying a value has the same effect as setting it explicitly to 0. (Bug #11763963, Bug #56739)

 

 

也就是說,從MySQL 5.7.3以后版本必須配置server-id,否則無法啟用MySQL二進制日志,雖然這個知識點沒啥技術含量,但是如果不了解的話,就會犯懵:因為MySQL服務啟動失敗,但是在錯誤日志里面沒有錯誤信息輸出。看不到錯誤信息,但是啟動又失敗,你說暈不暈!

 

 

service mysqld restart

Redirecting to /bin/systemctl restart  mysqld.service

Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.

 

 

參考資料

 

https://dev.mysql.com/doc/refman/5.7/en/replication-options-binary-log.html#sysvar_log_bin

 

https://dev.mysql.com/doc/relnotes/mysql/5.7/en/news-5-7-3.html


免責聲明!

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



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