mysql 5.7 enable binlog
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了mysql 5.7 enable binlog,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含4414字,纯文字阅读大概需要7分钟。
内容图文
![mysql 5.7 enable binlog](/upload/InfoBanner/zyjiaocheng/507/4362800e7389400da6f5089ace164cab.jpg)
we can see, the log_bin is disabled.
2. Turn on mysql log_bin
sudo vim /etc/mysql/conf.d/mysql.cnf
add the following config segment at the end of the file
# ---------------------------------------------- # Enable the binlog for replication & CDC # ---------------------------------------------- # Enable binary replication log and set the prefix, expiration, and log format. # The prefix is arbitrary, expiration can be short for integration tests but would # be longer on a production system. Row-level info is required for ingest to work. # Server ID is required, but this will vary on production systems server-id = 223344 log_bin = /var/lib/mysql/mysql-bin expire_logs_days = 3 binlog_format = row
#Mysql Packet Size may need to be re-configured. MySQL may have, by default, a ridiculously low allowable packet size.
#To increase it, you’ll need to have the property max_allowed_packet set to a higher number, say 1024M. max_allowed_packet=1024M
this configration means:
a) the server id is unique for each server, an is required for log_bin capture, it should be a numeric number equal or greater than 0, in my instance I set it to 223344, this number should be unique in the whole cluster. seems it‘s a good idea to set it as the ip
address number of the machine install. I fact I have do this in my real production enviroment.
b) the path of the log_bin, this is required to define the storage location fo the log_bin.
c) the log_bin retention time, in my case, I set it to 3 days.
d. the bin_log format, we should define it as row.
The whole definition file in my case is:
![mysql 5.7 enable binlog - 文章图片](/upload/getfiles/0001/2021/4/25/20210425070854225.jpg)
![mysql 5.7 enable binlog - 文章图片](/upload/getfiles/0001/2021/4/25/20210425070854250.jpg)
# For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html [mysqld] # # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M # # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M skip-host-cache skip-name-resolve #datadir=/var/lib/mysql #socket=/var/lib/mysql/mysql.sock #secure-file-priv=/var/lib/mysql-files user=mysql # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 #log-error=/var/log/mysqld.log #pid-file=/var/run/mysqld/mysqld.pid # ---------------------------------------------- # Enable the binlog for replication & CDC # ---------------------------------------------- # Enable binary replication log and set the prefix, expiration, and log format. # The prefix is arbitrary, expiration can be short for integration tests but would # be longer on a production system. Row-level info is required for ingest to work. # Server ID is required, but this will vary on production systems server-id = 223344 log_bin = /var/lib/mysql/mysql-bin expire_logs_days = 3 binlog_format = row #Mysql Packet Size may need to be re-configured. MySQL may have, by default, a ridiculously low allowable packet size. #To increase it, you’ll need to have the property max_allowed_packet set to a higher number, say 1024M. max_allowed_packet=1024MView Code
3. restart mysql service
systemctl restart mysql
after the mysql restarted, we use the command
show variables like ‘%log_bin%‘;
and we should found the log_bin is turned on now: log_bin | ON
then we go to file system, and can fould like this :
the log bin files are just there now!
-rw-r----- 1 mysql mysql 177 Apr 20 15:06 mysql-bin.000001
-rw-r----- 1 mysql mysql 154 Apr 20 15:22 mysql-bin.000002
-rw-r----- 1 mysql mysql 64 Apr 20 15:22 mysql-bin.index
Notes: every time we restart the mysql server instance, it will call flush logs and then create a new binlog file.
mysql 5.7 enable binlog
标签:number test star dir lease mysql-bin target 9.png alt
本文系统来源:https://www.cnblogs.com/lenmom/p/10743329.html
内容总结
以上是互联网集市为您收集整理的mysql 5.7 enable binlog全部内容,希望文章能够帮你解决mysql 5.7 enable binlog所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。