“Mysql binlog日志的三种模式介绍及模式修改”的版本间的差异
跳到导航
跳到搜索
(未显示同一用户的5个中间版本) | |||
第1行: | 第1行: | ||
+ | =站内资源 = | ||
+ | [[自动清理MySQL binlog日志]] | ||
=me= | =me= | ||
<pre> | <pre> | ||
第44行: | 第46行: | ||
重启mysql | 重启mysql | ||
</pre> | </pre> | ||
+ | |||
+ | == 删除bin-log日志== | ||
+ | <pre> | ||
+ | 1.查找当前有哪些二进制日志文件 | ||
+ | |||
+ | MySQL [(none)]> show binary logs; | ||
+ | +------------------+------------+ | ||
+ | | Log_name | File_size | | ||
+ | +------------------+------------+ | ||
+ | | mysql-bin.000561 | 1073747155 | | ||
+ | | mysql-bin.000562 | 1073784073 | | ||
+ | | mysql-bin.000563 | 1073742318 | | ||
+ | | mysql-bin.000564 | 1073742366 | | ||
+ | | mysql-bin.000565 | 1073741984 | | ||
+ | | mysql-bin.000566 | 1073741965 | | ||
+ | | mysql-bin.000567 | 1074758907 | | ||
+ | | mysql-bin.000568 | 75731888 | | ||
+ | +------------------+------------+ | ||
+ | |||
+ | .删除bin-log(删除mysql-bin.bin.000568之前的所有二进制日志文件) | ||
+ | |||
+ | purge binary logs to 'mysql-bin.000568' | ||
+ | |||
+ | |||
+ | # 重启后 如下 | ||
+ | MySQL [(none)]> show binary logs; | ||
+ | ERROR 1381 (HY000): You are not using binary logging | ||
+ | |||
+ | |||
+ | #2022 | ||
+ | mysql> show variables like '%server_id%'; | ||
+ | +----------------+-------+ | ||
+ | | Variable_name | Value | | ||
+ | +----------------+-------+ | ||
+ | | server_id | 1 | | ||
+ | | server_id_bits | 32 | | ||
+ | +----------------+-------+ | ||
+ | |||
+ | show variables like '%expire_logs%'; | ||
+ | |||
+ | |||
+ | mysql> show variables like '%expire_logs%'; | ||
+ | +----------------------------+-------+ | ||
+ | | Variable_name | Value | | ||
+ | +----------------------------+-------+ | ||
+ | | binlog_expire_logs_seconds | 0 | | ||
+ | | expire_logs_days | 2 | | ||
+ | +----------------------------+-------+ | ||
+ | |||
+ | |||
+ | |||
+ | set global expire_logs_days=1; | ||
+ | |||
+ | flush logs; | ||
+ | |||
+ | |||
+ | |||
+ | </pre> | ||
+ | |||
+ | [https://blog.csdn.net/xiewenbo/article/details/51283988 mysql关闭与删除bin-log日志详解] | ||
+ | |||
+ | [https://blog.csdn.net/wh987655/article/details/81449280 MySQL8.0 关闭log-bin 功能] | ||
=see also= | =see also= | ||
+ | [[自动清理MySQL binlog日志]] | ||
+ | |||
+ | =reference= | ||
[https://blog.csdn.net/jiang1013nan/article/details/6439503 MySQL binlog 格式(Mixed,Statement,Row Level)] | [https://blog.csdn.net/jiang1013nan/article/details/6439503 MySQL binlog 格式(Mixed,Statement,Row Level)] | ||
+ | [https://www.jianshu.com/p/32c7224115eb [mysql<nowiki>]</nowiki> Binlog的配置和使用] | ||
[https://blog.csdn.net/m0_37814112/article/details/78638359 Binlog日志的三种模式介绍及模式修改] | [https://blog.csdn.net/m0_37814112/article/details/78638359 Binlog日志的三种模式介绍及模式修改] |
2022年8月18日 (四) 05:40的最新版本
站内资源
me
以前是建议用row 而不要mixed 不过现在好像 mixed 好像也好些了 2.RBR:Row Based Replication 主服务器把表的行变化作为事件写入到二进制日志中,主服务器把代表了行变化的事件复制到从服务中,使用RBR的 长处: 所有的数据变化都是被复制,这是最安全的复制方式 更少的行级锁表 弊端: 日志会很大 不能通过查看日志来审计执行过的sql语句,不过可以通过使用mysqlbinlog --base64-output=decode-rows --verbose来查看数据的 变动 3.MBR:既使用SBR也使用RBR,默认使用SBR SBR:Statement Based Replication 当使用二进制日志时,主服务器会把SQL语句写入到日志中,然后从服务器会执行该日志,这就是SBR,在mysql5.1.4之前的版本都只能使用这种格式。使用SBR会有如下 长处: 日志文件更小 记录了所有的语句,可以用来日后审计 弊端: 使用如下函数的语句不能被正确地复制:load_file(); uuid(), uuid_short(); user(); found_rows(); sysdate(); get_lock(); is_free_lock(); is_used_lock(); master_pos_wait(); rand(); release_lock(); sleep(); version(); 在日志中出现如下警告信息的不能正确地复制:[Warning] Statement is not safe to log in statement format. 或者在客户端中出现show warnings Insert … select语句会执行大量的行级锁表 Update语句会执行大量的行级锁表来扫描整个表
Mysql binlog日志关闭以及删除bin-log日志
关闭binlog
#log-bin=mysql-bin #binlog_format=mixed 重启mysql
删除bin-log日志
1.查找当前有哪些二进制日志文件 MySQL [(none)]> show binary logs; +------------------+------------+ | Log_name | File_size | +------------------+------------+ | mysql-bin.000561 | 1073747155 | | mysql-bin.000562 | 1073784073 | | mysql-bin.000563 | 1073742318 | | mysql-bin.000564 | 1073742366 | | mysql-bin.000565 | 1073741984 | | mysql-bin.000566 | 1073741965 | | mysql-bin.000567 | 1074758907 | | mysql-bin.000568 | 75731888 | +------------------+------------+ .删除bin-log(删除mysql-bin.bin.000568之前的所有二进制日志文件) purge binary logs to 'mysql-bin.000568' # 重启后 如下 MySQL [(none)]> show binary logs; ERROR 1381 (HY000): You are not using binary logging #2022 mysql> show variables like '%server_id%'; +----------------+-------+ | Variable_name | Value | +----------------+-------+ | server_id | 1 | | server_id_bits | 32 | +----------------+-------+ show variables like '%expire_logs%'; mysql> show variables like '%expire_logs%'; +----------------------------+-------+ | Variable_name | Value | +----------------------------+-------+ | binlog_expire_logs_seconds | 0 | | expire_logs_days | 2 | +----------------------------+-------+ set global expire_logs_days=1; flush logs;
see also
reference
MySQL binlog 格式(Mixed,Statement,Row Level)
https://dev.mysql.com/doc/refman/5.5/en/replication-formats.html