在一次下載一個200多G的大文件時,使用以下方式進行下載,已經下載了180Gmysql
wget -c xxxxx.tar.gz -O xxxx.tar.gzlinux
由於當時機器上作的操做不少,機器有點卡,因而就手工kill掉這個任務,等空閒時候再手工下載。sql
結果kill掉這個進程後,很長時間這個任務才終止,且以後/tmp目錄被佔用的空間就一直沒有被釋放。vim
[kxk3admin@kxo-backup-in-02 ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 20G 8.9G 9.8G 48% /
tmpfs 1.9G 0 1.9G 0% /dev/shm
/dev/mapper/vg01-lv01
296G 225G 56G 81% /tmp
/dev/xvdc1 2.0T 546G 1.3T 30% /app
ossfs 256T 0 256T 0% /ossbash
因爲這臺機器上有不少定時自動任務在跑,因此不能隨便停或重啓這臺機器。(固然重啓這臺機器是能夠釋放掉tmp被佔用的空間)。在不重啓的狀況下考慮釋放掉這些空間。app
使用lsof -n | grep deleted查看是否有存在有相關文件被刪除,但進程未釋放的狀況發生ide
注:這個deleted表示該已經刪除了的文件,可是文件句柄未釋放,這個命令會把全部持有的未釋放文件句柄的進程列出來。url
[linux@kxo-backup-in-02 app]$ lsof -n | grep deleted
ossfs 1340 linux 5u REG 253,0 0 18 /tmp/tmpfjJmsrM (deleted)
ossfs 1340 linux 6u REG 253,0 588452596 1920 /tmp/tmpf3llHIV (deleted)
ossfs 1340 linux 7u REG 253,0 236260153501 14 /tmp/tmpfBevUvg (deleted)
ossfs 1340 linux 8u REG 253,0 4291821568 1473 /tmp/tmpflGDQvH (deleted)
ossfs 1340 linux 10u REG 253,0 0 956 /tmp/tmpfLZbTMe (deleted)
ossfs 1340 linux 11u REG 253,0 0 5186 /tmp/tmpfTh5Mov (deleted)
ossfs 1340 linux 13u REG 253,0 0 1247 /tmp/tmpfLVW3zR (deleted)
vim 3793 linux 4u REG 202,33 16384 60555276 /app/temp/.head300.log.swp (deleted)
collect_s 5568 linux 0u CHR 136,3 0t0 6 /dev/pts/3 (deleted)
bash 19204 linux 0u CHR 136,3 0t0 6 /dev/pts/3 (deleted)
bash 19204 linux 255u CHR 136,3 0t0 6 /dev/pts/3 (deleted)
bash 19524 linux 0u CHR 136,3 0t0 6 /dev/pts/3 (deleted)
bash 19524 linux 255u CHR 136,3 0t0 6 /dev/pts/3 (deleted)
collect_s 19682 linux 0u CHR 136,3 0t0 6 /dev/pts/3 (deleted)
bash 19900 linux 0u CHR 136,3 0t0 6 /dev/pts/3 (deleted)
bash 19900 linux 255u CHR 136,3 0t0 6 /dev/pts/3 (deleted)
bash 20090 linux 0u CHR 136,3 0t0 6 /dev/pts/3 (deleted)
bash 20090 linux 255u CHR 136,3 0t0 6 /dev/pts/3 (deleted)
collect_s 20131 linux 0u CHR 136,3 0t0 6 /dev/pts/3 (deleted)
collect_s 29077 linux 0u CHR 136,3 0t0 6 /dev/pts/3 (deleted)進程
而後你能夠使用kill命令來釋放文件句柄從而釋放空間。get
從上面看到並未發現有wget相關進程產生的佔用空間狀況, 而顯示爲ossfs進程有已經被刪除,但仍舊佔用空間狀況,因爲掛載的是oss高速磁盤,因此進程被kill以後貌似沒有釋放文件句柄,因而採用從新掛載oss的方式來解決。
[linux@kxo-backup-in-02 ~]$ lsof /oss/
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mysql 18023 linux cwd DIR 0,19 0 1536713 /oss/DONT_TOUCH/ossprd
強制kill掉
[linux@kxo-backup-in-02 ~]$ kill -9 18023
[linux@kxo-backup-in-02 ~]$ lsof /oss/
卸載oss
[linux@kxo-backup-in-02 ~]$ fusermount -u /oss
[linux@kxo-backup-in-02 ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 20G 7.1G 12G 38% /
tmpfs 1.9G 0 1.9G 0% /dev/shm
/dev/mapper/vg01-lv01
296G 212G 69G 76% /tmp
/dev/xvdc1 2.0T 935G 935G 50% /app
已經卸載
從新掛載
[linux@kxo-backup-in-02 ~]$ ossfs mysqlbak /oss -ourl=http://oss-xx-xxxx-xxxx.xxxxx.com
[linux@kxo-backup-in-02 ~]$ df -hFilesystem Size Used Avail Use% Mounted on/dev/xvda1 20G 7.1G 12G 38% /tmpfs 1.9G 0 1.9G 0% /dev/shm/dev/mapper/vg01-lv01 296G 64M 281G 1% /tmp/dev/xvdc1 2.0T 935G 935G 50% /appossfs 256T 0 256T 0% /osstmp空間已釋放,問題解決。