确保客户端上的文件状态是同步的NFS服务器 [英] Ensure that file state on the client is in sync with NFS server

查看:202
本文介绍了确保客户端上的文件状态是同步的NFS服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到处理NFS客户机上的陈旧数据有道。请考虑以下情形:


  • 两台服务器安装同一NFS共享存储与文件数量

  • 1服务器上的客户端应用程序删除一些文件

  • 2服务器上
  • 客户端应用程序试图访问已删除的文件和失败:陈旧NFS文件句柄(没什么好奇怪的,预计误差)

(也可能是需要了解的,该缓存安装选项是pretty两台服务器的性能的原因高)。

我试图理解的是:


  • 有没有检查可靠的方法,该文件被present?在上面给出LSTAT上的文件的情况下返回成功,只试图移动文件后,应用程序失败。

  • 如何手动同步目录的内容与服务器?客户端

  • 在如何编写可靠的文件管理code NFS的情况下,一些一般性的建议?

感谢。


解决方案

  

      
  • 有没有检查可靠的方法,该文件被present?在上面给出LSTAT上的文件的情况下返回成功,只试图移动文件后,应用程序失败。

  •   

这是它正常的NFS行为。


  

      
  • 如何手动同步目录的内容与服务器?客户端

  •   

这是不可能做手工,因为NFS pretends是一个正常的POSIX兼容的文件系统。

我已经试过一次,试图以某种方式减轻NFS客户端缓存的影响,code的close()/ open()的。在我来说,我需要读取写入到其他服务器上的文件的信息。但即使是重新招了接近于零的效果。我不能添加fdatasync()来书写的一面,因为这会降低整个应用程序了。

我与NFS,迄今为止的经验是,没有什么可以做。在关键的code路径,我只​​是codeD重试其返回ESTALE文件操作。


  

      
  • 在如何编写可靠的文件管理code NFS的情况下,一些一般性的建议?

  •   

mod我下来你想要的,但如果你的客户希望可靠性那么他们不应该使用NFS。

我公司例如做广告使用适当的分布式文件系统(我故意省略了品牌),如果客户需要的可靠性。我们的核心软件不能保证在NFS上运行,我们不支持这样的配置。但在我们的例子中,我们真正需要的保证一旦数据被写入到fs他们成为所有其他节点上访问。

在NF​​S一致性可以实现,但在性能为代价,使得NFS勉强可用。 (检查它的安装选项。)NFS是缓存像疯了似的掩盖一个事实,即它是一个服务器文件系统。为了使所有操作一气呵成,NFS客户端会去到NFS服务器同步的每一个小手术,绕过本地缓存。而这绝不会快。

但由于我们在这里所说的Linux,可以告知软件的客户评估可用的群集文件系统。例如。红帽现在正式支持 GFS 。我听说过关于使用CodaFS的人,但它没有硬性的信息。

I'm trying to find proper way to handle stale data on NFS client. Consider following scenario:

  • Two servers mount same NFS shared storage with number of files
  • Client application on 1 server deletes some files
  • Client application on 2 server tries to access deleted files and fails with: Stale NFS file handle (nothing strange, error is expected)

(Also it may be useful to know, that cache mount options are pretty high on both servers for performance reasons).

What I'm trying to understand is:

  • Is there reliable method to check, that file is present? In the scenario given above lstat on the file returns success and application fails only after trying to move file.
  • How can I manually sync contents of directory on the client with server?
  • Some general advise on how to write reliable file management code in case of NFS?

Thanks.

解决方案

  • Is there reliable method to check, that file is present? In the scenario given above lstat on the file returns success and application fails only after trying to move file.

That's it normal NFS behavior.

  • How can I manually sync contents of directory on the client with server?

That is impossible to do manually, since NFS pretends to be a normal POSIX-compliant file system.

I have tried once to code close()/open() in an attempt to somehow mitigate the effects of the NFS client-side caching. In my case I needed to read the info written to the file on other server. But even the reopen trick had close to zero effect. And I can't add fdatasync() to the writing side, since that slows whole application down.

My experience with NFS to date is that nothing you can do. In critical code paths I simply coded to retry the file operations which return ESTALE.

  • Some general advise on how to write reliable file management code in case of NFS?

Mod me down all you want, but if your customers want reliability then they shouldn't use NFS.

My company for example advertises use of proper distributed file system (I intentionally omit the brand) if customer wants reliability. Our core software is not guaranteed to run on NFS and we do not support such configurations. But in our case we really need the guarantees that as soon as the data are written to FS they become accessible on all other nodes.

Coherency in NFS can be achieved, but at the cost of performance, making NFS barely usable. (Check its mount options.) NFS is caching like crazy to hide the fact that it is a server file system. To make all operations coherent, NFS client would have to go to the NFS server synchronously for every little operation, bypassing the local cache. And that would never be fast.

But since we are talking Linux here, one can advise customers of the software to evaluate available cluster file systems. E.g. RedHat now officially support GFS. I have heard about people using CodaFS, but have no hard info on it.

这篇关于确保客户端上的文件状态是同步的NFS服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆