当前位置:网站首页>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开发全套学习资料》送给大家,初衷也很简单,就是希望帮助到想自学又不知道该从何学起的朋友,同时减轻大家的负担。添加下方名片,即可获取全套学习资料哦
边栏推荐
- MySql tens of millions of paging optimization, fast insertion method of tens of millions of data
- R语言ggpubr包的ggbarplot函数可视化分组柱状图、设置add参数为mean_se可视化不同水平均值的柱状图并为柱状图添加误差线(se标准误差)、position参数自定义分组柱状图分离
- MSYS2 QtCreator Clangd 代码分析找不到 mm_malloc.h的问题补救
- LayaBox---TypeScript---装饰器
- 软件测试的基本理论知识(软件测试面试基础知识)
- 一款优秀的中文识别库——ocr
- R语言使用zoo包中的rollapply函数以滚动的方式、窗口移动的方式将指定函数应用于时间序列、设置align参数指定结果数据中的时间标签取自窗口中的位置(参数right指定取自窗口的最右侧)
- 重磅大咖来袭!阿里云生命科学与智能计算峰会精彩内容剧透
- 瑞萨RZ/G2L处理器详细测评
- R language time series data arithmetic operation: use the log function to log the time series data, and use the diff function to calculate the successive difference of the logarithmic time series data
猜你喜欢
Rear tube implements breadcrumb function
Long battery life or safer?Seal and dark blue SL03 comparison shopping guide
Shell script realizes multi-select DNS simultaneous batch resolution of domain name IP addresses (new update)
QT专题:事件机制event基础篇
软件测试之发现和解决bug
The realization of the list
Turning and anti-climbing attack and defense
Jay Chou's new song is released, crawl the "Mojito" MV barrage, and see what the fans have to say!
【面向校招】Golang面试题合集
MySql tens of millions of paging optimization, fast insertion method of tens of millions of data
随机推荐
云原生应用平台的核心模块有哪些
众城优选系统开发功能
练习16-两道模拟题
games202:三,实时环境光照IBL + PRT
LayaBox---TypeScript---Namespaces and modules
周杰伦新歌发布,爬取《Mojito》MV弹幕,看看粉丝们都说的些啥!
QT专题:组合会话框和文本编辑器
The ggbarplot function of the R language ggpubr package visualizes the grouped histogram, sets the add parameter to mean_se to visualize the histogram of the mean values of different levels and adds
8月份的.NET Conf 活动 专注于 .NET MAUI
周鸿祎称微软抄袭 360 安全模式后发文否认;英特尔CEO基辛格回应市值被AMD超越:股价下跌是咎由自取|极客头条...
同样做软件测试,和月收入 3W 的学弟聊了一晚上,我彻底崩溃了
Verilog's random number system task----$random
Alibaba CTO Cheng Li: Alibaba Open Source History, Concept and Practice
Spearman's correlation coefficient
超赞!发现一个APP逆向神器!
软件测试岗位巨坑?阿里在职7年测试人告诉你千万别上当
如何安装dosbox(pycharm详细安装教程)
第十五章 多线程
日元疲软令游戏机在日本变身“理财产品”:黄牛大赚
QT专题:自定义部件