zoukankan      html  css  js  c++  java
  • 文件系统满的话(filesystem full),该如何处理。(du and ls)

    因为filehome 上小文件过多,所以du –sh * 过滤掉 filehome

    du -sh /* --exclude="filehome"

    1.1G    /backup

    7.8M    /bin

    6.8M    /boot

    #!/bin/bash  
    function ergodic(){  
      for file in `ls $1`  
      do  
        if [ -d $1"/"$file ]  
        then  
          ergodic $1"/"$file  
        else  
          local path=$1"/"$file   
          local name=$file        
          local size=`du --max-depth=1 $path|awk '{print $1}'`   
          echo $name  $size $path  
          echo $size  $name $path  >> /tmp/file.txt   
        fi    
      done  
    }  
      
    IFS=$'
    '                      #done
    INIT_PATH=".";  
    ergodic $INIT_PATH  
    
    sort -n /tmp/file.txt   
    
    




    ####### 文件系统满的话,该如何处理。
    1.使用以上shell(file.sh)处理 2.检查文件总大小是否小于df -k 的占用量,也就说明 进程没来得及释放日志文件,导致日志文件虽然被删除,但是进程仍然hold 空间
      详细请见:(http://www.cnblogs.com/feiyun8616/p/6132670.html) 看到
    /tmp oracle:dba 目录/tmp/rda 消耗较高,总和小于df -k显示的占用量,看到有oracle 进程占用/tmp.怀疑是清理了空间后进程未释放空间,需要进一步确认
     
    方法如下:

     

      step1: From time to time the du command doesn’t match up with df. This is due to deleted but ‘still open’ file usage

       lsof | awk '/deleted/ {sum+=$7} END {print sum}'

      step 2:  (check $2 is pid, manaul to kill the process)

      lsof | grep deleted

    (COMMAND     PID      USER   FD      TYPE             DEVICE   SIZE/OFF       NODE NAME)




    for ksh
    
    #for ksh
    #!/bin/bash
    function ergodic {
      for file in `ls $1`
      do
        if [ -d $1"/"$file ]
        then
    #      echo $file
            ergodic $1"/"$file
        else
    #         echo $1
    #         echo $file
          local path=$1"/"$file
          local name=$file
          local size=`du -sk $path|awk '{print $1}'`
    #     echo $name  $size $path
          echo $size  $name $path  >> /tmp/file.txt 
            fi
      done
    }
     
    #IFS=$'
    '                      #done
    INIT_PATH="/11_restore"; 
    #echo $INIT_PATH
    ergodic $INIT_PATH
    
    sort -n /tmp/file.txt

    3.监控脚本本身异常 导致系统 误报。

    大量未删除的文件 导致 脚本无法连接数据库,写入日志,出现如下提示。

    [root@yidbmon1 ~]# /usr/sbin/lsof |grep home

    bash       6623    oracle  cwd       DIR              253,8      12288     131223 /home/oracle/utility/macro

    tnslsnr    6940    oracle  cwd       DIR              253,8       4096     131073 /home/oracle

    bash       9990    oracle  cwd       DIR              253,8       4096     131099 /home/oracle/11

    bash       9990    oracle  254r      REG              253,8       3493     143496 /home/oracle/11/osw_sort_11pr.sh

    bash       9992    oracle  cwd       DIR              253,8       4096     131099 /home/oracle/11

    tee        9993    oracle  cwd       DIR              253,8       4096     131099 /home/oracle/11

    sh        11637    oracle  cwd       DIR              253,8       4096     131099 /home/oracle/11

    sh        11637    oracle    1w      REG              253,8 1994113024     147308 /home/oracle/11/nohup.out (deleted)

    sh        11637    oracle    2w      REG              253,8 1994113024     147308 /home/oracle/11/nohup.out (deleted)

    sh        11637    oracle  255r      REG              253,8       3493     143496 /home/oracle/11/osw_sort_11pr.sh

    sh        11639    oracle  cwd       DIR              253,8       4096     131099 /home/oracle/11

    sh        11639    oracle    2w      REG              253,8 1994113024     147308 /home/oracle/11/nohup.out (deleted)

    tee       11640    oracle  cwd       DIR              253,8       4096     131099 /home/oracle/11

    tee       11640    oracle    1w      REG              253,8 1994113024     147308 /home/oracle/11/nohup.out (deleted)

    tee       11640    oracle    2w      REG              253,8 1994113024     147308 /home/oracle/11/nohup.out (deleted)

    bash      20767    oracle  cwd       DIR              253,8       4096     131099 /home/oracle/11

    bash      20767    oracle  254r      REG              253,8       2648     143598 /home/oracle/11/osw_sort_edrprod.sh

    bash      20769    oracle  cwd       DIR              253,8       4096     131099 /home/oracle/11

    tee       20770    oracle  cwd       DIR              253,8       4096     131099 /home/oracle/11

    bash      21678    oracle  cwd       DIR              253,8       4096          2 /home

    se.sh     23010    oracle  cwd       DIR              253,8       4096     142968 /home/oracle/monitor/ngtools/se

    se.sh     23010    oracle   11r      REG              253,8       2635     139902 /home/oracle/monitor/ngtools/se/se.sh

    se.sh     23010    oracle   12r      DIR              253,8       4096     142968 /home/oracle/monitor/ngtools/se

    sh        26763    oracle  cwd       DIR              253,8       4096     131073 /home/oracle

    sh        26839    oracle  cwd       DIR              253,8       4096     131073 /home/oracle

    sh        26855    oracle  cwd       DIR              253,8       4096     131073 /home/oracle

    sh        26871    oracle  cwd       DIR              253,8       4096     131073 /home/oracle

    sh        26887    oracle  cwd       DIR              253,8       4096     131073 /home/oracle

    sh        26903    oracle  cwd       DIR              253,8       4096     131073 /home/oracle

    sh        26919    oracle  cwd       DIR              253,8       4096     131073 /home/oracle

    sh        26935    oracle  cwd       DIR              253,8       4096     131073 /home/oracle

    sh        26951    oracle  cwd       DIR              253,8       4096     131073 /home/oracle

    sh        26967    oracle  cwd       DIR              253,8       4096     131073 /home/oracle

    sh        26983    oracle  cwd       DIR              253,8       4096     131073 /home/oracle

    sh        29049    oracle  cwd       DIR              253,8       4096     131073 /home/oracle

    sh        29065    oracle  cwd       DIR              253,8       4096     131073 /home/oracle

    sh        29081    oracle  cwd       DIR              253,8       4096     131073 /home/oracle

    sh        29097    oracle  cwd       DIR              253,8       4096     131073 /home/oracle

    sh        29113    oracle  cwd       DIR              253,8       4096     131073 /home/oracle

    sh        29129    oracle  cwd       DIR              253,8       4096     131073 /home/oracle

    sh        29145    oracle  cwd       DIR              253,8       4096     131073 /home/oracle

    sh        29161    oracle  cwd       DIR              253,8       4096     131073 /home/oracle

    sh        29177    oracle  cwd       DIR              253,8       4096     131073 /home/oracle

    sh        29193    oracle  cwd       DIR              253,8       4096     131073 /home/oracle

    sh        29209    oracle  cwd       DIR              253,8       4096     131073 /home/oracle

    sleep     29934    oracle  cwd       DIR              253,8       4096     131099 /home/oracle/11

    sleep     29934    oracle    2w      REG              253,8 1994113024     147308 /home/oracle/11/nohup.out (deleted)

    sleep     29957    oracle  cwd       DIR              253,8       4096     131099 /home/oracle/11

    sleep     29988    oracle  cwd       DIR              253,8       4096     131099 /home/oracle/11

  • 相关阅读:
    Xshell 跳板机快速登录脚本按钮
    (一)angularjs5 环境搭建
    Myeclipse 内存溢出解决方法
    php 代码放到服务器上验证码不好用
    表格里面的input在底部
    Smarty忽略大括号
    php富友表单提交接口对接
    php富友接口对接http请求
    js去掉html标签
    删除的时候提示是否删除
  • 原文地址:https://www.cnblogs.com/feiyun8616/p/6073004.html
Copyright © 2011-2022 走看看