Note:
- This tutorial requires access to Oracle Cloud. To sign up for a free account, see Get started with Oracle Cloud Infrastructure Free Tier.
- It uses example values for Oracle Cloud Infrastructure credentials, tenancy, and compartments. When completing your lab, substitute these values with ones specific to your cloud environment.
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.
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.
Task 1: Install and configure FS-Cache server
-
To deploy NFS cache on OCI, provision an Oracle Linux compute instance using one of E4.DenseIO.Flex shapes.
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.
-
Select VCN and subnet, add public SSH key.
-
Open Advanced Options and add the
cloud-init
script: install.shThe script does the following:
- Configures RAID-0 on available NVMe disks
- Creates a filesystem on RAID-0 device and mounts it
- Installs cachefiled package and starts cachefiled service
- Enables NFS server
- Configures SELinux and Linux firewall
Task 2: Create and export NFS share
-
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
-
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
-
Replace
<FS-Cache-mount-point>
with the actual path of the mount point. Runexportfs
command.sudo exportfs -a
-
Check that the
cachfilesd
service is running.sudo systemctl status cachefilesd
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.
Related Links
- Getting started with FS-Cache
- How to Create Linux Instance
- Creating a Virtual Cloud Network
- How to create Network Load Balancer
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.
Deploy NFS Cache on Oracle Cloud Infrastructure
F86787-01
September 2023
Copyright © 2023, Oracle and/or its affiliates.