• Mysql设置主库binlog文件自动清理


    mysql主库中设置了打开binlog模式后,会在datadir目录下生成大量的日志文件,mysql默认是不会自动清理的,我们来设置下mysql自动清理binlog文件

    一、打开mysql

    [root@push-5-221 ~]# mysql -uroot  -p -S /var/lib/mysql/3306/mysql.sock
    Enter password: 
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 18786312
    Server version: 5.7.26-log MySQL Community Server (GPL)
    
    Copyright (c) 2000, 2019, 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 | 1073742330 |
    | master-221.000690 | 1073742640 |
    | master-221.000691 | 1073742135 |
    | master-221.000692 | 1073745009 |
    | master-221.000693 | 1073752964 |
    | master-221.000694 | 1073741900 |
    | master-221.000695 | 1073743774 |
    | master-221.000696 | 1073742434 |
    | master-221.000697 | 1073765838 |
    | master-221.000698 | 1073741976 |
    | master-221.000699 | 1073747163 |
    | master-221.000700 | 1073742572 |
    | master-221.000701 | 1073742412 |
    | master-221.000702 | 1073751913 |
    | master-221.000703 | 1073742548 |
    | master-221.000704 | 1073751141 |
    | master-221.000705 | 1073742720 |
    | master-221.000706 | 1073742493 |
    | master-221.000707 | 1073742684 |
    | master-221.000708 | 1073743787 |
    | master-221.000709 | 1073742104 |
    | master-221.000710 | 1073741879 |
    | master-221.000711 | 1073742618 |
    | master-221.000712 | 1073744563 |
    | master-221.000713 | 1073741975 |
    | master-221.000714 | 1073742720 |
    | master-221.000715 | 1073741974 |
    | master-221.000716 | 1073742362 |
    | master-221.000717 | 1073742761 |
    | master-221.000718 | 1073742778 |
    | master-221.000719 | 1073742199 |
    | master-221.000720 | 1073779470 |
    | master-221.000721 | 1073741880 |
    | master-221.000722 | 1073742598 |
    | master-221.000723 | 1073761923 |
    | master-221.000724 | 1073742172 |
    | master-221.000725 | 1073743665 |
    | master-221.000726 | 1073742798 |
    | master-221.000727 | 1073741959 |
    | master-221.000728 | 1073742084 |
    | master-221.000729 | 1073742838 |
    | master-221.000730 | 1073745927 |
    | master-221.000731 |  903202531 |
    +-------------------+------------+
    731 rows in set (0.00 sec)

    显示大量的日志文件

    通过设置expire_logs_days参数来实现自动删除binlog文件

    mysql> show variables like 'expire_logs_days';
    +------------------+-------+
    | Variable_name    | Value |
    +------------------+-------+
    | expire_logs_days | 0     |
    +------------------+-------+
    1 row in set (0.00 sec)
    
    mysql> 

    该参数表示binlog日志自动删除/过期的天数,默认值为0,表示不自动删除

    设置为10天过期

    mysql> set global expire_logs_days=10;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> show variables like 'expire_logs_days';
    +------------------+-------+
    | Variable_name    | Value |
    +------------------+-------+
    | expire_logs_days | 10    |
    +------------------+-------+
    1 row in set (0.00 sec)
    
    mysql> 
  • 相关阅读:
    asp.net webform 不显示__doPostBack的原因及某种解决方法
    sqlserver查询父子级关系
    使用gitblit搭建自己的代码存储仓库
    c# 十进制转二、八、十六进制
    asp.net webapi 返回json结果的方法
    每天CSS学习之text-indent
    每天CSS学习之text-decoration
    每天CSS学习之text-align
    每天CSS学习之line-height
    每天CSS学习之letter-spacing
  • 原文地址:https://www.cnblogs.com/sky-cheng/p/12034767.html
Copyright © 2020-2023  润新知