Troubleshooting NFS
A basic NFS configuration usually works without problems when the client and server are on the same network. The most common problems are caused by forgetting to start NFS, to edit the /etc/fstab file, or to export the /etc/exports file. Another common cause of failure is the iptables firewall daemon running on either the server or client without the administrator realizing it.
When the client and server are on different networks, these checks still apply, but you'll also have to make sure basic connectivity has been taken care of as outlined in Chapter 4, "Simple Network Troubleshooting." Sometimes a firewall being present on the path between the client and server can cause difficulties.
As always, no troubleshooting plan would be complete without frequent reference to the /var/log/messages file when searching for additional clues. Table 29.2 shows some common NFS errors you'll encounter.
Table 29.2. Some Common NFS Error MessagesOption | Description |
|---|
Too many levels of remote in path | Attempting to mount a filesystem that has already been mounted. | Permission denied | User is denied access. This could be the client's root user who has unprivileged status on the server due to the root_squash option. Could also be because the user on the client doesn't exist on the server. | No such host | Typographical error in the name of the server. | No such file or directory | Typographical error in the name of the file or directory; they don't exist. | NFS server is not responding | The server could be overloaded or down. | Stale file handle | A file that was previously accessed by the client was deleted on the server before the client closed it. | Fake hostname | Forward and reverse DNS entries don't exist for the NFS client. |
The showmount Command
When run on the server, the showmount -a command lists all the currently exported directories. It also shows a list of NFS clients accessing the server, in this case one client has an IP address of 192.168.1.102:
[root@bigboy tmp]# showmount -a
All mount points on bigboy:
*:/home
192.168.1.102:*
[root@bigboy tmp]#
The df Command
The df command lists the disk usage of a mounted filesystem. Run it on the NFS client to verify that NFS mounting has occurred. In many cases, the root_squash mount option will prevent the root user from doing this, so it's best to try it as an unprivileged user.
[nfsuser@smallfry nfsuser]$ df -F nfs
Filesystem 1K-blocks Used Available Use% Mounted on
192.168.1.100:/home/nfsuser
1032056 346552 633068 36% /home/nfsuser
[nfsuser@smallfry nfsuser]$
The nfsstat Command
The nfsstat command provides useful error statistics. The -s option provides NFS server stats, while the -c option provides them for clients. Threshold guidelines are provided in Table 29.3.
[root@bigboy tmp]# nfsstat -s
Server rpc stats:
calls badcalls badauth badclnt xdrcall
1547 0 0 0 0
Server nfs v2:
null getattr setattr root lookup readlink
244 100% 0 0% 0 0% 0 0% 0 0% 0 0%
read wrcache write create remove rename
0 0% 0 0% 0 0% 0 0% 0 0% 0 0%
link symlink mkdir rmdir readdir fsstat
0 0% 0 0% 0 0% 0 0% 0 0% 0 0%
Server nfs v3:
null getattr setattr lookup access readlink
251 19% 332 25% 0 0% 265 20% 320 24% 0 0%
read write create mkdir symlink mknod
39 2% 14 1% 1 0% 1 0% 0 0% 0 0%
remove rmdir rename link readdir readdirplus
0 0% 0 0% 0 0% 0 0% 0 0% 31 2%
fsstat fsinfo pathconf commit
1 0% 34 2% 0 0% 14 1%
[root@bigboy tmp]#
Table 29.3. Error Thresholds for the nfsstat CommandValue | Threshold | Description |
|---|
Readlink | > 10% | Excessive numbers of symbolic links slowing performance. Try to replace them with a directory and mount the filesystem directly on this new mount point. | Getattr | >50% | File attributes, like file data, is cached in NFS. This value tracks the percentage of file attribute reads that are not from cache refresh requests. Usually caused by the NFS noac mount option, which prevents file attribute caching. | badcalls | > 0 | Bad RPC requests. Could be due to poorly configured authentication, the root user attempting to access data governed by the root_squash directive, or having a user in too many groups. | retrans | > 5% | Percentage of requests for service that the client had to retransmit to the servers. Could be due to slow NFS servers or poor network conditions. | Writes | > 10% | Writes are slow due to poor caching values. Check the noac and wsize mount options. | Read | > 10% | Reads are slow due to poor caching values. Check the noac and rsize mount options. |
|