MySQL 5.7開啓二進制日誌注意事項

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

 

查了一下官方文檔16.1.6.4 Binary Logging Options and Variables以下所示, 若是沒有設置全局系統變量server_id,那麼MySQL就不容許啓動: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.sql

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

 

 

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

 

 

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.rest

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服務啓動失敗,可是在錯誤日誌裏面沒有錯誤信息輸出。看不到錯誤信息,可是啓動又失敗,你說暈不暈!code

 

 

service mysqld restartorm

Redirecting to /bin/systemctl restart  mysqld.serviceserver

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

相關文章
相關標籤/搜索