CentOS释放缓存

[ 2013-07-06 23:19:24 | 作者: admin ]
字号: | |
负载较大的Linux服务器,内存有时会耗尽,可使用以下命令尽快释放缓存。
查看目前内存占用情况:
[root@HZ-Cache01-231 ~]# free -m
                    total used free shared buffers cached
Mem: 7854 6047 1807 0 572 4305
-/+ buffers/cache: 1169 6685
Swap: 8191 0 8191
避免缓存里的数据丢失,先使用以下命令把内存里的数据暂时写到硬盘里。
[root@HZ-Cache01-231 ~]# sync
修改 /proc/sys/vm/drop_caches文件。
[root@HZ-Cache01-231 ~]# echo 3 > /proc/sys/vm/drop_caches
[root@HZ-Cache01-231 ~]# cat /proc/sys/vm/drop_caches
3


注释:


# To free pagecache:
echo 1 > /proc/sys/vm/drop_caches
# To free dentries and inodes:
echo 2 > /proc/sys/vm/drop_caches
# To free pagecache, dentries and inodes:
echo 3 > /proc/sys/vm/drop_caches


再次查看内存使用情况。
[root@HZ-Cache01-231 ~]# free -m
                    total used free shared buffers cached
Mem: 7854 3277 4577 0 1 2233
-/+ buffers/cache: 1042 6812
Swap: 8191 0 8191



attachments/201307/06_232112_501c86cdtc48a8c742aaf690.jpg
评论Feed 评论Feed: http://blog.xg98.com/feed.asp?q=comment&id=2088

这篇日志没有评论。

此日志不可发表评论。