In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-10-22 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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.