今天看服务器探针,吓了我一跳,发现硬盘空间剩余6.2G左右。
详解mysql-bin.000001文件来源以及处理方法
仔细想想没有往服务器上传什么大的文件,也不能被黑(不起眼的小网站服务器)。于是,就逐一的检查"/"下的所有文件占用磁盘空间的大小。

[[email protected] ~]# du -s /* 
6160    /bin
19380    /boot
156    /dev
21700    /etc
2383236    /home
112372    /lib
16    /lost+found
4    /media
4    /mnt
4    /opt
du: 无法访问"/proc/2187/task/2187/fd/4": 没有那个文件或目录
du: 无法访问"/proc/2187/task/2187/fdinfo/4": 没有那个文件或目录
du: 无法访问"/proc/2187/fd/4": 没有那个文件或目录
du: 无法访问"/proc/2187/fdinfo/4": 没有那个文件或目录
0    /proc
56    /root
9488    /sbin
4    /selinux
4    /srv
0    /sys
14760    /tmp
37310312    /usr
90452    /var

发现/usr占用了大约37.3G的磁盘空间,然后进入/usr检查。

[[email protected] ~]#  du -s /usr/local/*
944    /usr/local/autoconf-2.13
472    /usr/local/bin
87568    /usr/local/eaccelerator_cache
4    /usr/local/etc
4    /usr/local/games
172    /usr/local/include
13824    /usr/local/ioncube
4100    /usr/local/lib
4    /usr/local/libexec
36    /usr/local/man
36436840    /usr/local/mysql
5108    /usr/local/nginx
53440    /usr/local/php
4    /usr/local/sbin
2620    /usr/local/share
4    /usr/local/src
900    /usr/local/zend

从返回的命令看出,占用最大的是/usr/local/mysql,继续检查。

[[email protected] ~]#  du -s /usr/local/mysql/var/*
552    /usr/local/mysql/var/0t9
71196    /usr/local/mysql/var/feifeicms
1640    /usr/local/mysql/var/[email protected]@002ecom
320    /usr/local/mysql/var/localhost.localdomain.err
4    /usr/local/mysql/var/localhost.localdomain.pid
1032    /usr/local/mysql/var/mysql
28    /usr/local/mysql/var/mysql-bin.000001
1048    /usr/local/mysql/var/mysql-bin.000002
4    /usr/local/mysql/var/mysql-bin.000003
4    /usr/local/mysql/var/mysql-bin.000004
4    /usr/local/mysql/var/mysql-bin.000005
5092    /usr/local/mysql/var/mysql-bin.000006
3808    /usr/local/mysql/var/mysql-bin.000007
508    /usr/local/mysql/var/mysql-bin.000008
8    /usr/local/mysql/var/mysql-bin.000009
4    /usr/local/mysql/var/mysql-bin.000010
72    /usr/local/mysql/var/mysql-bin.000011
16    /usr/local/mysql/var/mysql-bin.000012
36    /usr/local/mysql/var/mysql-bin.000013
116    /usr/local/mysql/var/mysql-bin.000014
4    /usr/local/mysql/var/mysql-bin.000015
44    /usr/local/mysql/var/mysql-bin.000016
84    /usr/local/mysql/var/mysql-bin.000017
976    /usr/local/mysql/var/mysql-bin.000018
36    /usr/local/mysql/var/mysql-bin.000019
628    /usr/local/mysql/var/mysql-bin.000020
872    /usr/local/mysql/var/mysql-bin.000021
1428    /usr/local/mysql/var/mysql-bin.000022
4    /usr/local/mysql/var/mysql-bin.000023
16    /usr/local/mysql/var/mysql-bin.000024
44    /usr/local/mysql/var/mysql-bin.000025
28    /usr/local/mysql/var/mysql-bin.000026
76    /usr/local/mysql/var/mysql-bin.000027
12    /usr/local/mysql/var/mysql-bin.000028
104    /usr/local/mysql/var/mysql-bin.000029
40    /usr/local/mysql/var/mysql-bin.000030
76    /usr/local/mysql/var/mysql-bin.000031
292    /usr/local/mysql/var/mysql-bin.000032
64    /usr/local/mysql/var/mysql-bin.000033
7852    /usr/local/mysql/var/mysql-bin.000034
96    /usr/local/mysql/var/mysql-bin.000035
44    /usr/local/mysql/var/mysql-bin.000036
100    /usr/local/mysql/var/mysql-bin.000037
28740    /usr/local/mysql/var/mysql-bin.000038
12    /usr/local/mysql/var/mysql-bin.000039
128    /usr/local/mysql/var/mysql-bin.000040
384    /usr/local/mysql/var/mysql-bin.000041
100    /usr/local/mysql/var/mysql-bin.000042
4    /usr/local/mysql/var/mysql-bin.000043
24    /usr/local/mysql/var/mysql-bin.000044
40    /usr/local/mysql/var/mysql-bin.000045
88    /usr/local/mysql/var/mysql-bin.000046
13920    /usr/local/mysql/var/mysql-bin.000047
41164    /usr/local/mysql/var/mysql-bin.000048
4    /usr/local/mysql/var/mysql-bin.000049
4    /usr/local/mysql/var/mysql-bin.000050
4    /usr/local/mysql/var/mysql-bin.000051
6320    /usr/local/mysql/var/mysql-bin.000052
5272    /usr/local/mysql/var/mysql-bin.000053
84    /usr/local/mysql/var/mysql-bin.000054
100    /usr/local/mysql/var/mysql-bin.000055
80    /usr/local/mysql/var/mysql-bin.000056
124    /usr/local/mysql/var/mysql-bin.000057
56    /usr/local/mysql/var/mysql-bin.000058
7556    /usr/local/mysql/var/mysql-bin.000059
6244    /usr/local/mysql/var/mysql-bin.000060
4    /usr/local/mysql/var/mysql-bin.000061
4    /usr/local/mysql/var/mysql-bin.000062
356    /usr/local/mysql/var/mysql-bin.000063
108    /usr/local/mysql/var/mysql-bin.000064
40    /usr/local/mysql/var/mysql-bin.000065
76    /usr/local/mysql/var/mysql-bin.000066
88    /usr/local/mysql/var/mysql-bin.000067
152    /usr/local/mysql/var/mysql-bin.000068
2648    /usr/local/mysql/var/mysql-bin.000069
84    /usr/local/mysql/var/mysql-bin.000070
108    /usr/local/mysql/var/mysql-bin.000071
52    /usr/local/mysql/var/mysql-bin.000072
104    /usr/local/mysql/var/mysql-bin.000073
172    /usr/local/mysql/var/mysql-bin.000074
408    /usr/local/mysql/var/mysql-bin.000075
848    /usr/local/mysql/var/mysql-bin.000076
72    /usr/local/mysql/var/mysql-bin.000077
36    /usr/local/mysql/var/mysql-bin.000078
56    /usr/local/mysql/var/mysql-bin.000079
80    /usr/local/mysql/var/mysql-bin.000080
236    /usr/local/mysql/var/mysql-bin.000081
104    /usr/local/mysql/var/mysql-bin.000082
324    /usr/local/mysql/var/mysql-bin.000083
3476    /usr/local/mysql/var/mysql-bin.000084
88    /usr/local/mysql/var/mysql-bin.000085
140    /usr/local/mysql/var/mysql-bin.000086
336    /usr/local/mysql/var/mysql-bin.000087
396    /usr/local/mysql/var/mysql-bin.000088
84    /usr/local/mysql/var/mysql-bin.000089
88    /usr/local/mysql/var/mysql-bin.000090
272    /usr/local/mysql/var/mysql-bin.000091
80    /usr/local/mysql/var/mysql-bin.000092
76    /usr/local/mysql/var/mysql-bin.000093
88    /usr/local/mysql/var/mysql-bin.000094
248    /usr/local/mysql/var/mysql-bin.000095
116    /usr/local/mysql/var/mysql-bin.000096
3028    /usr/local/mysql/var/mysql-bin.000097
64    /usr/local/mysql/var/mysql-bin.000098
220    /usr/local/mysql/var/mysql-bin.000099
64    /usr/local/mysql/var/mysql-bin.000100
76    /usr/local/mysql/var/mysql-bin.000101
80    /usr/local/mysql/var/mysql-bin.000102
208    /usr/local/mysql/var/mysql-bin.000103
64    /usr/local/mysql/var/mysql-bin.000104
64    /usr/local/mysql/var/mysql-bin.000105
64    /usr/local/mysql/var/mysql-bin.000106
240    /usr/local/mysql/var/mysql-bin.000107
64    /usr/local/mysql/var/mysql-bin.000108
68    /usr/local/mysql/var/mysql-bin.000109
68    /usr/local/mysql/var/mysql-bin.000110
184    /usr/local/mysql/var/mysql-bin.000111
64    /usr/local/mysql/var/mysql-bin.000112
68    /usr/local/mysql/var/mysql-bin.000113
64    /usr/local/mysql/var/mysql-bin.000114
 .....
4    /usr/local/mysql/var/mysql-bin.000335
4    /usr/local/mysql/var/mysql-bin.000336
15908    /usr/local/mysql/var/mysql-bin.000337
129536    /usr/local/mysql/var/mysql-bin.000338
181124    /usr/local/mysql/var/mysql-bin.000339
264004    /usr/local/mysql/var/mysql-bin.000340
8    /usr/local/mysql/var/mysql-bin.index
212    /usr/local/mysql/var/performance_schema
2792    /usr/local/mysql/var/wordpress

通过检查看到,好多mysql-bin.000XXX的文件(binlog日志),而且都还很大。这些日志文件太大了,对我来说用处不大,索性就直接给关闭了。

[[email protected] ~]# vi /etc/my.cnf 

在log-bin前面加上"#"
详解mysql-bin.000001文件来源以及处理方法
然后重启服务器,再次查看,就不会在产生日志文件了!

详解mysql-bin.000001文件来源以及处理方法