全球主机交流论坛

标题: XEN设置定时脚本自动释放内存问题 [打印本页]

作者: 台北阿里    时间: 2010-11-2 16:23
标题: XEN设置定时脚本自动释放内存问题
使用XEN的朋友肯定也知道   XEN不像OpenVZ那样可以自动释放内存!

XEN需要自己写脚本 来定时自动释放内存!否则就只有重启了!相比重启

还是定时自动释放内存好些!

谁写过这方面的脚本  贴出来看看!
作者: dakai    时间: 2010-11-2 16:31
没有
我来学习

查了下,这个好象可以参考
http://www.linuxidc.com/Linux/2008-01/10738.htm
http://blog.chinaunix.net/u/10599/showart_1415878.html

[ 本帖最后由 dakai 于 2010-11-2 16:34 编辑 ]
作者: 台北阿里    时间: 2010-11-2 16:37
/proc是个虚拟文档系统,我们能够通过对他的读写操作做为和kernel实体间进行通信的一种手段.也就是说能够通过修改/proc中的文档,来对当前kernel的行为做出调整.那么我们能够通过调整/proc/sys/vm/drop_caches来释放内存.操作如下:


[root@server test]# cat /proc/sys/vm/drop_caches

0


首先,/proc/sys/vm/drop_caches的值,默认为0


[root@server test]# sync


手动执行sync命令(描述:sync 命令运行 sync 子例程。假如必须停止系统,则运行 sync 命令以确保文档系统的完整性。sync 命令将任何未写的系统缓冲区写到磁盘中,包含已修改的 i-node、已延迟的块 I/O 和读写映射文档)


[root@server test]# echo 3 > /proc/sys/vm/drop_caches

[root@server test]# cat /proc/sys/vm/drop_caches

3


将/proc/sys/vm/drop_caches值设为3


[root@server test]# free -m

total used free shared buffers cached

Mem: 249 66 182 0 0 11

-/+ buffers/cache: 55 194

Swap: 511 0 511


再来运行free命令,发现现在的used为66MB,free为182MB,buffers为0MB,cached为11MB.那么有效的释放了buffer和cache.


有关/proc/sys/vm/drop_caches的用法在下面进行了说明


/proc/sys/vm/drop_caches (since Linux 2.6.16)

Writing to this file causes the kernel to drop clean caches,

dentries and inodes from memory, causing that memory to become

free.

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.

Because this is a non-destructive operation and dirty objects

are not freeable, the user should run sync(8) first.
作者: winsock    时间: 2010-11-2 16:39
buffers+cached+free=剩余内存
作者: Cat    时间: 2010-11-2 16:51
你以为你用Windows吗
作者: zrdlrofmine    时间: 2010-11-2 16:56
学习了
作者: leven    时间: 2010-11-2 17:34
晕倒,越释放cache越慢
windows同上
作者: vnconfig    时间: 2010-11-5 02:04
有病,空余内存不是给你看的,是拿来用的。

vm.dirty_background_ratio
vm.dirty_background_bytes
vm.dirty_ratio
vm.dirty_bytes
vm.swappiness
作者: foxlovefox    时间: 2010-11-5 08:04
1 2楼的头像都好可爱。。
作者: ehane    时间: 2010-11-5 08:05
楼上的也不赖
作者: 霸武邪皇    时间: 2010-11-5 08:50
我看你还是回去用windows好了,在服务器上装个内存释放软件,满足你的爱好




欢迎光临 全球主机交流论坛 (https://sunk.eu.org/) Powered by Discuz! X3.4