代码改变世界

MySQL 5.7开启二进制日志注意事项

  潇湘隐者  阅读(3721)  评论(0编辑  收藏  举报

最近才开始将部分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

编辑推荐:
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
阅读排行:
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 没有源码,如何修改代码逻辑?
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
历史上的今天:
2017-07-11 RHEL 5.7 使用rpm安装XtraBackup问题总结
2017-07-11 ORACLE中修改表的Schema的总结
2015-07-11 mysqldump: Got error: 1142: SELECT, LOCK TABLES command denied to user 'root'@'localhost' for table 'accounts' when using LOCK TABLES
2015-07-11 MySQL备份还原——mysqldump工具介绍
2014-07-11 浅析SQL SERVER执行计划中的各类怪相
点击右上角即可分享
微信分享提示