During my career, I have seen many different ways of creating shared storage for multiple web servers or database servers. It’s not always an easy thing to do. For one, you have to worry about file locking and file systems that support clustering.
But there’s a solution. A relatively new service in AWS is Elastic File System (EFS), which takes away the headache of maintaining your own NFS or iSCSI implementation, and allows you to scale indefinitely as required.
In this article I’m going to illustrate how to set up EFS and mount the export on your servers.
- Configure EFS within AWS Console
- Mount EFS filesystem on one or more servers
Configure EFS within AWS Console
To create your elastic file system, navigate to the Elastic File System button under Services in the Amazon console. Then click Create File System. You’ll be asked to specify the VPC and availability zones you want this deployed to. Select the choices relevant to your use case.
Stick with the defaults for any other choices unless you specifically want to use other functionality.
Now your filesystem will be in the process of being created, and you should see something similar to the following:
In order to connect to our new EFS NFS export, we’ll need to install a few tools on our OS. A couple of examples of how to do this follow:
On an Amazon Linux, Red Hat Enterprise Linux, or SuSE Linux instance:
sudo yum install -y nfs-utils
On an Ubuntu or Debian instance:
sudo apt-get install nfs-common
Then, let’s go ahead and create a directory for our EFS export to be mounted under:
Mount the EFS filesystem on 1 or more servers
Now we can go ahead and mount the filesystem. The command to do this can be obtained from the instructions link provided after creating your filesystem. It will provide you with a unique hostname.
Once it’s mounted, you should see a new mount point after running df -h (Look at all that space!):
You’re now good to go! You can simply use the mount command provided in the instructions on each of your instances to mount the shared EFS storage.
EFS is a fantastic replacement for your own Gluster, NFS or iSCSI implementation. It reduces complexity, is easy to set up, and is cost effective.
From start to finish, I had this up and running in around 15 minutes.
- More details on Amazon EFS can be found here: https://aws.amazon.com/efs/