当前位置:网站首页>mysql清除binlog日志文件
mysql清除binlog日志文件
2022-08-02 10:15:00 【免费的东西】
清理前的准备:
1) 查看主库和从库正在使用的binlog是哪个文件
show master statusG
show slave statusG
2) 在删除binlog日志之前,首先对binlog日志备份,以防万一
注意:
时间和文件名一定不可以写错,尤其是时间中的年和文件名中的序号,以防不小心将正在使用的binlog删除!!!
切勿删除正在使用的binlog!!!
如果binlog非常多,不要轻易设置改参数去删除,有可能导致io争用!!!
purge master logs before’2016-09-01 17:20:00’; //删除指定日期以前的日志索引中binlog日志文件
purge master logs to’mysql-bin.000022’; //删除指定日志文件的日志索引中binlog日志文件
3)注意:
过期时间参数设置的要适当,对于主从复制,要看从库的延迟决定过期时间,避免主库binlog还未传到从库便因过期而删除,导致主从不一致!!!
方式一:设置过期时间(如果binlog非常多,不要轻易设置改参数,有可能导致io争用)
查看binlog过期时间,这个值默认是0天,也就是说不自动清理;可以根据生产情况修改,本例修改为30天
mysql> show variables like ‘expire_logs_days’;
±-----------------±------+
| Variable_name | Value |
±-----------------±------+
| expire_logs_days | 0 |
±-----------------±------+
1 row in set (0.00 sec)
mysql> set global expire_logs_days=30;
设置之后不会立即清除,触发条件是:
1)binlog大小超过max_binlog_size
2)手动执行flush logs
3)重新启动时(MySQL 将会new一个新文件用于记录binlog)
我们执行flush logs;
mysql> flush logs;
Query OK, 0 rows affected, 64 warnings (0.16 sec
方式二:使用purge命令予以清除:
将bin.000055之前的binlog清掉:
mysql>purge binary logs to ‘bin.000055’;
将指定日期之前的binlog清掉:
mysql>purge binary logs before ‘2017-05-01 13:09:51’;
清除60天前的 binlog
mysql>purge master logs before date_sub( NOW( ), INTERVAL 60 DAY);
先自我介绍一下,小编13年上师交大毕业,曾经在小公司待过,去过华为OPPO等大厂,18年进入阿里,直到现在。深知大多数初中级java工程师,想要升技能,往往是需要自己摸索成长或是报班学习,但对于培训机构动则近万元的学费,着实压力不小。自己不成体系的自学效率很低又漫长,而且容易碰到天花板技术停止不前。因此我收集了一份《java开发全套学习资料》送给大家,初衷也很简单,就是希望帮助到想自学又不知道该从何学起的朋友,同时减轻大家的负担。添加下方名片,即可获取全套学习资料哦
边栏推荐
- 练习16-两道模拟题
- Shell脚本实现多选DNS同时批量解析域名IP地址(新更新)
- R language ggplot2 visualization: use the ggbarplot function of the ggpubr package to visualize the stacked bar plot, the lab.pos parameter specifies the position of the numerical label of the bar cha
- npm ERR! 400 Bad Request - PUT xxx - Cannot publish over previously published version “1.0.0“.
- 享年94岁,图灵奖得主、计算复杂性理论先驱Juris Hartmanis逝世
- SVN如何删除文件名包含空格的文件
- 如何选择一块真正“好用的、性能高”的远程控制软件
- Why use BGP?
- LayaBox---TypeScript---声明合并
- LayaBox---TypeScript---三斜线指令
猜你喜欢

基于列表的排队与叫号系统

QT专题:组合会话框和文本编辑器

超赞!发现一个APP逆向神器!

第十七章 Excel操作

Linux system uninstall, install, upgrade, migrate clickHouse database

新“内卷”席卷科技圈,Google CEO 要求 174000 员工提高工作效率!

软件测试岗位巨坑?阿里在职7年测试人告诉你千万别上当

After 21 years of graduation, I switched to software testing. From 0 income to a monthly salary of over 10,000, I am really lucky...

Verilog's random number system task----$random

MSYS2 QtCreator Clangd 代码分析找不到 mm_malloc.h的问题补救
随机推荐
QT专题:组合会话框和文本编辑器
行为型模式-模板方法模式
R language ggplot2 visualization: use the ggbarplot function of the ggpubr package to visualize the horizontal column chart (bar chart), use the orientation parameter to set the column chart to be tra
如何安装dosbox(pycharm详细安装教程)
Com多进程通信实现
R语言使用zoo包中的rollapply函数以滚动的方式、窗口移动的方式将指定函数应用于时间序列、设置align参数指定结果数据中的时间标签取自窗口中的位置(参数right指定取自窗口的最右侧)
Getting Started with SCM from Scratch (1): Summary of Background Knowledge
Smoothing of time series data in R language: smoothing time series data to remove noise using the dpill function and locpoly function of the KernSmooth package
logo 图标(php图片加文字水印)
软件测试的基本理论知识(软件测试面试基础知识)
软件测试X模型
sqlmap安装教程用w+r打开(sqlyog安装步骤)
R语言ggplot2可视化:使用ggpubr包的ggbarplot函数可视化水平柱状图(条形图)、使用orientation参数设置柱状图转置为条形图
qq邮箱日发5万邮件群发技术(qq邮箱怎样定时发送邮件)
使用较广泛的安全测试工具有哪些?
阿里巴巴 CTO 程立:开源是基础软件的源头!
Rust 从入门到精通03-helloworld
ConvNeXt论文及实现
斯皮尔曼相关系数
games202:三,实时环境光照IBL + PRT