Create NFS Sharable Directory

Goal: Setup a shared directory across cluster using NFS

Designate one of the machine to host the data files. That is where we are going to host a NFS server. Suppose, server01.einext.com is your NFS file server.

On NFS Server

Install NFS applications

$ sudo yum install nfs-utils nfs-utils-lib

Start NFS services

$ sudo chkconfig nfs on

$ sudo service rpcbind start

$ sudo service nfs start

Create a folder - consider this as data folder for your entire cluster.

$ sudo mkdir /data

$ sudo chmod 777 /data

Add the following line to /etc/exports file. * signifies any client can connect the NFS server. You restrict access by using server name or domain name.

/data *(rw,sync,no_root_squash,no_subtree_check)

Apply the new entry to the exports file

$ sudo exportfs -a

On the NFS Client machine

Verify that the nfs mount points are showing up.

$ sudo showmount -e <nfs server name>

Install the software

$ sudo yum install nfs-utils nfs-utils-lib

Create a mount point

$ sudo mkdir -p /nfs/data

$ sudo mount <nfs-server-name>:/data /nfs/data

$ sudo chmod 777 /nfs/data

On Mac OS

$ sudo mount_nfs -o resvport <nfs-server-name>:/data /nfs/data

Verify mount points

$ sudo df -h

$ sudo mount

$ ls -l /nfs/data

Testing the access

$ touch /nfs/data/test.txt

Enter the mount details in fstab for persistence.

$ sudo vi /etc/fstab

Add the following line

<nfs server name>:/data /mnt/nfs/data nfs auto,noatime,nolock,bg,nfsvers=3,intr,tcp,actimeo=1800 0 0

To reload all mount point after machine reboot, run the following command.

$ sudo mount -a