深圳市鸿华锐信息技术有限公司欢迎您!
服务创新提升价值!
百度地图| SiteMap| 知识库| 联系我们
全国服务热线:0755-88855786   深圳:13058107600

知识库

全国服务热线:
0755-88855786
深圳:
13058107600

清理Zabbix服务器上 MySQL 的 binlog

zabbix服务器上MYSQL占空间,发现binlog每个大小1G多:

删除Binlog:

[root@zabbix5 data]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 40075
Server version: 8.0.21 MySQL Community Server - GPL

Copyright (c) 2000, 2020, 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> show master logs;
+---------------+------------+-----------+
| Log_name      | File_size  | Encrypted |
+---------------+------------+-----------+
| binlog.000158 | 1073742177 | No        |
| binlog.000159 | 1073742069 | No        |
| binlog.000160 | 1073743376 | No        |
| binlog.000161 | 1073742669 | No        |
| binlog.000162 | 1073742083 | No        |
| binlog.000163 | 1073743613 | No        |
| binlog.000164 |  160199812 | No        |
| binlog.000165 |  947050252 | No        |
+---------------+------------+-----------+
8 rows in set (0.18 sec)

mysql> PURGE MASTER LOGS BEFORE DATE_SUB(CURRENT_DATE, INTERVAL 10 DAY);
Query OK, 0 rows affected (0.04 sec)

mysql> show master logs;
+---------------+------------+-----------+
| Log_name      | File_size  | Encrypted |
+---------------+------------+-----------+
| binlog.000163 | 1073743613 | No        |
| binlog.000164 |  160199812 | No        |
| binlog.000165 |  947079829 | No        |
+---------------+------------+-----------+
3 rows in set (0.00 sec)

mysql> reset master;
Query OK, 0 rows affected (0.09 sec)

mysql> exit




设置自动清理:

# 只保留7天内的 binlog 文件
mysql> set global binlog_expire_logs_seconds=60*60*168;


QQ客服在线咨询
业务咨询:
223883921
QQ客服在线咨询
技术支持:
56802890
联系方式
联系电话:
0755-88855786
微信客服
扫码二维码
返回顶部
✉ 

留言