CPFS supports access over the NFS protocol. After you create a CPFS file system, enable the protocol service and create an export directory to generate a mount target. Then, install the CPFS-NFS client on an ECS instance and run the mount command to access the file system. The mount target for an export directory is independent of POSIX mount targets. If you only need to access the CPFS file system over the NFS protocol, you do not need to create a POSIX mount target. Deleting an existing POSIX mount target does not affect data access through the export directory.
Prerequisites
-
A CPFS file system is created. For more information, see Create a file system.
-
A protocol service is created. For more information, see Create a protocol service.
-
An export directory is created. For more information, see Create an export directory.
-
One or more ECS instances are created and meet the following conditions. For more information, see Create an ECS instance.
-
A public IPv4 address is assigned or an Elastic IP address is associated with the ECS instance.
-
The operating system of the instance is one of the supported operating systems for the CPFS-NFS client.
-
Usage
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 from 30000 to 60000 for port mapping when you mount a file system.
If another application is already using the 127.0.1.255 IP address or the port range from 30000 to 60000, modify the CPFS-NFS client configuration. For more information, see Client configuration.
File directories
Installing the CPFS-NFS client creates the following directories on the ECS instance: the configuration file directory (/etc/aliyun/cpfs), the runtime directory (/var/run/cpfs), and the log directory (/var/log/aliyun/cpfs/).
The runtime directory stores the automatically generated haproxy configuration files. If you specify a custom path by using the hp_config_dir option, that path is used instead.
Processes
After you mount a CPFS file system using the CPFS-NFS client, an haproxy process starts on the ECS instance for I/O access. A watchdog process also starts to monitor the health of the CPFS-NFS client.
Client logs
You can find information about mount errors in the CPFS-NFS client logs in the /var/log/aliyun/cpfs/ directory. To customize the log content, modify the parameters in the log configuration file at /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. For the source code or to compile it manually, visit the GitHub repository.
-
Log on to the ECS instance where you will mount the CPFS file system. For more information about how to connect to an ECS instance, see Connection methods.
-
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.rpm -
Install 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.rpm -
Install 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.deb -
Install 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.deb -
Install 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.rpm -
Install the CPFS-NFS client.
sudo zypper --no-gpg-checks install -y aliyun-alinas-utils-*.rpm
-
-
Verify the installation.
which mount.cpfs-nfsA successful installation returns the following output:
/usr/sbin/mount.cpfs-nfs
Step 2: Mount the file system with the client
-
Mount the CPFS file system.
-
Scenario 1: General mount (default path)
This scenario applies to most environments that do not have AppArmor, SELinux, or other special path access restrictions enabled.
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 /mnt -
Scenario 2: Mount in a high-security environment (for example, on systems with SELinux or AppArmor enabled)
If security hardening policies, such as AppArmor or SELinux, are enabled on your operating system, the default mount might cause access errors. In this case, specify a path using the hp_config_dir option. When you run the command, replace
<custom_directory>with a path that your system's security policy allows.sudo mount -t cpfs-nfs -o vers=3,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport,hp_config_dir=<custom_directory> file-system-id.region.cpfs.aliyuncs.com:/share/path /mnt
-
-
Mount command parameters
Parameter
Description
file-system-id.region.cpfs.aliyuncs.com:/share/path /mnt
Specifies the mount path and the local path. Replace them with your actual values.
-
Mount path: The mount path of the export directory. In the File Storage NAS console, on the file system list page, click Manage for 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 path.
Example:
cpfs-196f91a8e58b****-195ceeac7b6ac****.cn-chengdu.cpfs.aliyuncs.com:/share/fileset -
Local path: The path on the ECS instance where you want to mount the file system. This can be the root directory (/) or any subdirectory, such as /mnt. If you specify a subdirectory, ensure that it already exists.
vers
The NFS version. CPFS supports only NFSv3.
Mount options
You can specify multiple mount options separated by commas (,). The following options are available:
-
rsize: The size of the data block (in bytes) used for reading data between the client and the file system. Recommended value: 1048576.
-
wsize: The size of the data block (in bytes) used for writing data between the client and the file system. Recommended value: 1048576.
NoteIf you need to change the I/O size parameters (rsize and wsize), we recommend that you use the maximum value (1048576) to avoid performance degradation.
-
hard: If the CPFS file system becomes temporarily unavailable, a local application that uses a file on the file system stops and waits until the file system is back online. This option is recommended.
-
timeo: The duration, in tenths of a second, that the CPFS-NFS client waits for a response before it retries a request to the file system. Recommended value: 600 (60 seconds).
NoteIf you must change the timeout parameter (timeo), we recommend that you use a value of 150 or greater. This value is in tenths of a second, so 150 corresponds to 15 seconds.
-
retrans: The number of times the CPFS-NFS client retries a request. Recommended value: 2.
-
noresvport: Uses a new TCP port upon network reconnection to ensure that the connection is not interrupted during network fault recovery. This option is recommended.
Important-
The
softoption is not recommended because it poses a risk to data consistency. If you use thesoftoption, you assume all associated risks. -
Avoid setting any other mount options to values that are different from the recommended values. For example, changing the read or write buffer sizes or disabling attribute caching can degrade performance.
-
-
hp_config_dir: (Optional) Specifies the directory that contains the haproxy configuration file. Set this parameter if your operating system has security enforcement policies (such as AppArmor or SELinux) or other high-security policies that restrict processes to reading configurations or running only in specific paths.
-
Path selection recommendation: Select a suitable directory from your system's security policy allowlist and make sure that the path is authorized by the security module.
-
Logic: The CPFS client first tries to use the directory specified by this parameter. If you do not specify this parameter, the client attempts to automatically parse the security policy allowlist. If parsing fails, the client falls back to the default path
/var/run/cpfs.
-
-
-
Run the
mount -lcommand to view the mount information.After the file system is mounted, you can run the
df -hcommand to view the capacity information of the file system. -
(Optional) Configure automatic mount on startup.
To prevent mount information from being lost after the ECS instance restarts, you need to configure the
/etc/fstabfile. If you used thehp_config_dirparameter during manual mounting, you must also configure it here.-
Open the
/etc/fstabconfiguration file and add the mount configuration.-
Configuration for a general environment:
file-system-id.region.cpfs.aliyuncs.com:/share/path /mnt cpfs-nfs vers=3,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,_netdev,noresvport 0 0 -
Example configuration for a high-security environment:
Replace
<custom_directory>with a path that your system's security policy allows.file-system-id.region.cpfs.aliyuncs.com:/share/path /mnt cpfs-nfs vers=3,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,_netdev,noresvport,hp_config_dir=<custom_directory> 0 0 -
The following table describes the other parameters.
Parameter
Description
_netdev
Prevents the client from attempting to mount the file system before the network is ready.
0 (the first item after noresvport)
A non-zero value indicates that the dump command should back up the file system. For CPFS file systems, this value is 0.
0 (the second item after noresvport)
Indicates the order in which the fsck command checks the file system at startup. For CPFS file systems, this value is 0, which prevents fsck from running at startup.
-
-
Run the
rebootcommand to restart the ECS instance.Before you restart the ECS instance, confirm that the manual mount was successful to prevent the instance from failing to restart. If the automatic mount is configured successfully, you can run the
df -hcommand to view the mounted CPFS file system after the ECS instance restarts.
-
Client configuration
Configuration file
If you need to modify the CPFS-NFS client configuration, contact the CPFS technical support team. Modify the configuration file only under their guidance to avoid disrupting I/O access. The configuration file is located at /etc/aliyun/cpfs/cpfs-utils.conf. The following is a configuration example:
[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. Default value: INFO. |
|
logging_max_bytes |
The maximum size of a log file, in bytes. Default: 1048576 (1 MiB). |
|
logging_file_count |
The maximum number of log files to retain. Default value: 10. |
|
cpfs_proxy_addr |
The proxy IP address for the CPFS client. Default value: 127.0.1.255. |
|
cpfs_proxy_port_min |
The minimum value of the proxy port range for the CPFS client. Default value: 30000. |
|
cpfs_proxy_port_max |
The maximum value of the proxy port range for the CPFS client. Default value: 60000. |
|
poll_interval_sec |
The detection interval for the background watchdog service. Default value: 1s. |
|
unmount_grace_period_sec |
The grace period for cleaning up the corresponding configuration files after you unmount a CPFS-NFS mount target. Default value: 30s. |
|
dns_refresh_interval |
The interval at which the background watchdog service checks the DNS records to determine whether the primary and secondary nodes are available. Default value: 60s. |
Haproxy configuration
During the mount process, the CPFS-NFS client automatically generates an haproxy configuration file and starts the related processes. Do not manually modify this configuration file. Otherwise, I/O access might be disrupted. You can view the haproxy-config.dns configuration file for details. By default, this file is stored in the /var/run/cpfs/ directory. If you specified the hp_config_dir parameter during the mount, the file is stored in the specified custom directory. The following code shows an example of the file content:
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 backup
The following table describes the important parameters.
|
Parameter |
Description |
|
defaults |
We recommend that you do not 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 to 60000. |
|
backend |
The IP addresses of the backend CPFS-NFS service, where |