Note:

Deploy NFS Cache on Oracle Cloud Infrastructure

Introduction

When multiple cloud-based compute instances require access to on-premises NFS storage, you can deploy NFS cache on cloud. To improve NFS performance data is cached on cloud when an NFS client requests it. NFS client nodes write data directly back to your NFS origin file server using write-through caching.

NFS performance is very sensitive to network latency. Even a relatively small network latency can significantly degrade NFS performance for both reads and writes. When using on-premises NFS storage, deploying NFS cache on cloud can lead to significant performance benefits, particularly for “read-heavy” workloads.

Objective

Deploy NFS caching solution on Oracle Cloud Infrastructure (OCI).

Prerequisites

You must have a virtual cloud network (VCN) configured with a private or public subnet where NFS cache will be installed. OCI subnet should have connectivity to on-premises NFS server and TCP port 2049 must be open in the subnet security list. It is recommended to setup a VPN tunnel or OCI Fast Connect between on-premises NFS server and NFS cache server on cloud.

Note: This tutorial refers to NFS4 version. For older NFS versions you may need to open addition ports in the subnet security list.

Architecture

NFS cache can be deployed in a number of different architectures. In this example, we are using the following architecture.

Image1

For High Availability (HA), you can install a Network Load balancer with 2 or more backend NFS cache servers and configure TCP/2049 port in the Network Load balancer listener.

Image2

Task 1: Install and configure FS-Cache server

  1. To deploy NFS cache on OCI, provision an Oracle Linux compute instance using one of E4.DenseIO.Flex shapes.

    Image3

    Note: These Dense I/O shapes have different number of NVMe local disks. NVMe storage will be used for caching NFS data. Select the shape based on the storage requirements.

  2. Select VCN and subnet, add public SSH key.

  3. Open Advanced Options and add the cloud-init script: install.sh

    Image4

    The script does the following:

    1. Configures RAID-0 on available NVMe disks
    2. Creates a filesystem on RAID-0 device and mounts it
    3. Installs cachefiled package and starts cachefiled service
    4. Enables NFS server
    5. Configures SELinux and Linux firewall

Task 2: Create and export NFS share

  1. Create a directory for NFS mount point, and mount NFS Server share to FS-Cache VM using -fsc option. For example:

    sudo mount <NFS-server-IP>:<NFS-share> <FS-Cache-mount-point> -o fsc
    
    where:  <NFS-server-IP> is the IP of the origin NFS server
    	<NFS-share> is the path of NFS share directory from the origin NFS server
    	<FS-Cache-mount-point> is the mount point on FS-Cache server
    
  2. Export the local mount point by editing the /etc/exports file.

    sudo echo "<FS-Cache-mount-point> *(rw,wdelay,no_root_squash,no_subtree_check,fsid=10,sec=sys,rw,secure,no_root_squash,no_all_squash)" > /etc/exports
    
  3. Replace <FS-Cache-mount-point> with the actual path of the mount point. Run exportfs command.

    sudo exportfs -a
    
  4. Check that the cachfilesd service is running.

    sudo systemctl status cachefilesd
    

    Image5

Task 3: Mount NFS share on NFS clients

Mount directories exported from FS-Cache server to NFS clients. For example, on NFS client you can run the following command.

sudo mount <FS-Cache-IP>:<FS-Cache-mount-point> <local-mount-point>

where:  <FS-Cache-server-IP> is the IP of FS-Cache server
	<FS-Cache-mount-point> is the path exported from FS-Cache server
	<local-mount-point> is the mount point on NFS client  

When reading files that are not cached yet on FS-Cache server the access time will be longer. However, when a file is cached the read time will be comparable to accessing NFS server on the same LAN. The difference will be even more obvious when many NFS clients read the same content from the NFS share.

Acknowledgments

Author - Michael Prestin (Master Principal Cloud Architect)

More Learning Resources

Explore other labs on docs.oracle.com/learn or access more free learning content on the Oracle Learning YouTube channel. Additionally, visit education.oracle.com/learning-explorer to become an Oracle Learning Explorer.

For product documentation, visit Oracle Help Center.