Skip to main content

Getting Started with Shared Storage (NFS)

NFS stands for Network File System and allows you to mount a file system from 1 host to another. In this case, we will be mounting a directory from a server to several webservers in order to have the site files mirrored on all of the servers or virtual machines.

Requirements

A minimum of 1 server or virtual machine is necessary to setup shared storage. 

Configuring NFS Master

Deploy a VM in our cloud service and then follow these steps to install and configure NFS.

  1. Execute the following command as root to install NFS on your server if it isn't already.

    yum install nfs-utils
  2. Now enable and start the NFS service.

    systemctl enable --now nfs-server
  3. Create a directory that you want to share with the other servers or VMs.

    mkdir -pv /mnt/home
  4. Edit the exports file to allow your IPs access to the shared mount directory:

    Example Content in /etc/exports

    /mnt/home 198.49.75.201(rw,no_subtree_check,insecure,no_root_squash)
    /mnt/home 198.49.75.249(rw,no_subtree_check,insecure,no_root_squash)

    ⚠️ The example above is just for illustrative purposes. It follows this pattern:

    mountpoint IP-address-to-be-permitted-access (mounting-options-for-that-IP)

    You should check man exports on your NFS server to see the variety of options for setting up your /etc/exports file.

  5. Export the filesystem.

    exportfs -a
  6. Add the IPs that will be accessing NFS to the firewall (the following commands assume you are using firewalld.

    firewall-cmd --new-zone=nfs --permanent
    firewall-cmd --zone=nfs --add-service=nfs --permanent
    firewall-cmd --zone=nfs --add-source=198.49.75.249 --permanent
    firewall-cmd --zone=nfs --add-source=198.49.75.201 --permanent
    firewall-cmd --reload

Configuring NFS Clients

Now that you have the NFS mounts prepared, you need to install NFS on all of the servers that will need to access the mounts.

  1. Install nfs-utils.

    yum install nfs-utils
  2. Mount the home folder.

    Mount the home folder.
    mount -t nfs -o vers=4 67.23.235.138:/mnt/home /home
  3. Repeat this on any other servers that need access.