比尔盖子 博客

清除并禁用 MySQL 的 Binary Logs

最近 MySQL 一下子飞黄腾达了,Binary Log 吃掉 800 MiB 多的硬盘空间,干扰了系统的正常运行。解决的方法有很多,包括直接删除文件,逐个使用 SQL 语句清除日志等。但我还是倾向于使用标准的操作方法。

清除已有日志

  1. 首先使用 mysql -u root -p 登录服务器。

  2. SHOW BINARY LOGS;

    首先看看我们有多少日志,占用了多少空间。真是不少啊。

    +-------------------+-----------+
    | Log_name          | File_size |
    +-------------------+-----------+
    | mysqld-bin.000001 |       264 |
    | mysqld-bin.000002 |      1546 |
    | mysqld-bin.000003 |     11728 |
    | mysqld-bin.000004 | 122291346 |
    | mysqld-bin.000005 |       264 |
    | mysqld-bin.000006 |       958 |
    | mysqld-bin.000007 |     85263 |
    | mysqld-bin.000008 |    467392 |
    | mysqld-bin.000009 |    271736 |
    | mysqld-bin.000010 |       264 |
    | mysqld-bin.000011 |      2670 |
    | mysqld-bin.000012 |   5258576 |
    | mysqld-bin.000013 |     25406 |
    | mysqld-bin.000014 |    430000 |
    | mysqld-bin.000015 |    560172 |
    | mysqld-bin.000016 |  45971600 |
    | mysqld-bin.000017 |  62227475 |
    | mysqld-bin.000018 | 223992121 |
    | mysqld-bin.000019 |  91294894 |
    | mysqld-bin.000020 |   4796916 |
    +-------------------+-----------+
    
  3. FLUSH LOGS;

  4. RESET MASTER;

关掉它

编辑 /etc/mysql/my.cnf,找到 log-bin 选项,注释掉;如果有 expire_logs_days,同样注释掉。

...
# log-bin
# expire_logs_days = 10
...

至此,Binary Logs 被彻底禁用。

Categories: IT生活

对《关于 yum 作者去世引发的地震》一文的澄清与道歉 » « 服务器 IP 变更

1 Comment

  1. 不错,很是值得关注!

发表评论

Your email address will not be published.

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax

Copyright © 2017 比尔盖子 博客

匿名浏览:http://x4wttqqrkud5pttgqlpxgevtr4rbqpa6lkwdiw3o3m6q4deeldgq.b32.i2p
警告:残留有明网混合资源,访问前请自行屏蔽明网流量

Theme by Anders NorenUp ↑