Mysql设置主库binlog文件自动清理
mysql主库中设置了打开binlog模式后,会在datadir目录下生成大量的日志文件,mysql默认是不会自动清理的,我们来设置下mysql自动清理binlog文件
一、打开mysql
[root@push-- ~]# mysql -uroot -p -S /var/lib/mysql//mysql.sock
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.7.-log MySQL Community Server (GPL) Copyright (c) , , Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
二、 显示binlog文件
mysql> show binary logs;
| master-221.000689 | |
| master-221.000690 | |
| master-221.000691 | |
| master-221.000692 | |
| master-221.000693 | |
| master-221.000694 | |
| master-221.000695 | |
| master-221.000696 | |
| master-221.000697 | |
| master-221.000698 | |
| master-221.000699 | |
| master-221.000700 | |
| master-221.000701 | |
| master-221.000702 | |
| master-221.000703 | |
| master-221.000704 | |
| master-221.000705 | |
| master-221.000706 | |
| master-221.000707 | |
| master-221.000708 | |
| master-221.000709 | |
| master-221.000710 | |
| master-221.000711 | |
| master-221.000712 | |
| master-221.000713 | |
| master-221.000714 | |
| master-221.000715 | |
| master-221.000716 | |
| master-221.000717 | |
| master-221.000718 | |
| master-221.000719 | |
| master-221.000720 | |
| master-221.000721 | |
| master-221.000722 | |
| master-221.000723 | |
| master-221.000724 | |
| master-221.000725 | |
| master-221.000726 | |
| master-221.000727 | |
| master-221.000728 | |
| master-221.000729 | |
| master-221.000730 | |
| master-221.000731 | |
+-------------------+------------+
rows in set (0.00 sec)
显示大量的日志文件
通过设置expire_logs_days参数来实现自动删除binlog文件
mysql> show variables like 'expire_logs_days';
+------------------+-------+
| Variable_name | Value |
+------------------+-------+
| expire_logs_days | |
+------------------+-------+
row in set (0.00 sec) mysql>
该参数表示binlog日志自动删除/过期的天数,默认值为0,表示不自动删除
设置为10天过期
mysql> set global expire_logs_days=;
Query OK, rows affected (0.00 sec) mysql> show variables like 'expire_logs_days';
+------------------+-------+
| Variable_name | Value |
+------------------+-------+
| expire_logs_days | |
+------------------+-------+
row in set (0.00 sec) mysql>
Mysql设置主库binlog文件自动清理的更多相关文章
- 查看MySQL日志数据binlog文件
binlog介绍 binlog,即二进制日志,它记录了数据库上的所有改变. 改变数据库的SQL语句执行结束时,将在binlog的末尾写入一条记录,同时通知语句解析器,语句执行完毕. binlog格式 ...
- centos设置定时删除文件定时清理网站日志
1.进入linux系统 2.在任意目录创建一个sh后缀的文件,如: 3.编辑打开该文件,如图: 4.此时按键盘上的“i”键或者“insert”键,进入编辑模式 输入: #!/bin/shfind /d ...
- 必须了解的mysql三大日志-binlog、redo log和undo log
日志是 mysql 数据库的重要组成部分,记录着数据库运行期间各种状态信息.mysql日志主要包括错误日志.查询日志.慢查询日志.事务日志.二进制日志几大类.作为开发,我们重点需要关注的是二进制日志( ...
- 【原创】数据库基础之Mysql(3)mysql删除历史binlog
mysql开启binlog后会在/var/lib/mysql下创建binlog文件,如果手工删除,则下次mysql启动会报错: mysqld: File './master-bin.000001' n ...
- 自动清理MySQL binlog日志
开启MySQL binlog日志的服务器,如果不设置自动清理日志,默认binlog日志一直保留着,时间一长,服务器磁盘空间被binlog日志占满,导致MySQL数据库出错. 使用下面方法可以安全清理b ...
- MySQL binlog 自动清理脚本
# vim /data/scripts/delete_mysql_binlog.sh 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 ...
- 【转载】mysql binlog日志自动清理及手动删除
说明:当开启mysql数据库主从时,会产生大量如mysql-bin.00000* log的文件,这会大量耗费您的硬盘空间.mysql-bin.000001mysql-bin.000002mysql-b ...
- mysql binlog日志自动清理及手动删除
说明:当开启mysql数据库主从时,会产生大量如mysql-bin.00000* log的文件,这会大量耗费您的硬盘空间.mysql-bin.000001mysql-bin.000002mysql-b ...
- 小记---------maxwell 一个可以实时读取mysql二进制日志binlog,并生成JSON格式的消息,作为生产者发送给kafka,Redis,文件或其他平台的应用程序
maxwell主要提供了下列功能 支持 SELECT * FROM table 的方式进行全量数据初始化 支持在主库发生failover后,自动回复binlog位置(GTID) ...
随机推荐
- idea 中的new file 没有jsp
idea 的new file中没有你需要的文件,原因是IDEA认为当前包下不应该创建该文件,以就没有创建该文件的选项. 以jsp 文件为例.其他文件类似. 解决方法: File ---> pro ...
- DOTS概述
Unity数据导向技术栈有三个主要部分:Unity实体 - 组件 - 系统(ECS),Unity C#作业系统和Unity Burst编译器. 实体 - 组件 - 系统概述 ECS提供了一种游戏设计方 ...
- LeetCode.1185-一周中的星期几(Day of the Week)
这是小川的第415次更新,第448篇原创 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第266题(顺位题号是1185).给定日期,返回该日期的星期几.输入为三个整数,分别代表日,月和 ...
- fdisk中参数配置说明表
命令 描述 a 设置活动分区标志 b 编辑BSD Unix系统用的磁盘标签 c 设置DOS兼容标志 d 删除分区 l 显示可用的分区类型 m 显示命令选项(帮助) n 添加一个新的分区 o 创建DOS ...
- go爬虫系列
一.go语言爬取豆瓣电影top250 package main import ( "net/http" "io/ioutil" "os" & ...
- JS字符串格式化~欢迎来搂~~
/* 函数:格式化字符串 参数:str:字符串模板: data:数据 调用方式:formatString("api/values/{id}/{name}",{id:101,name ...
- Excel小技巧(随机点名)
如图,想要做一个随机点名的表格,同样可以石头剪刀布的场合,随机选人. 如何做呢? 第一步,填好想要的数据 第二步,在空的位置输入=INDIRECT("A"&RANDBETW ...
- 学习笔记:CentOS7学习之十三(1):硬盘介绍
1. SAS-SATA-SSD-SCSI-IDE硬盘讲解 1.1 常见硬盘类型: SAS硬盘:SAS(Serial Attached SCSI),串行连接SCSI接口,串行连接小型计算机系统接口.SA ...
- 微信JSAPI支付接口,支付完成后关闭当前窗口
一.把demo里的这一段: success: function (res) { // 支付成功后的回调函数 if (res.err_msg == "get_brand_wcpay_reque ...
- [转帖]postgres 创建新用户并授权-- 非常好的
postgres 创建新用户并授权 https://blog.csdn.net/XuHang666/article/details/81506297 原作者总结的挺好的 可以用来学习一下. grant ...