Homes - NFS

1. NFS server on Redhat

Install NFS packages:

yum install -y nfs- utils portmap

Edit /etc/sysconfig/nfs:

RQUOTAD_PORT=951
LOCKD_TCPPORT=952
LOCKD_UDPPORT=953
MOUNTD_PORT=954
STATD_PORT=955
STATD_OUTGOING_PORT=956

Edit /etc/exports:

/group  10.20.0.0/16(async,wdelay,secure,no_root_squash,rw)

Make NFS start by default:

chkconfig portmap on
chkconfig nfs on
chkconfig nfslock on
service portmap restart
service nfs restart
service nfslock restart

It is crucial that clients access NFS via internal network since port mapping requires many addresses.

2. NFS client on Ubuntu

Install nfs-common:

apt-get install -y nfs-common autofs autofs-ldap

Edit /etc/defaults/nfs:

NEED_STATD=yes
STATDOPTS="--port 955 --outgoing-port 956"

Edit /etc/auto.master:

/group /etc/auto.group --timeout=600
      tcp,nolock,noatime,rsize=1024,wsize=1024,bg,intr,soft,
      nfsvers=3,port=2049,mountport=954,nosuid,rw

Note: The nolock option eases the gconfd NFS PITA (mentioned here) by disabling negotiation of file locking with the server. Probable side effect is that several users can run the same session from several hosts unattended and damage GNOME environment.

Edit /etc/auto.group:

.hidden 10.20.0.1:/group/hidden
public  10.20.0.1:/group/public
*       10.20.0.1:/group/&/Client

Restart automounter:

/etc/init.d/autofs reload

The trackerd crawler prevents auto mounts from unmounting. Remove it:

apt-get remove -y tracker

gconfd locks home directory some time after logout. The fix is described here.

3. NFS performance tuning

General guidelines:

  • Set noatime (Ubuntu performs the noatime action extensively)
  • In Gutsy, install nfs-common_1.1.2-4ubuntu1_i386.deb (fixes NFS bug)
  • Use rsize/wsize of 1024 to fit in a single VPN packet
  • Use tcp

Measurements

Time to start session:

Time (s) Client Server
50 tcp,lock,noatime,rsize=1024,wsize=1024,bg async,wdelay
45 tcp,lock,noatime,rsize=1024,wsize=1024 async,wdelay
45 udp,lock,noatime,rsize=1024,wsize=1024 async,wdelay
49 tcp,nolock,noatime,rsize=1024,wsize=1024 async,wdelay
53 tcp,nolock,noatime,rsize=1024,wsize=1024 async,wdelay
49 tcp,nolock,noatime,rsize=1024,wsize=1024 sync,no_wdelay
  • Common client options: bg,intr,soft,soft,nfsvers=3,mountport=954,nosuid,rw
  • Common server options: rw,secure,no_root_squash

Cite: UNIX NFS also uses large IO sizes by default, but each NFS client can choose its own read and write sizes. The size must be a power of 2, so I use 1024-byte IO sizes for NFS across my (UDP-based) OpenVPN tunnel between my home and office to make the NFS IO size fit into asingle VPN packet. I get performance on a par with what I'd expect given the underlying bandwidth.

4. UNFS on CentOS VPS

OpenVZ does not support NFS in the kernel, so the user-space daemon UNFS3 comes to rescue.

First, install the package:

yum install unfs3 

Edit /etc/sysconfig/unfsd

 # User-space NFSv3 daemon options. See man unfsd.
# "-n NFS_SERVICE_PORT -m MOUNT_SERVICE_PORT",
# (-t) TCP protocol, (-p) do not register with portmapper
OPTIONS="-n 950 -m 954 -t -p" 

Edit /etc/exports:

 # unfs3 does not support these options: wdelay,secure
#/group 10.20.0.0/16(async,wdelay,secure,no_root_squash,rw)
/group 10.20.0.0/16(secure,no_root_squash,rw)

Activate the daemon:

 chkconfig unfsd on
service unfsd restar t

The client configuration is basically the same. However, we don't use automounter, and the following NFS option changes in the master automounter file: port=950.

TODO: investigate if we can use rpc.statd with UNFS.

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
To prevent automated spam submissions leave this field empty.