This topic describes how to mount a Network File System (NFS) file system on an RDS Custom instance. You can mount an NFS file system on multiple RDS Custom instances to enable the instances to share access to the file system.
Prerequisites
An RDS Custom instance is created. For more information, see Create an RDS Custom instance.
A Network Attached Storage (NAS) file system is created in the region in which the RDS Custom resides. In this topic, an Extreme NAS file system is created. For more information, see Create an Extreme NAS file system in the NAS console.
A mount target is created for the NAS file system, and the domain name of the mount target is obtained. The mount target must reside in the same virtual private cloud (VPC) as the RDS Custom instance. For more information, see Manage mount targets.
Procedure
Connect to an RDS Custom instance For more information, see Connect to an RDS Custom instance.
Install the NFS client.
Before you mount an NFS file system on Linux, you must install an NFS client. You need to install the NFS client on each Linux server only once. You do no need to install the NFS client the next time you mount a file system on the Linux server.
Operating system
Installation command
Alibaba Cloud Linux
sudo yum install nfs-utilsCentOS
Redhat
Ubuntu
Run the following installation commands in sequence:
sudo apt-get updatesudo apt-get install nfs-commonDebian
Run the following command to mount the NAS file system:
sudo mount -t nfs -o vers=3,noacl,nolock,proto=tcp,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2, noresvport file-system-id.region.extreme.nas.aliyuncs.com:/share /mntThe following table describes the parameters in the mount command.
Parameter
Description
file-system-id.region.extreme.nas.aliyuncs.com:/share /mnt
The format is <Domain name of a mount target>:<Directory of the NAS file system> <Mount directory that resides on the current server>. You must configure the parameter as needed.
Domain name of a mount target: To view the domain name, perform the following steps: Log on to the NAS console. On the File System List page, find the file system that you want to manage and click Manage in the Actions column. On the Mount Targets tab, view the domain name of the mount target. For more information, see Manage mount targets.
Directory of the NAS file system: If you use an Extreme NAS file system, the directory must start with /share. Examples: /share and /share/subdir. If you specify a subdirectory, make sure that the subdirectory exists in the NAS file system.
Mount directory that resides on the current server: a subdirectory of the RDS Custom instance, such as /mnt. Make sure that the subdirectory exists.
NoteIf you specify a mount directory that resides on the current server and contains data, the data becomes temporarily invisible after the file system is mounted. Only data in the file system is displayed in the mount directory. We recommend that you specify an empty directory.
vers
The protocol version of the file system.
vers=3: uses NFSv3 to mount the file system.
vers=4: uses NFSv4 to mount the file system.
Where
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.
NoteExtreme NAS file systems support only NFSv3.
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 disabled and NAS is unavailable, the client may immediately return an error without retrying, which may cause data inconsistency or loss.
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 connectivity between the file system and the Elastic Compute Service (ECS) instance when the network recovers from a failure.
We recommend that you enable this parameter.
Run the following command to verify the mount result:
mount -lIf a command output that is similar to the following example appears, the mount is successful.
After the file system is mounted, you can run the
df -hcommand to view the capacity of the file system.
After the NAS file system is mounted, read data from and write data to the NAS file system on the ECS instance running Linux.
You can access the file system the same way you access a local directory. The following figure shows an example.
