Autofs NFS mount fails with error “exports lookup failed for <hostname>”
Have you ever faced an “exports lookup failed for <hostname>” error in the /var/log/messages file while setting up NFS-based automount in the RHEL environment? It will also through an error like “key “server name” not found in map source(s)“.
Let me share my experience related to mount nfs share with autofs in rhel. The environment is RHEL and NFS/AutoFS.By default, autofs is shipped with the main distro if not you can simply install using the yum command.
Step by Step Procedure on how to Setup NFS Automount in RHEL
In this step-by-step process out target is to create /net-based lazy automount which should get mounted like /net/hostname.NFS master server is lnxsrv01 and NFS Client is lnxsrv02.
NFS Server Configuration in Linux
- Update /etc/export file with the directory name which you want to access on target NFS client server in below format.
# cat /etc/exports /home/data lnxsrv02(rw) # exportfs -a
- Restart NFS Service on master NFS Server.
For RHEL5,6 # service nfs restart For RHEL5,6,7 # systemctl start nfs Make it auto-start at reboot # systemctl enable nfs
- Validate Availability of NFS Share
# showmount -e Export list for lnxsrv01 /home/data hostname.abc.com
So now we have configured the NFS mount on lnxsrv01. It can be accessed from target hosts. Now let us see how to make it accessible on the target NFS Client machine as automount.
NFS Client Configuration in Linux
- First Validate that NFS Share is visible to the target NFS Client Server using the showmount command in linux like below
# showmount -e lnxsrv01 Export list for lnxsrv01 /home/data lnxsrv02.abc.com
In the above example, you can see that the NFS mount is visible to the target NFS Client-Server.
- Test Manual mounting NFS Share from NFS Master Server using below set of commands
# mkdir /a # mount -t nfs lnxsrv01:/home/data /a # df -h /a lnxsrv01:/home/data 550G 428G 94G 83% /a
So you have tested you are able to manually mount NFS Share. Now let us see how to set up as lazy /net automount so you can access it as /net/lnxsrv01.
How to Setup NFS Automount in RHEL
Step 1: Configure /etc/auto.master
File /etc/auto.master should look like below related to /net mount.
# cat /etc/auto.master # : auto.master,v 2.0 2008/04/22 Exp $ # Sample auto.master file # This is an automounter map and it has the following format # key [ -mount-options-separated-by-comma ] location # For details of the format look at autofs(5). /net -hosts -nosuid,nobrowse
Step 2: Configure /etc/nsswitch.conf
Secondly, you need to make sure automount is configured like below
# cat /etc/nsswitch.conf |grep automount automount: files
Step 3: Add NFS Server in the /etc/hosts file
Add NFS Server in the hosts file of NFS Client so it looks like below. Use FQDN.
# cat /etc/hosts |grep lnxsrv01 188.8.131.52 lnxsrv01 lnxsrv01.abc.com
Step 4: Restart NFS Service
Finally, Restart NFS Service on Target Server to make sure configuration gets implemented.
# service nfs restart # service nfs status
So now if you do simply cd to /net/lnxsrv01 you can simply perform any activity on a remote NFS file system from another NFS client machine.
That`s it about how to fix exports lookup failed for <hostname>error while configuring NFS as automount. This procedure has worked many times for me. If you have a similar scenario you can try it if it helps please comment and share with the needed audience to get benefited from this procedure in a critical state. While “key “server name” not found in map source(s)” can be simply ignored.