问题描述
我在使用NFS客户端属性缓存时遇到了麻烦.我正在使用一些服务器,一个是NFS服务器,其他是NFS客户端服务器.
I have a trouble with NFS client-side attribute caching.I'm using some servers, one is an NFS server and the others are NFS client servers.
所有服务器均为Debian(Linux的lenny,2.6.26-2-amd64),并且版本如下.
All servers are Debian(lenny, 2.6.26-2-amd64 of Linux) and versions are following.
% dpkg -l | grep nfs
ii libnfsidmap2 0.20-1 An nfs idmapping library
ii nfs-common 1:1.1.2-6lenny1 NFS support files common to client and server
ii nfs-kernel-server 1:1.1.2-6lenny1 support for NFS kernel server
在NFS服务器中,/etc/exports编写如下:
In the NFS server, /etc/exports is written as following:
/export-path 192.168.0.0/255.255.255.0(async,rw,no_subtree_check)
在NFS客户端中,/etc/fstab编写如下:
In the NFS clients, /etc/fstab is written as following:
server:/export-path /mountpoint nfs rw,hard,intr,rsize=8192,async 0 0
如您所见,异步"选项用于多客户端访问性能.但是,有时这可能会导致错误缓存错误.
As you can see, "async" option is used for multi-clients access performance.However, sometimes this can cause false-caching errors.
由于我要维护许多服务器(并且我没有改变安装选项的强烈权限),所以我不想修改/etc/exports或/etc/fstab.我认为只要有一个命令行工具就可以使用用户权限清理" NFS客户端属性缓存,就足够了.
Since I am maintaining many servers (and I have not so strong permission to change the mount options), I don't want to modify /etc/exports nor /etc/fstab.I think it is sufficient if I have a command-line tool that "cleans" NFS client-side attribute cache with a user permission.
请告诉我是否有这样的命令.
Please let me know if there such commands.
谢谢
(附加)
我的意思是错误缓存错误",
I mean by "false-caching errors",
% ls -l /data/1/kabe/foo
ls: cannot access /data/1/kabe/foo: No such file or directory
% ssh another-server 'touch /data/1/kabe/foo'
% ls -l /data/1/kabe/foo
ls: cannot access /data/1/kabe/foo: No such file or directory
有时会发生这种情况.问题不是文件内容,而是文件属性(=牙科信息),因为NFS表示它可以保证从打开到打开"的一致性.
Sometimes such cases happen.The problem is not a file content but file attributes(=dentries information) since NFS says it guarantees Close-to-Open consistency.
推荐答案
根据您所说的错误缓存错误",运行sync
可能会满足您的需求.这将刷新所有文件系统缓冲区.
Depending on what you mean by "false-caching errors", running sync
may get you what you need. This will flush all filesystem buffers.
如果需要,还可以使用/proc/sys/vm/drop_caches
清除内核中的VM缓存.
If needed, you can also clear out the VM caches in the kernel using /proc/sys/vm/drop_caches
.
# To free pagecache
echo 1 > /proc/sys/vm/drop_caches
# To free dentries and inodes
echo 2 > /proc/sys/vm/drop_caches
# To free pagecache, dentries and inodes
echo 3 > /proc/sys/vm/drop_caches
这篇关于NFS缓存清理命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!