NFSv4, network file system version 4, is the new version of NFS (for setting up the older NFSv3, see Nfs) with new features like strong authentication and integrity via Kerberos and SPKM-3, improved performance, safe file caching, lock migration, UTF-8, ACLs and better support for Windows file sharing semantics.
This article covers installing and configuring NFSv4.
Contents[hide] |
Both client and servers require the nfs-utils package. Install with pacman:
# pacman -S nfs-utils
The server configuration is very thorough.
First we'll need to edit our exports in /etc/exports. A typical NFSv4 export would look like this:
/export 192.168.0.12(rw,fsid=0,no_subtree_check,async,no_root_squash) /export/music 192.168.0.12(rw,no_subtree_check,async,no_root_squash)
/export is the NFS root here (due to the fsid=0 entry). Everything else that you want to be shared over NFS must be accessible under /export.
For exporting directories outside the NFS root, see below.
To do this, you'll need to use bind mounts. For example, to bind /home/john to /export/john:
# mount --bind /home/john /export/john
Then, /export/john needs to be added to /etc/exports:
/export 192.168.0.12(rw,fsid=0,no_subtree_check,async,no_root_squash) /export/music 192.168.0.12(rw,no_subtree_check,async,no_root_squash) /export/john 192.168.0.12(rw,no_subtree_check,async,no_root_squash,nohide)
The nohide option is required, because the kernel NFS server automatically hides mounted directories. To add the bind mount to /etc/fstab:
/home/john /export/john none bind 0 0
Then, /etc/idmapd.conf needs to be edited. You'll need to at the very least specify your Domain there. Example:
[General] Verbosity = 1 Pipefs-Directory = /var/lib/nfs/rpc_pipefs Domain = archlinux.org [Mapping] Nobody-User = nobody Nobody-Group = nobody
To allow network access to the nfs server you should edit /etc/hosts.allow. The following example opens these services to anyone:
nfsd: ALL rpcbind: ALL mountd:ALL
This is a very insecure way of allowing host access. To get better control over who is allowed to access the daemons, hosts.deny should be everyone, and hosts.allow should specifically allow certain people. In this example, 192.168.0.101 should be the IP address of the person(s) allowed to access it. The numbers after the '/' is the netmask:
nfsd: 192.168.0.101/255.255.255.255 rpcbind: 192.168.0.101/255.255.255.255 mountd: 192.168.0.101/255.255.255.255
This examples enables access for anyone on that network:
nfsd: 192.168.0.0/255.255.255.0 rpcbind: 192.168.0.0/255.255.255.0 mountd: 192.168.0.0/255.255.255.0
For finer control, read the hosts_access(5) man page.
To start the NFS server, just do:
# /etc/rc.d/rpcbind start # /etc/rc.d/nfs-common start # /etc/rc.d/nfs-server start
If you want to tweak the configuration, feel free to edit /etc/conf.d/nfs-server.conf to fit your needs.
The client configuration is more simple.
/etc/idmapd.conf needs to be edited on all clients and the Domain entry should be identical to the one on the server. Example:
[General] Verbosity = 1 Pipefs-Directory = /var/lib/nfs/rpc_pipefs Domain = archlinux.org [Mapping] Nobody-User = nobody Nobody-Group = nobody [Translation] Method = nsswitch
You will need to allow rpcbind for the server's ip:
rpcbind: 192.168.0.100/255.255.255.255
On the client, to mount the NFSv4 partition: Make sure that nfs module is loaded. (lsmod | grep nfs). If not execute the next command "modprobe nfs"
# /etc/rc.d/rpcbind start # /etc/rc.d/nfs-common start # mount -t nfs4 server:/ /mnt/server/ # mount -t nfs4 server:/music /mnt/music/ # mount -t nfs4 server:/john /mnt/john
Replacing 'server' with the hostname or IP address of your NFS server and of course 'server', 'music' and 'john' with the names of whatever directories you exported on the server.
If you want the NFS volumes to mount automatically on bootup, add them to fstab. For example:
server:/ /mnt/server nfs4 async,user 0 0
Remember to add netfs in the daemons array at /etc/rc.conf in order to mount nfs volumes at boot.
In order for NFS to function properly, both server and client must have closely matching time values. If the clocks on the clients differ from the server too much, then basic functions like file copy operations may hang for a very long time leaving the system unusable until they resume. The clocks do not have to match to micro/nano second accuracies, but ideally they should be within 1 second of each other.
The NTP system is recommended to sync both the server and the clients to the highly accurate NTP servers available on the Internet. For a small system like a home network, the ntpdate utility may be used to sync both servers and clients to the same time. For a larger installation, it may be desirable to install an OpenNTP server (see NTP) onto the same machine acting as the NFS server, and then all clients on the network would sync time values from the server. This has the advantage of lowering the stress on the external NTP servers, and in assuring that the NFS clients will use the exact time that the NFS server has, even if the NFS server experiences some drift.
Common problems and how to overcome them
Add 'nfsd' to /etc/rc.conf modules array (NOTE: you may need to add "Verbosity = 3" to /etc/idmapd.conf and restart the services above to receive the error)
Delete all space from the option list in /etc/exports
Check that you have loaded nfs module
lsmod | grep nfs
and if previous returns empty or only nfsd-stuff, do
modprobe nfs
Check that the permissions on your client's folder are correct ('755' worked for me --Zenlord 12:01, 7 May 2010 (EDT))
而且直接配置文件是效率最高的,通过其它驱动效率都相对较低,BDB
这个测试不太准确,看官方的测试结果:http://bind-dlz.sourceforg
为什么使用BDB时QPS这么低? 我在bind版本基本相似的环境中测试的
It is quite useful and interesting too.
VIRT 的上限是64G,也就是36位, cat /proc/cpuinfo的结果是:addre
昨天要准备用线程重写webbench,试验了下Fedora Linux 2.6.35.14
不明白您的具体的意思是什么?
已经发送到你QQ邮箱