我有 2 台机器通过 NFS 交换数据:2 个大约 20 字节的不同文件。客户端写入其文件,服务器读取并删除该文件,然后写入不同的文件,服务器读取并删除该文件。等等。这两个文件始终具有相同的名称。
一切都好。他们运行Linux 2.4。现在,我添加了另一个运行 Linux 2.6 的客户端。它的工作方式相同,只是使用不同名称的文件。
问题是新客户端在写入文件后大约 40 秒看到来自服务器的文件。我可以等 4-5 秒甚至 10 秒,但不能等 40 秒。
我尝试使用 -o vers=2
或 -o vers=3
挂载远程分区,但没有效果。
然后我尝试了 echo 3 >/proc/sys/vm/drop_caches
,(参见 NFS cache-cleaning command? )没有效果。
我可以做些什么来减少时间差距?
最佳答案
您可以尝试合并监听通知方法,使用 iNotify 来监视文件系统事件。
The inotify API provides a mechanism for monitoring file system events. Inotify can be used to monitor individual files, or to monitor directories. When a directory is monitored, inotify will return events for the directory itself, and for files inside the directory
Q: Can I watch sysfs (procfs, nfs...)? Simply spoken: yes, but with some limitations. These limitations vary between kernel versions and tend to get smaller. Please read information about particular filesystems.
这很可能会缩短时间差距。
关于linux - NFS 时间间隔过长,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17717522/