在centOS6.8上, 我将一个远程机器的nfs,mount到本地:
mount -o rw -t nfs4 192.168.10.29:/var/fes/ /mnt/fes
当在nfs服务器上修改了文件后,发现本地程序读取到的文件内容依旧是旧的内容。【我发现,ls一下那个挂载的目录,之后就能看到最新的内容了,不知道时什么原因】
搜到2篇文章:
https://www.cnblogs.com/yum777/p/6228723.html
需要给mount命令添加noac的选项,但是添加这个选项后,问题并没有解决。
继续搜索:
有人报出一个bug,说使用noac无效,但是使用actimeo=0可以解决这个问题。 验证过,这个选项确实可以解决问题。为了避免频繁的网络请求,我使用actimeo=1
说是这些选项的用途吧:
ac: attribute cache 目的是缓存文件属性信息,防止过于频繁的对nfs服务器的网络请求。(cache时间的长短可以配置,使用man nfs查看)
noac: 也就是不缓存了
ac的时间长短可以通过下面四个选项配置:
acregmin=n The minimum time (in seconds) that the NFS client caches attributes of a regular file before it requests fresh attribute information from a server. If this option is not specified, the NFS client uses a 3-second minimum.
acregmax=n The maximum time (in seconds) that the NFS client caches attributes of a regular file before it requests fresh attribute information from a server. If this option is not specified, the NFS client uses a 60-second maxi-
mum.
acdirmin=n The minimum time (in seconds) that the NFS client caches attributes of a directory before it requests fresh attribute information from a server. If this option is not specified, the NFS client uses a 30-second minimum.
acdirmax=n The maximum time (in seconds) that the NFS client caches attributes of a directory before it requests fresh attribute information from a server. If this option is not specified, the NFS client uses a 60-second maximum.
actimeo=n Using actimeo sets all of acregmin, acregmax, acdirmin, and acdirmax to the same value. If this option is not specified, the NFS client uses the defaults for each of these options listed above.