处理删除二进制日志后,show binary logs 显示File_size为0的情况

服务器硬盘空间占用过大,发现二进制日志文件过多,于是删除mysql的二进制日志文件:

[[email protected] mysql] # rm -rf dbbin.00010*
[[email protected] mysql] #  rm  -rf  dbbin.00010*
[[email protected] mysql] #  rm  -rf  dbbin.00011*
[[email protected] mysql] #  rm  -rf  dbbin.00012*

然后通过mysql命令行查看:

mysql> show binary logs;
+--------------+------------+
| Log_name     | File_size  |
+--------------+------------+
| dbbin.000001 |          0 |
| dbbin.000002 |          0 |
| dbbin.000003 |          0 |
| dbbin.000004 |          0 |
| dbbin.000005 |          0 |
| dbbin.000006 |          0 |
| dbbin.000007 |          0 |
| dbbin.000008 |          0 |
| dbbin.000009 |          0 |
| dbbin.000010 |          0 |
| dbbin.000011 |          0 |
| dbbin.000012 |          0 |
| dbbin.000013 |          0 |
| dbbin.000014 |          0 |
| dbbin.000015 |          0 |
| dbbin.000016 |          0 |
| dbbin.000017 |          0 |
| dbbin.000018 |          0 |
| dbbin.000019 |          0 |
| dbbin.000020 |          0 |
| dbbin.000021 |          0 |
| dbbin.000022 |          0 |
| dbbin.000023 |          0 |
| dbbin.000024 |          0 |
| dbbin.000025 |          0 |
| dbbin.000026 |          0 |
| dbbin.000027 |          0 |
| dbbin.000028 |          0 |
| dbbin.000029 |          0 |
| dbbin.000030 |          0 |
| dbbin.000031 |          0 |
| dbbin.000032 |          0 |
| dbbin.000033 |          0 |
| dbbin.000034 |          0 |
| dbbin.000035 |          0 |
| dbbin.000036 |          0 |
| dbbin.000037 |          0 |
| dbbin.000038 |          0 |
| dbbin.000039 |          0 |
| dbbin.000040 |          0 |
| dbbin.000041 |          0 |
| dbbin.000042 |          0 |
| dbbin.000043 |          0 |
| dbbin.000044 |          0 |
| dbbin.000045 |          0 |
| dbbin.000046 |          0 |
| dbbin.000047 |          0 |
| dbbin.000048 |          0 |
| dbbin.000049 |          0 |
| dbbin.000050 |          0 |
| dbbin.000051 |          0 |
| dbbin.000052 |          0 |
| dbbin.000053 |          0 |
| dbbin.000054 |          0 |
| dbbin.000055 |          0 |
| dbbin.000056 |          0 |
| dbbin.000057 |          0 |
| dbbin.000058 |          0 |
| dbbin.000059 |          0 |
| dbbin.000060 |          0 |
| dbbin.000061 |          0 |
| dbbin.000062 |          0 |
| dbbin.000063 |          0 |
| dbbin.000064 |          0 |
| dbbin.000065 |          0 |
| dbbin.000066 |          0 |
| dbbin.000067 |          0 |
| dbbin.000068 |          0 |
| dbbin.000069 |          0 |
| dbbin.000070 |          0 |
| dbbin.000071 |          0 |
| dbbin.000072 |          0 |
| dbbin.000073 |          0 |
| dbbin.000074 |          0 |
| dbbin.000075 |          0 |
| dbbin.000076 |          0 |
| dbbin.000077 |          0 |
| dbbin.000078 |          0 |
| dbbin.000079 |          0 |
| dbbin.000080 |          0 |
| dbbin.000081 |          0 |
| dbbin.000082 |          0 |
| dbbin.000083 |          0 |
| dbbin.000084 |          0 |
| dbbin.000085 |          0 |
| dbbin.000086 |          0 |
| dbbin.000087 |          0 |
| dbbin.000088 |          0 |
| dbbin.000089 |          0 |
| dbbin.000090 |          0 |
| dbbin.000091 |          0 |
| dbbin.000092 |          0 |
| dbbin.000093 |          0 |
| dbbin.000094 |          0 |
| dbbin.000095 |          0 |
| dbbin.000096 |          0 |
| dbbin.000097 |          0 |
| dbbin.000098 |          0 |
| dbbin.000099 |          0 |
| dbbin.000100 |          0 |
| dbbin.000101 |          0 |
| dbbin.000102 |          0 |
| dbbin.000103 |          0 |
| dbbin.000104 |          0 |
| dbbin.000105 |          0 |
| dbbin.000106 |          0 |
| dbbin.000107 |          0 |
| dbbin.000108 |          0 |
| dbbin.000109 |          0 |
| dbbin.000110 |          0 |
| dbbin.000111 |          0 |
| dbbin.000112 |          0 |
| dbbin.000113 |          0 |
| dbbin.000114 |          0 |
| dbbin.000115 |          0 |
| dbbin.000116 |          0 |
| dbbin.000117 |          0 |
| dbbin.000118 |          0 |
| dbbin.000119 |          0 |
| dbbin.000120 |          0 |
| dbbin.000121 |          0 |
| dbbin.000122 |          0 |
| dbbin.000123 |          0 |
| dbbin.000124 |          0 |
| dbbin.000125 |          0 |
| dbbin.000126 |          0 |
| dbbin.000127 |          0 |
| dbbin.000128 |          0 |
| dbbin.000129 |          0 |
| dbbin.000130 |          0 |
| dbbin.000131 |          0 |
| dbbin.000001 |          0 |
| dbbin.000002 |          0 |
| dbbin.000003 |          0 |
| dbbin.000004 |          0 |
| dbbin.000005 |          0 |
| dbbin.000006 |          0 |
| dbbin.000007 |          0 |
| dbbin.000008 |          0 |
| dbbin.000009 |          0 |
| dbbin.000010 |          0 |
| dbbin.000011 |          0 |
| dbbin.000012 |          0 |
| dbbin.000013 |          0 |
| dbbin.000014 |          0 |
| dbbin.000015 |          0 |
| dbbin.000016 |          0 |
| dbbin.000017 |          0 |
| dbbin.000018 |          0 |
| dbbin.000019 |          0 |
| dbbin.000020 |          0 |
| dbbin.000021 |          0 |
| dbbin.000022 |          0 |
| dbbin.000023 |          0 |
| dbbin.000024 |          0 |
| dbbin.000025 |          0 |
| dbbin.000026 |          0 |
| dbbin.000027 |          0 |
| dbbin.000028 |          0 |
| dbbin.000029 |          0 |
| dbbin.000030 |          0 |
| dbbin.000031 |          0 |
| dbbin.000032 |          0 |
| dbbin.000033 |          0 |
| dbbin.000034 |          0 |
| dbbin.000035 |          0 |
| dbbin.000036 |          0 |
| dbbin.000037 |          0 |
| dbbin.000038 |          0 |
| dbbin.000039 |          0 |
| dbbin.000040 |          0 |
| dbbin.000041 |          0 |
| dbbin.000042 |          0 |
| dbbin.000043 |          0 |
| dbbin.000044 |          0 |
| dbbin.000045 |          0 |
| dbbin.000046 |          0 |
| dbbin.000047 |          0 |
| dbbin.000048 |          0 |
| dbbin.000049 |          0 |
| dbbin.000050 |          0 |
| dbbin.000051 |          0 |
| dbbin.000052 |          0 |
| dbbin.000053 |          0 |
| dbbin.000054 |          0 |
| dbbin.000055 |          0 |
| dbbin.000056 |          0 |
| dbbin.000057 |          0 |
| dbbin.000058 |          0 |
| dbbin.000059 |          0 |
| dbbin.000060 |          0 |
| dbbin.000061 |          0 |
| dbbin.000062 |          0 |
| dbbin.000063 |          0 |
| dbbin.000064 |          0 |
| dbbin.000065 |          0 |
| dbbin.000066 |          0 |
| dbbin.000067 |          0 |
| dbbin.000068 |          0 |
| dbbin.000069 |          0 |
| dbbin.000070 |          0 |
| dbbin.000071 |          0 |
| dbbin.000072 |          0 |
| dbbin.000073 |          0 |
| dbbin.000074 |          0 |
| dbbin.000075 |          0 |
| dbbin.000076 |          0 |
| dbbin.000077 |          0 |
| dbbin.000078 |          0 |
| dbbin.000079 |          0 |
| dbbin.000080 |          0 |
| dbbin.000081 |          0 |
| dbbin.000082 |          0 |
| dbbin.000083 |          0 |
| dbbin.000084 |          0 |
| dbbin.000085 |          0 |
| dbbin.000086 |          0 |
| dbbin.000087 |          0 |
| dbbin.000088 |          0 |
| dbbin.000089 |          0 |
| dbbin.000090 |          0 |
| dbbin.000091 |          0 |
| dbbin.000092 |          0 |
| dbbin.000093 |          0 |
| dbbin.000094 |          0 |
| dbbin.000095 |          0 |
| dbbin.000096 |          0 |
| dbbin.000097 |          0 |
| dbbin.000098 |          0 |
| dbbin.000099 |          0 |
| dbbin.000100 |          0 |
| dbbin.000101 |          0 |
| dbbin.000102 |          0 |
| dbbin.000103 |          0 |
| dbbin.000104 |          0 |
| dbbin.000105 |          0 |
| dbbin.000106 |          0 |
| dbbin.000107 |          0 |
| dbbin.000108 |          0 |
| dbbin.000109 |          0 |
| dbbin.000110 |          0 |
| dbbin.000111 |          0 |
| dbbin.000112 |          0 |
| dbbin.000113 |          0 |
| dbbin.000114 |          0 |
| dbbin.000115 |          0 |
| dbbin.000116 |          0 |
| dbbin.000117 |          0 |
| dbbin.000118 |          0 |
| dbbin.000119 |          0 |
| dbbin.000120 |          0 |
| dbbin.000121 |          0 |
| dbbin.000122 |          0 |
| dbbin.000123 |          0 |
| dbbin.000124 |          0 |
| dbbin.000125 |          0 |
| dbbin.000126 |          0 |
| dbbin.000127 |          0 |
| dbbin.000128 |          0 |
| dbbin.000129 |          0 |
| dbbin.000130 |          0 |
| dbbin.000131 |          0 |
| dbbin.000132 |          0 |
| dbbin.000133 |          0 |
| dbbin.000134 |          0 |
| dbbin.000135 |  928716703 |
| dbbin.000136 |  959380747 |
| dbbin.000137 |  851723423 |
| dbbin.000138 |  365674634 |
| dbbin.000139 | 1073742052 |
| dbbin.000140 |  123579443 |
| dbbin.000141 |   30362973 |
| dbbin.000142 |  902470948 |
| dbbin.000143 |  889738300 |
| dbbin.000144 |  923650782 |
| dbbin.000145 | 1511748108 |
| dbbin.000146 |  290317434 |
| dbbin.000147 |      52264 |
+--------------+------------+
278 rows in set (0.00 sec)

看着很不爽,进行下一步的解决:

mysql> purge binary logs to 'dbbin.000133';
Query OK, 0 rows affected, 263 warnings (0.01 sec)

查看处理的结果:

mysql> show binary logs;
+--------------+------------+
| Log_name     | File_size  |
+--------------+------------+
| dbbin.000133 |          0 |
| dbbin.000134 |          0 |
| dbbin.000135 |  928716703 |
| dbbin.000136 |  959380747 |
| dbbin.000137 |  851723423 |
| dbbin.000138 |  365674634 |
| dbbin.000139 | 1073742052 |
| dbbin.000140 |  123579443 |
| dbbin.000141 |   30362973 |
| dbbin.000142 |  902470948 |
| dbbin.000143 |  889738300 |
| dbbin.000144 |  923650782 |
| dbbin.000145 | 1511748108 |
| dbbin.000146 |  290317434 |
| dbbin.000147 |    3826433 |
+--------------+------------+
15 rows in set (0.00 sec)

再处理一下:

mysql> purge binary logs to 'dbbin.000135';
Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql> show binary logs;
+--------------+------------+
| Log_name     | File_size  |
+--------------+------------+
| dbbin.000135 |  928716703 |
| dbbin.000136 |  959380747 |
| dbbin.000137 |  851723423 |
| dbbin.000138 |  365674634 |
| dbbin.000139 | 1073742052 |
| dbbin.000140 |  123579443 |
| dbbin.000141 |   30362973 |
| dbbin.000142 |  902470948 |
| dbbin.000143 |  889738300 |
| dbbin.000144 |  923650782 |
| dbbin.000145 | 1511748108 |
| dbbin.000146 |  290317434 |
| dbbin.000147 |    4443351 |
+--------------+------------+
13 rows in set (0.00 sec)

看着是不是舒服很多?

时间: 2024-10-23 03:35:39

处理删除二进制日志后,show binary logs 显示File_size为0的情况的相关文章

mysql删除二进制日志文件

一.RESET MASTER 这个语句可以验证首次配置主机备机是否成功.步骤如下: 1. 启动master和 slave,开启replication (即 复制) 注:replication (复制) 也是mysql一个重要的技术 2.运行一些测试的语句看数据是否能够复制到 slave上面 3.当复制运行正常的话,就 stop slace 然后在slave上面执行 reset slave,去掉不需要的数据 4.在master上面执行reset master 去掉2中产生的数据 可以删除列于索引文

dataguard主库删除归档日志后从库恢复的方法

------------------方法1在主库上使用备份的进行恢复丢失的归档日志-------------------------1.发现主库备份后删除了归档,但是这些归档从库还没应用,也没有传到从库从库应用的最新的归档日志为592SQL> connect / as sysdbaConnected.SQL> Select Max(t.SEQUENCE#) From V$archived_Log t; MAX(T.SEQUENCE#)---------------- 592 主库的归档日志SQ

MYSQL 删除二进制日志的 3 个方法

方法 1: reset master; ------------------ 删除前: 删除日志: 删除后: ----------------------------------------    可以看出只留下了一个日志文件        ------------------------------------------- 方法 2: purge master logs to 'file_name'; 删除前: 运行删除: 删除后: 第三种:purge master logs to 'yyy

SQL SERVER 数据日志太大,磁盘没有空间,直接删除数据库日志后,显示 恢复挂起。

问题简述: sharepoint的某个站点对应的数据库日志太大了,想把日志瘦身.于是我把整个数据库分离,然后附加数据库来重新生成日志文件.谁知道在附加的时候,居然报错"附加数据库报错:由于数据库没有完全关闭,无法重新生成日志" 问题原因:原因是数据库关闭时存在打开的事务/用户,该数据库没有检查点或者该数据库是只读的.如果事务日志文件被手动删除或者由于硬件或环境问题而丢失,则可能出现此错误. 处理办法: 一.把分离之前的日志文件也复制过来一齐附加嘛从错误提示看, 应该是你的日志文件中还包

关系型数据库之Mysql二进制日志管理(四)

MySQL二进制日志(Binary Log)1.它包含的内容及作用如下:包含了所有更新了数据或者已经潜在更新了数据(比如没有匹配任何行的一个DELETE)包含关于每个更新数据库(DML)的语句的执行时间信息不包含没有修改任何数据的语句,如果需要启用该选项,需要开启通用日志功能主要目的是尽可能的将数据库恢复到数据库故障点,因为二进制日志包含备份后进行的所有更新用于在主复制服务器上记录所有将发送给从服务器的语句启用该选项数据库性能降低1%,但保障数据库完整性,对于重要数据库值得以性能换完整.有些类似

mysql二进制日志的使用

mysql二进制日志也就是一些mysql命令操作的记录 删除二进制日志信息: 二进制日志会记录大量的信息(其中包含一些无用的信息).如果很长时间不清理二进制日志,将会浪费很多的磁盘空间.但是,删除之后可能导致数据库崩溃时无法进行恢复,所以若要删除二进制日志首先将其和数据库备份一份,其中也只能删除备份前的二进制日志,新产生的日志信息不可删(可以做即时点还原).也不可在关闭mysql服务器之后直接删除因为这样可能会给数据库带来错误的.若非要删除二进制日志需要做如下操作:导出备份数据库和二进制日志文件

MySQL 二进制日志(Binary Log)

同大多数关系型数据库一样,日志文件是MySQL数据库的重要组成部分.MySQL有几种不同的日志文件,通常包括错误日志文件,二进制日志,通用日志,慢查询日志,等等.这些日志可以帮助我们定位mysqld内部发生的事件,数据库性能故障,记录数据的变更历史,用户恢复数据库等等.二进制日志,也叫binary log,是MySQL Server中最为重要的日志之一,本文主要描述二进制日志. 1.MySQL日志文件系统的组成   a.错误日志:记录启动.运行或停止mysqld时出现的问题.   b.通用日志:

MySQL二进制日志(binary log)总结

本文出处:http://www.cnblogs.com/wy123/p/7182356.html (保留出处并非什么原创作品权利,本人拙作还远远达不到,仅仅是为了链接到原文,因为后续对可能存在的一些错误进行修正或补充,无他) 今天无意中发现了一个云栖社区举行的MySQL“第一季:挑战玄惭之 慢SQL性能优化赛”,在测试服务器上执行其测试脚本写入数据的时候报错提示如下,Multi-statement transaction required more than 'max_binlog_cache_

MySQl Study学习之--MySQl二进制日志管理

MySQl Study学习之--MySQl二进制日志管理 MySQL二进制日志(Binary Log):   a.它包含的内容及作用如下:    包含了所有更新了数据或者已经潜在更新了数据(比如没有匹配任何行的一个DELETE)    包含关于每个更新数据库(DML)的语句的执行时间信息    不包含没有修改任何数据的语句,如果需要启用该选项,需要开启通用日志功能    主要目的是尽可能的将数据库恢复到数据库故障点,因为二进制日志包含备份后进行的所有更新    用于在主复制服务器上记录所有将发送