Saturday, 26 April 2014

automount configuration from NFS

Objective:  Execute shared scripts from NFS server to local server, which is configured via auto-mounts.

Environment: CentOS 6.3 32-bit

Package version:  autofs-5.0

Why do we need to use an autofs ?

One drawback to using /etc/fstab is that, regardless of how infrequently a user accesses the NFS mounted file system, the system must dedicate resources to keep the mounted file system in place. This is not a problem with one or two mounts, but when the system is maintaining mounts to many systems at one time, overall system performance can be affected. An alternative to /etc/fstab is to use the kernel-based automount utility. An automounter consists of two components. One is a kernel module that implements a file system, while the other is a user-space daemon that performs all of the other functions. The automount utility can mount and unmount NFS file systems automatically (on demand mounting) therefore saving system resources.

On RPM based systems, autofs is not installed by default, hence I would assume you might be knowing on how to install the 'auotfs' package using package manager. 
All my scripts are been placed in the central server which is NFS, and I would share to my local client which is configured via auto-mounts in-order to save the system performance.

NFS config's:

The directory containing the scripts are shared in /etc/exportfs and access controls are provided to the client servers. Once your configurations are completed, make sure to start the nfs services.

#vi /etc/exporfs
/scripts    <IP address of the client>(ro,sync)

You can get the system information script from getsysinfo.sh. The same file will be shared to all the clients.

 autofs config's:

The primary configuration file for the automounter is /etc/auto.master, also referred to as the master map which may be changed. The master map lists autofs-controlled mount points on the system, and their corresponding configuration files or network sources known as automount maps.

# cat /etc/auto.master
/autofs         /etc/auto.fs    --timeout=3
#

I use a shorter time vaule common user will not recognize as a timespan or anything the user could get nervous about when waiting. 


# tail -2 /etc/auto.fs
scripts -rw,soft,intr,rsize=8192,wsize=8192     nfs.domain.com:/scripts
#

Save the file and make sure you start the service.
#service autofs start

Now, you can traverse to the directoy which will mount when in use and unmounts when not in use. 

#df -h /autofs/scripts
Filesystem            Size  Used Avail Use% Mounted on
nfs.domain.com:/scripts  8.7G  4.1G  4.3G  49% /autofs/scripts

# ls -l  /autofs/scripts
total 8
-rwxr-xr-x 1 root root 7391 Sep  1  2013 getsysinfo.sh
#

You could also use the same for the local file system. I would conclude this article here and the 'automounts' can be configured for NIS, CIFS where I may explain in coming articles.

No comments:

Post a Comment