Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set expire_logs_days automatic expiration and clean up binlog in mysql

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

Editor to share with you how to set expire_logs_days to automatically expire and clean up binlog in mysql. I hope you will get something after reading this article. Let's discuss it together.

There is a relatively small system in production. It is found that mysql occupies a large space, which is caused by more binlog after investigation.

Check the expiration time of binlog. The set time is 90 days. By default, this value is 0 days, that is, it is not cleaned automatically and can be modified according to production conditions. In this case, it is changed to 7 days.

Mysql > show variables like 'expire_logs_days'

+-+ +

| | Variable_name | Value |

+-+ +

| | expire_logs_days | 90 | |

+-+ +

1 row in set (0.00 sec)

Mysql > set global expire_logs_days=7

Query OK, 0 rows affected (0.00 sec)

It will not be cleared immediately after it is set. The trigger condition is:

Binlog size exceeds max_binlog_size

Execute flush logs manually

On restart (MySQL will new a new file to record binlog)

We execute flush logs.

Mysql > flush logs

Query OK, 0 rows affected, 64 warnings (0.16 sec

If there are too many binlog, do not easily set and change parameters, which may lead to io contention. In this case, you can use the purge command to clear it:

Clear the binlog before bin.000055:

Mysql > purge binary logs to 'bin.000055'

Clear the binlog before the specified time:

Mysql > purge binary logs before '2017-05-01 13 purl 09purl 51'

After reading this article, I believe you have a certain understanding of "how to set up expire_logs_days automatic expiration cleaning binlog in mysql". If you want to know more about it, welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report