ITPub博客

首页 > 数据库 > Oracle > [20161012]linux free的补充.txt

[20161012]linux free的补充.txt

原创 Oracle 作者:lfree 时间:2016-10-12 10:05:04 0 删除 编辑

[20161012]linux free的补充.txt

--前一阵子写的:
http://blog.itpub.net/267265/viewspace-2124363/

下面是关于buffers和cached的英文资料:

Buffers are associated with a specific block device, and cover caching of filesystem metadata as well as tracking
in-flight pages. The cache only contains parked file data. That is, the buffers remember what's in directories, what
file permissions are, and keep track of what memory is being written from or read to for a particular block device. The
cache only contains the contents of the files themselves.

-- buffers 缓存,主要用于块设备缓存,例如用户目录、inode值等(ls大目录可以看到这个值增加)
-- cached  缓存,主要用于缓存文件。

--有一些理解不是很清除.

$ free -m
             total       used       free     shared    buffers     cached
Mem:        129161      19398     109762          0        435       7910
-/+ buffers/cache:      11053     118108
Swap:        30718         10      30707

$ dd if=/dev/zero of=aaaaaaa bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes (1.0 GB) copied, 1.86119 seconds, 563 MB/s

$ free -m
             total       used       free     shared    buffers     cached
Mem:        129161      20412     108748          0        437       8910
-/+ buffers/cache:      11064     118096
Swap:        30718         10      30707

--我建立1个1000M的文件,cached从7910=>8910.buffers几乎不变。

# dd if=/dev/cciss/c0d0p6 of=/dev/null bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes (1.0 GB) copied, 12.1073 seconds, 86.6 MB/s

--注意,我看了一些网站的blog,if与of是写反的,应该也能测试出来。这样你必须保证这个块设备没有内容,总之千万别写反了。

# free -m
             total       used       free     shared    buffers     cached
Mem:        129161      28231     100929          0       8039       8910
-/+ buffers/cache:      11281     117880
Swap:        30718         10      30707

# echo 1 >| /proc/sys/vm/drop_caches
# free -m
             total       used       free     shared    buffers     cached
Mem:        129161      13252     115909          0          0       2277
-/+ buffers/cache:      10973     118187
Swap:        30718         10      30707

--我前一个测试有一些问题实际上echo 1 >| /proc/sys/vm/drop_caches,buffers与cached好像都清除的。不知道为什么?
--有一些概念还不是很清楚。

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/267265/viewspace-2126155/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
熟悉oracle相关技术,擅长sql优化,rman备份与恢复,熟悉linux shell编程。

注册时间:2008-01-03

  • 博文量
    4006
  • 访问量
    7969431