After you create a Network File System (NFS) file system, you can mount the NFS file system on Edge Node Service (ENS) instances. This way, multiple ENS instances can share the NFS file system. This topic describes how to mount an NFS file system on a Linux ENS instance. To do so, you must log on to the ENS instance first.
Prerequisites
A Linux ENS instance is available on the edge node on which you create a NAS file system.
A NAS file system is created and the URL of the mount target of the NAS file system is obtained. The NAS file system and the ENS instance reside in the same virtual private cloud (VPC).
Procedure
Connect to the ENS instance.
Install an NFS client. Before you mount an NFS file system on a Linux ENS instance, you must install an NFS client. You need to install the NFS client on each Linux ENS instance only once. You do no need to install the NFS client the next time you mount a file system on the ENS instance.
Operating system
Installation command
CentOS
sudo yum install nfs-utilsUbuntu
sudo apt-get updateDebian
sudo apt-get install nfs-commonMount an NFS file system.
To ensure optimal access performance, we recommend that you mount a file system by using NFSv3.
NFS v4 supports file locks, including range locks. If you need to modify a file on multiple Linux ENS instances at the same time, we recommend that you mount a file system by using NFS v4.
You can obtain the mount commands for the NFS v3 and NFS v4 protocols on the details page of the target file system. You can use the shortcut key to copy the mount commands. Select a mount command based on your business requirements. For more information, see View a mount target.
NoteBy default, the UID information is added to mount target addresses for the NFS v3 protocol as a part of the file system directory.
To use NFSv3 to mount the file system, run the following command:
sudo mount -t nfs -o vers=3,nolock,proto=tcp,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport 100.64.XXX.XXX:/UID/source_path /target_pathTo use NFSv4 to mount the file system, run the following command:
sudo mount -t nfs -o vers=4,minorversion=0,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport 100.64.XXX.XXX:/source_path /target_path
Parameters
Parameter
Description
100.64.XXX.XXX:/source_path /target_path
The command syntax is <Mount target address>:<Name of a shared directory><Path of a mount directory>. You must replace the domain name, directory name, and directory path with their actual values.
Mount target address: 100.64.XXX.XXX. You can view the mount target address on the NAS page.
Name of a shared directory: /source_path specifies a subdirectory that exists in the NAS file system, such as
/share. /source_path cannot specify a root directory.Path of a mount directory: /target_path specifies a subdirectory of the ENS instance, such as
/mnt. Make sure that the subdirectory exists.
vers
The protocol version of the file system.
vers=3: uses NFS v3 to mount the file system.
vers=4: uses NFS v4 to mount the file system.
minorversionspecifies the minor version number of the protocol. NAS file systems support NFSv4.0. If you use NFSv4 to mount a NAS file system, you must set the minor version number to 0.rsize
The size of data blocks that the client can read from the file system.
Recommended value: 1048576.
wsize
The size of data blocks that the client can write to the file system.
Recommended value: 1048576.
hard
If this parameter is not enabled, when File Storage NAS is unavailable, the client may immediately return an error without retrying, which may cause inconsistency or loss of data.
We recommend that you enable this parameter.
timeo
The period of time for which the NFS client waits before the client retries to send a request. Unit: deciseconds (tenths of a second).
Recommended value: 600 (60 seconds).
retrans
The number of times that the NFS client retries to send a request.
Recommended value: 2.
noresvport
Specifies that a new TCP port is used to ensure network continuity between the file system and the ENS instance when the network recovers from a failure.
We recommend that you enable this parameter.
Note:
If you need to modify the
timeomount option, we recommend that you specify 150 or a greater value. Thetimeoparameter is measured in deciseconds (tenths of a second). For example, the value 150 indicates 15 seconds.To prevent performance degradation, we recommend that you set both the
rsize and wsizeparameters to 1048576.To prevent data inconsistency, we recommend that you do not specify the soft mount option. If you specify the soft mount option, make sure that you understand the potential risks.
We recommend that you do not set any other mount options that are different from the defaults. If you change the read or write buffer sizes or disable attribute caching, the performance may be reduced.
NoteIf an ENS instance has only one internal NIC (primary NIC), the default route for accessing NAS points to the primary NIC. If the instance has multiple NICs, such as a public NIC and an internal NIC, the internal NIC cannot be used to access NAS. You need to run the following command to manually add a route in the instance before you can use the internal NIC to access NAS:
ip route add 100.64.xxx.xxx(NAS mount target address)dev ethX(internal NIC).Verify the mount result.
After the NFS file system is mounted, you can run the
df -hcommand to view the capacity of the NFS file system.