【人在运维囧途_09】秒删海量数据文件的方法


【人在运维囧途_09】秒删海量数据文件的方法
 
【人在运维囧途_08】淘宝内部大量使用的开源系统监控工具--Tsar
http://www.2cto.com/os/201304/203057.html
 
此篇是人在囧途之运维的 NO.9 了、更新实在太慢鸟、愧疚、、
     在运维的工作中、有时我们需要去删除大文件、或者 N (N 取正无穷哟~~)多小文件
     那么、rm 次奥咯、
     这里、Rocky 介绍 Linux 史上最可爱、最温柔、最成熟、最善良、最.....槽糕、找不到形容词、囧
     那便是 rsync 的另外一种用法
 
        ① 语法:
           
            # rsync --delete-before -avH --progress --stats DEST SRC
            
            解释:
            当SRC和DEST性质都为文件【f】时,意思是清空文件内容而不是删除文件
            当SRC和DEST性质都为目录【d】时,意思是删除该目录下的所有文件,使其变为空目录
            PS:其实该命令顶好记的哦、av -_-#、H$_$、男人很少不懂的、骚年、此时你的硬盘都有谁来着、、
            
           
        ② 原理:
            
            rsync实际上用的就是替换原理
 
        ③ 优点:
   
            处理速度相当快,处理几个G的文件也就是秒级的事、比rm要快很多倍
     
        ④ 缺点:
            
            对磁盘io的占用较高、业务高峰或要暂避
 
        ⑤ 测试:
 
[plain] 
[root@localhost log]# ls  
rhel-server-5.8-i386-dvd.iso  
[root@localhost log]# pwd  
/tmp/test/log  
[root@localhost ~]# mkdir empty  
[root@localhost ~]# rsync --delete-before -avH --progress --stats /root/empty/ /tmp/test/log/  
building file list ...   
1 file to consider  
deleting rhel-server-5.8-i386-dvd.iso  
./  
  
Number of files: 1  
Number of files transferred: 0  
Total file size: 0 bytes  
Total transferred file size: 0 bytes  
Literal data: 0 bytes  
Matched data: 0 bytes  
File list size: 19  
File list generation time: 0.001 seconds  
File list transfer time: 0.000 seconds  
Total bytes sent: 29  
Total bytes received: 15  
  
sent 29 bytes  received 15 bytes  6.77 bytes/sec  
total size is 0  speedup is 0.00  
 

相关内容

    暂无相关文章