linux查看清理內存和緩存(No space left on device)

free -m   查看內存情況

df -h      查看服務器磁盤情況

 lsof | grep deleted    查看了被進程佔用中的文件 (有可能文件並未真正刪除,只是標記爲 deleted,只有進程結束後纔會將文件真正從磁盤中清除

[root@testserver ~]# free -m
total used free shared buffers cached
Mem: 2013 1661 352 0 223 1206
-/+ buffers/cache: 231 1782
Swap: 2047 0 2047

[root@testserver ~]# sync
[root@testserver ~]# sync
[root@testserver ~]# cat /proc/sys/vm/drop_caches
0
[root@testserver ~]# echo 3 > /proc/sys/vm/drop_caches
[root@testserver ~]# cat /proc/sys/vm/drop_caches 
3
[root@testserver ~]# free -m

1、使用df -hl 命令,查看掛載空間是否充足;

 技術分享圖片

2、使用top命令,查看內存運行情況;

 技術分享圖片

使用free -m命令應該也可以:

[root@testserver ~]# free -m
total used free shared buffers cached
Mem: 2013 1661 352 0 223 1206
-/+ buffers/cache: 231 1782
Swap: 2047 0 2047

3、使用sync命令,將緩存寫入文件中;

[root@server test]# sync

手動執行sync命令(描述:sync 命令運行 sync 子例程。如果必須停止系統,則運行sync 命令以確保文件系統的完整性。sync 命令將所有未寫的系統緩衝區寫到磁盤中,包含已修改的 i-node、已延遲的塊 I/O 和讀寫映射文件)

To free pagecache, use
echo 1 > /proc/sys/vm/drop_caches;
To free dentries and inodes, use
echo 2 > /proc/sys/vm/drop_caches;
To free pagecache, dentries and inodes, use
echo 3 >/proc/sys/vm/drop_caches.

默認是0,1表示清空頁緩存,2表示清空inode和目錄樹緩存,3清空所有的緩存。

查看:

[root@testserver ~]# cat /proc/sys/vm/drop_caches

4、冗餘數據及時刪除,生產數據備份;

測試
[root@testserver ~]# uname -a
Linux testserver 2.6.18-164.el5 #1 SMP Thu Sep 3 03:28:30 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章