最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Linux 查看空間使用情況的實例詳解

 更新時間:2017年10月10日 14:07:44   作者:貓頭鷹工作室  
這篇文章主要介紹了Linux 查看空間使用情況的實例詳解的相關(guān)資料,希望通過本文能幫助到大家,讓大家理解掌握如何實現(xiàn),需要的朋友可以參考下

Linux 查看空間使用情況的實例詳解

在日常的Linux巡檢中,我們會遇到文件系統(tǒng)目錄使用空間很高的情況,例如如下利用”df -h “查看到根目錄空間使用超過80%。而我們僅僅知道是根目錄空間使用過高,這樣是不夠的。還需要知道是目錄還是文件讓根目錄空間使用過高。通常我們使用的命令是”du -sh *”。

第一步:查看Linux系統(tǒng)的文件系統(tǒng)使用情況,如下可以看到根目錄”/”已經(jīng)使用81%。


[root@hostname ~]# df -h
Filesystem      Size Used Avail Use% Mounted on
/dev/sda6       67G  51G  13G 81% /
tmpfs         16G 152K  16G  1% /dev/shm
/dev/sda3       99G 188M  94G  1% /arch
/dev/sda1       197G 188M 187G  1% /u01
/dev/sda2       197G  50G 138G 27% /u02


第二步:進(jìn)入根目錄,利用du -sh 命令查詢各個目錄或者文件占用空間的情況,因為/u02是獨立的文件系統(tǒng),所以可以忽略。我們關(guān)注的是root這個目錄,占用了空間47G。

[root@hostname ~]# cd /

[root@hostname /]# du -sh *
20K   arch
7.6M  bin
27M   boot
324K  dev
36M   etc
36K   home
136M  lib
26M   lib64
16K   lost+found
4.0K  media
0    misc
4.0K  mnt
0    net
8.0K  opt
4.0K  orbit-root
--省略/proc目錄統(tǒng)計的報錯
0    proc
47G   root  ##根目錄文件系統(tǒng)使用最大的目錄
15M   sbin
0    selinux
4.0K  srv
0    sys
80K   tmp
20K   u01
49G   u02

第三步:進(jìn)入root目錄,其實也是root用戶的主目錄。我們從ls命令可以猜到可能是【apache-tomcat-6.0.36-linux】這個tomcat的程序目錄占用比較多。

[root@hostname /]# cd root
[root@hostname ~]# ls
anaconda-ks.cfg apache-tomcat-6.0.36-linux Desktop Documents Downloads install.log install.log.syslog Music Pictures Public Templates Videos

第四步:通過統(tǒng)計發(fā)現(xiàn),確實是【apache-tomcat-6.0.36-linux】這個目錄占用了47G。但是到此問題還沒有結(jié)束,因為既然是應(yīng)用程序的目錄,根據(jù)我的經(jīng)驗很可能是tomcat的日志文件占用空間比較多。

[root@hostname ~]# du -sh *
4.0K  anaconda-ks.cfg
47G   apache-tomcat-6.0.36-linux
4.0K  Desktop
4.0K  Documents
4.0K  Downloads
56K   install.log
12K   install.log.syslog
4.0K  Music
4.0K  Pictures
4.0K  Public
4.0K  Templates
4.0K  Videos

第五步:既然看到有tomcat的目錄,很可能這個tomcat運(yùn)行著,利用ps命令查看是否有tomcat的進(jìn)程,一般可以過濾java這個關(guān)鍵詞。如下,果然有tomcat在運(yùn)行著。那么很可能占用空間最多就是tomcat的日志文件。

[root@hostname ~]# ps -ef|grep java
root   4879 4836 0 08:26 pts/0  00:00:00 grep java
root   11864   1 47 Aug16 ?    26-03:11:29 /usr/bin/java -Djava.util.logging.config.file=/root/apache-tomcat-6.0.36-linux/conf/logging.properties -Xms512m -Xmx1024m -XX:PermSize=128M -XX:MaxPermSize=256m -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/root/apache-tomcat-6.0.36-linux/endorsed -classpath /root/apache-tomcat-6.0.36-linux/bin/bootstrap.jar -Dcatalina.base=/root/apache-tomcat-6.0.36-linux -Dcatalina.home=/root/apache-tomcat-6.0.36-linux -Djava.io.tmpdir=/root/apache-tomcat-6.0.36-linux/temp org.apache.catalina.startup.Bootstrap start

第六步:進(jìn)入tomcat的程序目錄,查看哪個目錄占用的空間最大。如下,發(fā)現(xiàn)是一個【fare】的目錄占用了46G,而【logs】是日志目錄卻占用了23M。

[root@hostname ~]# cd apache-tomcat-6.0.36-linux
[root@hostname apache-tomcat-6.0.36-linux]# ls
backup bin conf fare lib LICENSE logs NOTICE RELEASE-NOTES RUNNING.txt temp webapps work
[root@hostname apache-tomcat-6.0.36-linux]# du -sh *
92K   backup
882M  bin
108K  conf
46G   fare
6.8M  lib
40K   LICENSE
23M   logs
4.0K  NOTICE
12K   RELEASE-NOTES
16K   RUNNING.txt
7.9M  temp
188M  webapps
7.1M  work

第七步:繼續(xù)一探究竟【fare】目錄里面到底存放的是什么類型的目錄或者文件。如下看到有很多類似日志文件,如common.log和pricing.log。通過和開發(fā)人員溝通之后,確定確實日志文件。

[root@hostname apache-tomcat-6.0.36-linux]# cd fare
[root@hostname fare]# ls
common.log       common.log.2017-09-21 common.log.2017-10-03   pricing.log.2017-09-10 pricing.log.2017-09-22 pricing.log.2017-10-04
common.log.2017-09-10 common.log.2017-09-22 common.log.2017-10-04   pricing.log.2017-09-11 pricing.log.2017-09-23 pricing.log.2017-10-05
common.log.2017-09-11 common.log.2017-09-23 common.log.2017-10-05   pricing.log.2017-09-12 pricing.log.2017-09-24 pricing.log.2017-10-06
common.log.2017-09-12 common.log.2017-09-24 common.log.2017-10-06   pricing.log.2017-09-13 pricing.log.2017-09-25 pricing.log.2017-10-07
common.log.2017-09-13 common.log.2017-09-25 common.log.2017-10-07   pricing.log.2017-09-14 pricing.log.2017-09-26 pricing.log.2017-10-08
common.log.2017-09-14 common.log.2017-09-26 common.log.2017-10-08   pricing.log.2017-09-15 pricing.log.2017-09-27 pricing.log.2017-10-09
common.log.2017-09-15 common.log.2017-09-27 common.log.2017-10-09   pricing.log.2017-09-16 pricing.log.2017-09-28 spring.log
common.log.2017-09-16 common.log.2017-09-28 common.zip        pricing.log.2017-09-17 pricing.log.2017-09-29 struts2.log
common.log.2017-09-17 common.log.2017-09-29 framework.log       pricing.log.2017-09-18 pricing.log.2017-09-30 xwork2.log
common.log.2017-09-18 common.log.2017-09-30 hibernate.log       pricing.log.2017-09-19 pricing.log.2017-10-01
common.log.2017-09-19 common.log.2017-10-01 hibernate.log.2017-01-03 pricing.log.2017-09-20 pricing.log.2017-10-02
common.log.2017-09-20 common.log.2017-10-02 pricing.log        pricing.log.2017-09-21 pricing.log.2017-10-03

第八步:繼續(xù)查看哪個目錄或者文件占用的空間最大,發(fā)現(xiàn)都是common.log和pricing.log相關(guān)的文件占用的空間最大,都是700M以上。至此,已經(jīng)查明占用根目錄”/”空間最多的原因是tomcat的日志文件太多,而且每一個日志文件都很大。

[root@hostname fare]# du -sh *|sort -h
0    framework.log
0    hibernate.log.2017-01-03
0    spring.log
0    struts2.log
0    xwork2.log
4.0K  hibernate.log
17M   common.zip
215M  pricing.log
216M  common.log
667M  pricing.log.2017-10-08
668M  common.log.2017-10-08
674M  common.log.2017-10-05
674M  pricing.log.2017-10-05
678M  common.log.2017-10-07
678M  pricing.log.2017-10-07
679M  common.log.2017-10-06
679M  pricing.log.2017-10-06
683M  common.log.2017-10-04
683M  pricing.log.2017-10-04
690M  pricing.log.2017-09-10
691M  common.log.2017-09-10
711M  common.log.2017-09-12
711M  pricing.log.2017-09-12
719M  pricing.log.2017-09-11
720M  common.log.2017-09-11
737M  common.log.2017-09-30
737M  pricing.log.2017-09-28
737M  pricing.log.2017-09-30
738M  common.log.2017-09-28
742M  common.log.2017-09-29
742M  pricing.log.2017-09-29
744M  pricing.log.2017-10-09
745M  common.log.2017-10-09
751M  common.log.2017-10-01
751M  pricing.log.2017-10-01
754M  common.log.2017-09-13
754M  pricing.log.2017-09-13
760M  common.log.2017-10-03
760M  pricing.log.2017-10-03
783M  pricing.log.2017-10-02
784M  common.log.2017-10-02
791M  pricing.log.2017-09-18
792M  common.log.2017-09-18
797M  common.log.2017-09-27
797M  pricing.log.2017-09-27
804M  common.log.2017-09-17
804M  common.log.2017-09-19
804M  pricing.log.2017-09-17
804M  pricing.log.2017-09-19
808M  common.log.2017-09-26
808M  pricing.log.2017-09-26
815M  pricing.log.2017-09-24
816M  common.log.2017-09-24
821M  common.log.2017-09-14
821M  pricing.log.2017-09-14
821M  pricing.log.2017-09-23
822M  common.log.2017-09-23
826M  common.log.2017-09-25
826M  pricing.log.2017-09-25
827M  common.log.2017-09-16
827M  pricing.log.2017-09-15
827M  pricing.log.2017-09-16
828M  common.log.2017-09-15
831M  common.log.2017-09-22
831M  pricing.log.2017-09-22
851M  common.log.2017-09-21
851M  pricing.log.2017-09-21
860M  common.log.2017-09-20
860M  pricing.log.2017-09-20

 第九步:從文件的命令規(guī)律,可以看出日志文件日期保留一個月,檢查root用戶是否有定時刪除日志文件計劃。如下命令查看所示,確實有每天凌晨03:15進(jìn)行日志文件刪除的計劃。但是由于日志文件太多和根目錄空間大小原因,導(dǎo)致根目錄空間使用比例過高。在有部署自動監(jiān)控工具,如zabbix等,會自動發(fā)送告警。


[root@hostname ~]# crontab -l
15 3 * * * /u02/shell/rm_log_pricing.sh
[root@hostname ~]# cat /u02/shell/rm_log_pricing.sh
find /root/apache-tomcat-6.0.36-linux/bin/fare/ -name "common.log.2*" -mtime +30 | xargs rm -f
find /root/apache-tomcat-6.0.36-linux/bin/fare/ -name "pricing.log.2*" -mtime +30 | xargs rm -f

總結(jié):

從運(yùn)維的角度,不建議tomcat等應(yīng)用程序部署在和Linux操作系統(tǒng)相關(guān)的文件系統(tǒng)中,尤其是直接部署在根目錄下。一般都建議使用獨立的文件系統(tǒng)來部署應(yīng)用程序,無論從IO性能監(jiān)控,文件系統(tǒng)空間使用監(jiān)控都是有利的。

如有疑問請留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

相關(guān)文章

  • Linux shell中的test命令用法教程

    Linux shell中的test命令用法教程

    這篇文章主要給大家介紹了Linux shell中的test命令用法的相關(guān)資料,test命令是shell環(huán)境中測試條件表達(dá)式的實用工具,文中介紹的非常詳細(xì),需要的朋友可以參考借鑒,下面來一起看看吧。
    2017-04-04
  • 解決Linux Centos yum-config-manager --add-repo添加倉庫添加錯誤問題

    解決Linux Centos yum-config-manager --add-repo添

    這篇文章主要介紹了解決Linux Centos yum-config-manager --add-repo添加倉庫添加錯誤問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-04-04
  • cloudera manager 設(shè)置開機(jī)自啟的方法

    cloudera manager 設(shè)置開機(jī)自啟的方法

    下面小編就為大家?guī)硪黄猚loudera manager 設(shè)置開機(jī)自啟的方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-01-01
  • CentOS7.5從零安裝Python3.6.6的教程詳解

    CentOS7.5從零安裝Python3.6.6的教程詳解

    這篇文章主要介紹了CentOS7.5從零安裝Python3.6.6的教程,本文通過實例圖文相結(jié)合的形式給大家介紹的非常詳細(xì),具有一定的參考借鑒價值 ,需要的朋友可以參考下
    2018-10-10
  • linux服務(wù)器上使用nginx訪問本地靜態(tài)資源的方法

    linux服務(wù)器上使用nginx訪問本地靜態(tài)資源的方法

    這篇文章主要介紹了linux服務(wù)器上如何使用nginx訪問本地靜態(tài)資源,本文給出了解決方法,需要的朋友可以參考下
    2019-12-12
  • 詳解Linux查看實時網(wǎng)卡流量的幾種方式

    詳解Linux查看實時網(wǎng)卡流量的幾種方式

    本篇文章中主要介紹了詳解Linux查看實時網(wǎng)卡流量的幾種方式,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-05-05
  • Linux虛擬機(jī)重啟找不到IP的解決方案

    Linux虛擬機(jī)重啟找不到IP的解決方案

    這篇文章主要為大家詳細(xì)介紹了Linux虛擬機(jī)重啟找不到IP問題的解決方案,文中通過示例圖片和代碼進(jìn)行了詳細(xì)的講解,有需要的小伙伴可以參考下
    2024-12-12
  • linux下/etc/passwd文件的選項說明

    linux下/etc/passwd文件的選項說明

    /etc/passwd 文件是系統(tǒng)的主要文件之一。該文件中包含了所有用戶登錄名清單;為所有用戶指定了主目錄;在登錄時使用的 shell 程序名稱等。該文件還保存了用戶口令;給每個用戶提供系統(tǒng)識別號。
    2008-06-06
  • linux之source.list的使用解析

    linux之source.list的使用解析

    /etc/apt/source.list文件定義了軟件源的相關(guān)信息,包括檔案類型、倉庫地址和版本代號,倉庫地址指向了軟件包的索引文件和具體存放路徑,修改該文件后需要更新軟件包列表,才能安裝新的軟件
    2025-03-03
  • Linux 塊設(shè)備驅(qū)動代碼編寫

    Linux 塊設(shè)備驅(qū)動代碼編寫

    這篇文章主要介紹了Linux 塊設(shè)備驅(qū)動代碼編寫,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-04-04

最新評論

三河市| 南华县| 兴山县| 阜平县| 昔阳县| 剑阁县| 蒙城县| 巧家县| 个旧市| 中阳县| 玉林市| 芜湖市| 阜城县| 红河县| 上饶县| 萍乡市| 格尔木市| 弋阳县| 无极县| 西乡县| 儋州市| 阜宁县| 鄂尔多斯市| 井陉县| 江油市| 永嘉县| 富民县| 江安县| 海伦市| 通海县| 苏州市| 普定县| 杨浦区| 铅山县| 祥云县| 伊宁市| 宜城市| 永川市| 突泉县| 芜湖县| 洛宁县|