NFS Configuration On AWS Environment

Deepak Surendran
Tensult Blogs
Published in
4 min readMar 27, 2019
Ref : https://bit.ly/2CFrpS2

Sometimes we need to share out data on a central server. Normally we are doing this task through NFS or samba/cifs protocol. NFS protocol is developed by Sun Microsystems in 1984. It allows users to access the data on centralized location over the network. It’s a way of mounting Linux discs/directories over a network so that we have a single copy of data in a centralized location and we can access it from different systems. If you have both Linux and Windows machines, you can use samba/cifs. As a Linux Engineer, I won’t suggest using samba/cifs for Linux machines, because its performance is far below than NFS. If you are using samba/cifs on a Linux machine, then it will work like two English speakers are communicating through a French/Spanish speaker. So it’s better to use NFS, if you are using Linux machines. If you have any further queries about samba, please click here.

Now I am going to illustrate how to set up centralized storage using NFS protocol in AWS. Here I am using 3 RHEL instances, one as an NFS-server and other two as NFS-clients. You can set the NFS using 2 instances also. One as NFS-server and other one is a client. Here I am taking the former combination of 3 RHEL instances. Please connect to the NFS server and do the following:

First We need to install nfs-utils package on our NFS server. It contains all the necessary services to build our NFS server.

Now we need to create a directory that we need to share and just change the permissions of the shared directory.

We need to enable and start necessary services for the proper working of NFS.

In the next step we are going to configure NFS share directory over the network, For that please edit the /etc/exports file.

sudo vi /etc/exports

Here, 172.31.22.1 and 172.31.23.119 are the IP addresses of the NFS client machines. Just restart the NFS service and share the folder using exportfs command,

sudo systemctl restart nfs-server
sudo exportfs

Our folder is exported now. We need to go to our nfs client machines and need to install the necessary packages and create the nfs directory mount points,

sudo yum install nfs-utils
sudo mkdir -p /mnt/nfs-share

Next, we need to mount the NFS shared directory,

sudo vi /etc/fstab

and mount it using,

sudo mount -a

Once the above steps are completed, we can try to create some test files in NFS share directory and check it in NFS directory mount point in client to verify this.

First login to NFS-server and go to the shared directory and create a test file there,

Now go to the client machine and check the NFS directory mount point,

As you can see above, our NFS configuration is working now. Just follow the same steps in our second instance also. Now I am are trying to implement High availability for NFS server. If anyone has an idea about building NFS cluster with high availability on AWS environment, Please share the details in the comment section.

This Blog has been moved from Medium to blogs.tensult.com. All the latest content will be available there. Subscribe to our newsletter to stay updated.

--

--