Use Protocol services to access CPFS over NFS. NFS provides broad operating system compatibility and flexible compute options while retaining the high throughput of CPFS. This quick start uses CentOS to show how to create a CPFS file system and mount it over NFS. Protocol services provide NFS mount targets independently of POSIX mount targets.
Prerequisites
The CPFS service is activated.
When you log on to the CPFS console for the first time, activate the CPFS service as prompted.
An Elastic Compute Service (ECS) instance that meets the following requirements is created. For more information, see Create an instance.
A public IPv4 address is assigned or an elastic IP address (EIP) is associated with the ECS instance.
The instance runs one of the following operating systems supported by the CPFS-NFS client:
Operating system type
Operating system version
Alibaba Cloud Linux
-
Alibaba Cloud Linux 3.2104 64-bit
-
Alibaba Cloud Linux 2.1903 64-bit
CentOS
-
CentOS 8.x 64-bit
-
CentOS 7.x 64-bit
Ubuntu
-
Ubuntu 20.04 64-bit
-
Ubuntu 18.04 64-bit
-
Ubuntu 16.04 64-bit
Debian
-
Debian 10.x 64-bit
-
Debian 9.x 64-bit
-
Debian 8.x 64-bit
SUSE
-
SUSE Linux Enterprise Server 15 64-bit
-
This quick start uses the following ECS instance and CPFS file system configurations:
ECS
Operating system: CentOS 7.9
Region: China (Shanghai)
Zone: Shanghai Zone B
CPFS
Region: China (Shanghai)
Zone: Shanghai Zone B
Type: 100 MB/s/TiB baseline
Configured capacity: 3,600 GiB
Procedure
Step 1: Create a file system
Log on to the CPFS console.
On the Overview page, at the bottom, click Create CPFS File System.
On the CPFS International Site (Pay-as-you-go) page, configure the required parameters as described in the following table. Configure the other parameters based on your business requirements or retain the default settings. For more information, see Create a file system.
Parameter
Description
Region
From the drop-down list, select China (Shanghai).
Zone
Select Shanghai Zone B. Select the same zone as the ECS instance.
Type
Select 100 MB/s/TiB Baseline.
CPFS capacity
Specify the storage capacity of the file system. In this example, select 3,600 GiB.
Virtual private cloud
Select the virtual private cloud (VPC) that you created.
vSwitch
Select a vSwitch that you created in the VPC.
Click Buy Now. Follow the on-screen instructions to complete the purchase.
(Optional) Step 2: Create a Fileset
A Fileset is a lightweight file system within a CPFS file system. It has an independent inode namespace and independent management capabilities, and appears as a directory in the file system hierarchy. We recommend that you create a Fileset to export data and create an NFS mount target. Compared with a regular directory, a Fileset supports additional features such as file count limits and data flows.
In the left-side navigation pane, choose , and click the name of the file system that you created.
On the file system details page, choose Fileset.
On the Fileset tab, click Create Fileset, and configure the following required parameter. Configure the other parameters based on your business requirements or retain the default settings.
Fileset Path: Enter the path of the Fileset in the file system. The path must start and end with a forward slash (/). Example: /fileset1/.
Click OK.
Step 3: Create a protocol service and an export directory
To access a CPFS file system over NFS, create a protocol service. The protocol service generates a mount target that the ECS instance can use to mount the file system.
In the left-side navigation pane, choose Protocol Services tab, click Create Protocol Service, configure the required parameters as described in the following table. Configure the other parameters based on your business requirements or retain the default settings. For more information, see Manage protocol services.
Parameter
Description
Protocol type
Select NFS V3.
vSwitch
Select a vSwitch in the same VPC as the file system.
Protocol export
Click Fileset (Recommended), and select the Step 2 Fileset.
Export VPC
Select the same VPC as the ECS instance.
Export vSwitch
Select the same vSwitch as the ECS instance. The protocol cluster exports the protocol service to the specified VPC through this vSwitch.
NoteA protocol service can consume up to 32 IP addresses on a vSwitch. Make sure that the vSwitch has sufficient available IP addresses.
Click OK.
In the Action column of the protocol service that you created, click Export Directory.
On the Export Directory panel, copy the mount target for later use.
Step 4: Install the CPFS-NFS client and mount the file system
Connect to the ECS instance. For information about connection methods, see Connect to an ECS instance.
Configure the CPFS-NFS client.
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-*.rpmVerify the installation.
which mount.cpfs-nfsA successful installation returns the following output:
/usr/sbin/mount.cpfs-nfs
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 /mntReplace
file-system-id.region.cpfs.aliyuncs.com:/share/pathwith the mount target copied in Step 3, and replace/mntwith a local path on the current server. For more information about mount parameters, see Mount parameters.Run the
mount -lcommand to view the mount information.After the file system is mounted, run the
df -hcommand to view the capacity information of the file system.NoteTo prevent mount information from being lost after the ECS instance restarts, configure the /etc/fstab file on the ECS instance to automatically remount the CPFS file system at startup. For more information, see Configure automatic mounting at startup.
Step 5: Use the file system
After the file system is mounted, you can access and use it as a standard directory on the ECS instance.
The following example uses the local mount path /mnt on the ECS instance to create and delete files in the CPFS file system.
[root@iZ2vxxx ~]# cd /mnt
[root@iZ2vxxx mnt]# ll
total 0
[root@iZ2vxxx mnt]# mkdir dir1
[root@iZ2vxxx mnt]# mkdir dir2
[root@iZ2vxxx mnt]# ll
total 1
drwxr-xr-x 2 root root 4096 Apr 29 10:17 dir1
drwxr-xr-x 2 root root 4096 Apr 29 10:17 dir2
[root@iZ2vxxx mnt]# rm -rf dir*
[root@iZ2vxxx mnt]# ll
total 0