Wednesday, April 22, 2009

NFS与文件锁

要在NFS文件系统上使用文件锁, 是需要client端和server端都运行着如下程序:
[jessinio@storage0 ~]$ ps auxwww|grep rpc
root 739 0.0 0.0 5736 1588 ?? Ss 18Feb09 0:03.99 /usr/sbin/rpcbind
root 804 0.0 0.0 266776 1540 ?? Ss 18Feb09 0:02.94 /usr/sbin/rpc.statd
root 810 0.0 0.0 5752 1872 ?? Ss 18Feb09 1:21.82 rpc.lockd: server (rpc.lockd)
daemon 816 0.0 0.0 5752 1884 ?? I 18Feb09 0:00.03 rpc.lockd: client (rpc.lockd)


否则无法使用文件锁, 例子如下:

jessinio@192.168.55.140 /mnt/test_lock$ svnsync init file:///mnt/test_lock/test_repo http://svn.rdev.xxx.net/matter http://svn.rdev.xxx.net/matter --username liangqingxi
svnsync: Can't get exclusive lock on file '/mnt/test_lock/test_repo/db/write-lock': Operation not supported

要在NFS上正常使用文件锁除了上面说的使用rpc系统的程序之外, 还有一种BT的方法:

如下是FreeBSD的mount_nfs的man描述:

-L Do not forward fcntl(2) locks over the wire. All locks will be
local and not seen by the server and likewise not seen by other
NFS clients. This removes the need to run the rpcbind(8) service
and the rpc.statd(8) and rpc.lockd(8) servers on the client.
Note that this option will only be honored when performing the
initial mount, it will be silently ignored if used while updating
the mount options.

linux下, 没有看到这个参数, 只看到一个貌似的:

mand Allow mandatory locks on this filesystem. See fcntl(2)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.