Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1092704
  • 博文数量: 186
  • 博客积分: 4939
  • 博客等级: 上校
  • 技术积分: 2075
  • 用 户 组: 普通用户
  • 注册时间: 2010-04-08 17:15
文章分类

全部博文(186)

文章存档

2018年(1)

2017年(3)

2016年(11)

2015年(42)

2014年(21)

2013年(9)

2012年(18)

2011年(46)

2010年(35)

分类: 系统运维

2013-08-03 18:30:34

    NFS是linux下最常见的service,配置各方面都很简单,但是一些性能方面的设置还是要注意,下边是google到的结果:

sync、async选项对于NFS Server和NFS Client含义是不一样的
NFS server采用sync还是async是在/etc/exports里面设置的。如果设置为async,则所有client的写操作都会先放到内存 cache中,不会立即写到硬盘,并欺骗client写操作已经完成。如果设置为sync,则所有写操作都直接写入硬盘,写完以后再应答client。
NFS Client采用sync还是async是在mount的时候用-o指定的。如果设置为sync,则client每次调用write函数都会立即提交到 server。如果设置为async,write操作会先在client端缓存起来,等到缓冲到一定数量再一次提交到server。具体可以看man nfs。

nfs server没有必要使用sync选项,一来不能很好地利用系统cache,二来对性能的影响实在太大。


NFS will by default perform a level of caching of directory and file contents at the kernel level of the system. If machine one updates a file and machine two has still got a copy of the file in cache, then if machine two attempts to access the file then it may not see the newer version of the file until its cache expires.
Check the man page for nfs for the following parameters:
   acregmin=n     The minimum time in seconds that attributes of a  regular  file  should  be  cached  before  requesting fresh information from a server.  The default is 3 seconds.

   acregmax=n     The maximum time in seconds that attributes of a  regular file can be cached before requesting fresh information from a server.  The default is 60 seconds.

   acdirmin=n     The minimum time in seconds that attributes of a directory  should be cached before requesting fresh information from a server.  The default is 30 seconds.

   acdirmax=n     The maximum time in seconds that attributes of a directory  can be cached before requesting fresh information
                  from a server.  The default is 60 seconds.

   actimeo=n      Using actimeo sets all of acregmin, acregmax, acdirmin,and  acdirmax  to  the same value.  There is no default value.
                
   noac           Disable all forms of attribute caching entirely.   This
                  extracts  a  significant  performance  penalty  but  it
                  allows two different  NFS  clients  to  get  reasonable
                  results  when  both  clients  are actively writing to a common export on the server.
 


If the NFS server is a NetApp filer sharing to Linux boxes your performance will be abysmal unless noac is disabled 。

the NFS client will be requesting every attribute from the NFS server for every stat() call on every file and/or directory. The CPU on the NFS server then ends up going through the roof. The options I typically use to get reasonably good performance (but not immediate updates) is: rw,tcp,rsize=16384,wsize=16384,hard,nointr

以上说明了我最近遇到的一个诡异的问题的原因,NFS 服务器上的文件在client上不能及时出现,这个和developer一起debug的时候发现的,其实一个很简单的解决办法,在client上设置一个cron定期强制刷新 touch ${NFS_PATH}/test & >/dev/null 即可

阅读(1225) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~