Cloud Parallel File Storage (CPFS) can be accessed using the NFS protocol. After you create a CPFS file system, you need to enable the protocol service and create an export directory to generate a mount target. You can then install the CPFS-NFS client on an Elastic Computing Service (ECS) instance and run the mount command to access the CPFS file system. The mount target for an export directory is independent of a POSIX mount target. To access the CPFS file system only using the NFS protocol, you do not need to create a POSIX mount target. Deleting a POSIX mount target does not affect data access through the export directory.
Prerequisites
A CPFS file system has been created. For more information, see Create a file system.
A protocol service has been created. For more information, see Create a protocol service.
An export directory has been created. For more information, see Create an export directory.
One or more ECS instances have been created and meet the following two conditions. For more information, see Create an ECS instance.
An Internet IPv4 address is assigned or an Elastic IP (EIP) is associated.
The operating system is supported by the CPFS-NFS client.
Usage notes
Supported operating systems
Operating system type | Operating system version |
Alibaba Cloud Linux |
|
CentOS |
|
Ubuntu |
|
Debian |
|
SUSE |
|
IP addresses and ports
The CPFS-NFS client uses the local IP address 127.0.1.255 and the TCP port range 30000–60000 for port mapping during mount operations.
If the 127.0.1.255 IP address or the port range 30000–60000 is used by other software, modify the CPFS-NFS client configuration. For more information, see Client configuration.
File directories
After you install the CPFS-NFS client, the configuration directory (/etc/aliyun/cpfs), runtime directory (/var/run/cpfs), and log directory (/var/log/aliyun/cpfs/) for the client are created on the ECS instance.
Processes
After you mount a CPFS file system using the CPFS-NFS client, an haproxy process is started on the ECS instance to handle I/O access. A watchdog process is also started to monitor the health of the CPFS-NFS client.
Client logs
You can access the CPFS-NFS client logs in the /var/log/aliyun/cpfs/ path to find information about mount errors. You can also customize the content of the client logs by modifying the parameters in the log configuration file /etc/aliyun/cpfs/cpfs-utils.conf. After you modify the configuration file, run the sudo service aliyun-cpfs-mount-watchdog restart command to restart the backend watchdog process.
Step 1: Download and install the CPFS-NFS client
This client is open source. You can visit the GitHub repository to obtain the source code or compile it manually.
Log on to the ECS instance where you want to mount the CPFS file system. For more information, see Select a method to connect to an ECS instance.
Download and install the CPFS-NFS client.
Alibaba Cloud Linux
Download the CPFS-NFS client.
wget https://cpfs-hangzhou-nfs-client.oss-cn-hangzhou.aliyuncs.com/aliyun-alinas-utils-latest.al.noarch.rpmInstall the CPFS-NFS client.
sudo yum install aliyun-alinas-utils-*.rpm
CentOS
Download the CPFS-NFS client.
wget https://cpfs-hangzhou-nfs-client.oss-cn-hangzhou.aliyuncs.com/aliyun-alinas-utils-latest.el.noarch.rpmInstall the CPFS-NFS client.
sudo yum install aliyun-alinas-utils-*.rpm
Ubuntu
Download the CPFS-NFS client.
sudo wget https://cpfs-hangzhou-nfs-client.oss-cn-hangzhou.aliyuncs.com/aliyun-alinas-utils-latest.deb -O /tmp/aliyun-alinas-utils-latest.debInstall the CPFS-NFS client.
sudo apt-get update sudo apt-get install /tmp/aliyun-alinas-utils-latest.deb
Debian
Download the CPFS-NFS client.
sudo wget https://cpfs-hangzhou-nfs-client.oss-cn-hangzhou.aliyuncs.com/aliyun-alinas-utils-latest.deb -O /tmp/aliyun-alinas-utils-latest.debInstall the CPFS-NFS client.
sudo apt-get update sudo apt-get install /tmp/aliyun-alinas-utils-latest.deb
SUSE
Download the CPFS-NFS client.
wget https://cpfs-hangzhou-nfs-client.oss-cn-hangzhou.aliyuncs.com/aliyun-alinas-utils-latest.lp15.x86_64.rpmInstall the CPFS-NFS client.
sudo zypper --no-gpg-checks install -y aliyun-alinas-utils-*.rpm
Verify the installation of the CPFS-NFS client.
which mount.cpfs-nfsThe following is an example of a successful response:
/usr/sbin/mount.cpfs-nfs
Step 2: Mount the file system using the CPFS-NFS client
You can mount the CPFS file system.
sudo mount -t cpfs-nfs -o vers=3,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport file-system-id.region.cpfs.aliyuncs.com:/share/path /mntThe following table describes the parameters for the mount command.
Parameter
Description
file-system-id.region.cpfs.aliyuncs.com:/share/path /mnt
This indicates <mount_address> <local_mount_path>. Replace them with your actual values.
Mount address: The mount address of the export directory. In the File Storage NAS console, go to the file system list page. Click Manage next to the target file system to go to the Protocol Service page. In the Actions column, click Export Directory to open the Export Directory panel and obtain the mount address.
Example:
cpfs-196f91a8e58b****-195ceeac7b6ac****.cn-chengdu.cpfs.aliyuncs.com:/share/filesetLocal mount path: The root directory (/) or any subdirectory (for example, /mnt) on the Linux ECS instance. If it is a subdirectory, make sure the subdirectory exists.
vers
The version of the file system. CPFS supports mounting file systems only with the NFSv3 protocol.
Mount options
You can select multiple mount options when you mount a file system. Separate the options with commas (,). The options are described as follows:
rsize: Defines the size of the block for reading data between the client and the file system. Recommended value: 1048576.
wsize: Defines the size of the block for writing data between the client and the file system. Recommended value: 1048576.
NoteTo change the I/O size parameters (rsize and wsize), use the maximum value (1048576) to avoid performance degradation.
hard: If CPFS is temporarily unavailable, local applications that use a file on the file system stop and wait until the file system is back online. We recommend that you enable this parameter.
timeo: Specifies the time, in tenths of a second, that the CPFS-NFS client waits for a response before it retries sending a request to the file system. Recommended value: 600 (60 seconds).
NoteIf you must change the timeout parameter (timeo), use a value of 150 or greater. The unit for the timeo parameter is tenths of a second, so 150 represents 15 seconds.
retrans: The number of times the CPFS-NFS client retries a request. Recommended value: 2.
noresvport: Uses a new TCP port when the network reconnects. This ensures that the connection is not interrupted during network fault recovery. We recommend that you enable this parameter.
ImportantWe do not recommend using the soft option because it poses a data consistency threat. If you use the soft option, you are responsible for any associated threats.
Avoid setting any other mount options that differ from the default values. If you change the read or write buffer size or disable the attribute cache, performance may decrease.
Run the
mount -lcommand to verify the mount.After the file system is mounted, you can run the
df -hcommand to view its capacity.Optional: Configure automatic mounting at startup.
To prevent mount information from being lost when an ECS instance restarts, you can configure the /etc/fstab file on the Linux ECS instance. This enables the CPFS file system to be automatically mounted when the ECS instance restarts.
Open the /etc/fstab configuration file and add the mount configuration.
file-system-id.region.nas.aliyuncs.com:/share/path /mnt cpfs-nfs vers=3,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,_netdev,noresvport 0 0For a description of the main parameters in the example, see Mount command parameters. The other parameters are described as follows.
Parameter
Description
_netdev
Prevents the client from starting to mount the file system before the network is ready.
0 (the first item after noresvport)
A non-zero value indicates that the file system should be backed up by the dump command. For CPFS file systems, this value is 0 by default.
0 (the second item after noresvport)
This value indicates the order in which fsck checks file systems at startup. For CPFS file systems, this value is 0 by default, which means that fsck does not run at startup.
Run the
rebootcommand to restart the ECS instance.NoteBefore you restart the ECS instance, confirm that the manual mount was successful to avoid a restart failure. If the automatic mount is configured successfully, you can run the
df -hcommand after the ECS instance restarts to verify that the CPFS file system is mounted.
Client configuration
Configuration file
To modify the CPFS-NFS client configuration, contact the CPFS technical support team for guidance. Modifying the configuration file without guidance may affect I/O access. The configuration file is located at /etc/aliyun/cpfs/cpfs-utils.conf. The following is a sample configuration:
[DEFAULT]
logging_level = INFO
logging_max_bytes = 1048576
logging_file_count = 10
[mount]
stunnel_debug_enabled = false
# Validate the certificate hostname on mount. This option is not supported by certain stunnel versions.
stunnel_check_cert_hostname = false
# Use OCSP to check certificate validity. This option is not supported by certain stunnel versions.
stunnel_check_cert_validity = false
proxy_port = 12049
cpfs_proxy_addr = 127.0.1.255
cpfs_proxy_port_min = 30000
cpfs_proxy_port_max = 60000
[mount-watchdog]
poll_interval_sec = 1
unmount_grace_period_sec = 30
dns_refresh_interval = 60
[client-tool]The following table describes the important parameters in the configuration file:
Parameter | Description |
logging_level | The log level. The default value is INFO. |
logging_max_bytes | The maximum size of a log file. The default value is 1048576 bytes, which means the maximum size of a single log file is 1 MiB. |
logging_file_count | The maximum number of log files to retain. The default value is 10, which means a maximum of 10 log files are retained. |
cpfs_proxy_addr | The proxy IP address of the CPFS client. The default value is 127.0.1.255. |
cpfs_proxy_port_min | The minimum value of the proxy port range for the CPFS client. The default value is 30000. |
cpfs_proxy_port_max | The maximum value of the proxy port range for the CPFS client. The default value is 60000. |
poll_interval_sec | The detection interval of the backend watchdog service. The default value is 1 s. |
unmount_grace_period_sec | The quiet time for cleaning up the corresponding configuration file after you unmount the CPFS-NFS mount target. The default value is 30 s. |
dns_refresh_interval | The interval at which the backend watchdog service checks whether the primary and secondary nodes corresponding to the DNS are active. The default value is 60 s. |
haproxy configuration
The CPFS-NFS client automatically generates an haproxy configuration file and starts the haproxy process during the mount process. Do not modify this configuration file. Otherwise, I/O access may be affected. You can view the configuration file at /var/run/cpfs/haproxy-config.dns. The following is an example.
global
maxconn 4096
defaults
mode tcp
balance leastconn
timeout client 60s
timeout server 60s
timeout connect 3s
retries 3
frontend cpfs2049
bind 127.0.1.255:30000
default_backend bk2049
backend bk2049
server cpfs_primary 172.27.1.189:2049 maxconn 2048 check port 2049 inter 2s fall 5 rise 30 on-marked-up shutdown-backup-sessions
server cpfs_backup 172.27.0.214:2049 maxconn 2048 check port 2049 inter 2s fall 5 rise 30 backupThe following table describes the important parameters:
Parameter | Description |
defaults | We do not recommend that you modify the default parameter values. |
frontend | The local IP address and port for the haproxy proxy. The default IP address is 127.0.1.255, and the port range is 30000–60000. |
backend | The IP address of the backend CPFS-NFS service. |