原由html
隨着系統運行,CentOS空間不斷減小,對此很是焦慮,到底磁盤空間被哪些新增文件佔用了呢?nginx
分析過程,主要使用du命令,逐層找出消耗空間的目錄lua
一、在根目錄下檢索一下文件的佔用狀況,執行du命令spa
[test@t-ng-01 /]$ sudo du -sh *rest
0 bin日誌
54M boothtm
0 devit
31M etcast
160M hometest
0 lib
0 lib64
0 media
24K mnt
0 opt
0 proc
56K root
673M run
0 sbin
0 srv
0 sys
0 tmp
12G usr
296M var
發現usr目錄佔用了12G!!
二、進入usr目錄,繼續執行du命令
[test@t-ng-01 /]$ cd /usr
[test@t-ng-01 usr]$ sudo du -sh *
107M bin
0 etc
0 games
12M include
441M lib
190M lib64
40M libexec
11G local
48M sbin
366M share
0 src
0 tmp
local目錄佔用了11G!!
三、進入local目錄繼續分析
[test@t-ng-01 usr]$ cd local
[test@t-ng-01 local]$ sudo du -sh *
0 bin
0 etc
0 games
0 include
0 lib
0 lib64
0 libexec
11G openresty
0 sbin
0 share
0 src
OpenResty目錄佔用11G,距離真相愈來愈近了
四、進入OpenResty目錄繼續分析
[test@t-ng-01 local]$ cd openresty
[test@t-ng-01 openresty]$ sudo du -sh *
148K bin
24K COPYRIGHT
12M luajit
576K lualib
11G nginx
2.7M pod
216K resty.index
0 site
五、進入Nginx目錄繼續分析
[test@t--ng-01 openresty]$ cd nginx
[test@t-ng-01 nginx]$ sudo du -sh *
151M bak
12K certs
0 client_body_temp
100K conf
72K conf-bak
92K conf-v2
82M data
24K data-v2
0 fastcgi_temp
8.0K html
9.4G logs
208K lua
120K lua-v2
512M on
40K proxy_temp
16M sbin
0 scgi_temp
0 uwsgi_temp
六、最後到Log目錄下探個究竟
[test@t-ng-01 nginx]$ cd logs
[test@t-ng-01 logs]$ sudo du -sh *
36K access-0621.log
710M access.log
2.9G access.log-20190101
2.8G access.log-20190102
3.0G access.log-20190103
192K error.log
908K error.log-20181221
940K error.log-20181222
872K error.log-20181223
840K error.log-20181224
880K error.log-20181225
924K error.log-20181226
976K error.log-20181227
116M error.log-20181228
1.3M error.log-20181229
1.1M error.log-20181230
1.0M error.log-20181231
908K error.log-20190101
844K error.log-20190102
7.1M error.log-20190103
4.0K nginx.pid
結論
一、 Nginx的訪問日誌歷史備份文件佔用了大部分磁盤空間,果斷刪除比較早的,只保留1天備份
二、 在Nginx根目錄下有一個異常的On文件,佔用512M空間,分析Nginx.conf文件,是某處設置錯誤,致使一直寫訪問日誌。