When a container is destroyed, its internal data is lost. Mount a NAS file system to an SAE application instance to persist application data and share it between instances. NAS is suitable for high-performance computing and data sharing scenarios.
Prerequisites
Procedure
Configure NAS storage when you create an application
-
On the SAE Application List page, select the target region and namespace at the top, and then click Create Application.
-
On the Basic Information page, configure the application details, and click Next: Advanced Settings.
-
Expand the Persistent Storage section and configure the parameters.
-
Turn on the Enable NAS switch.
-
In the NAS File System row, select the file system to mount, and then set Mount Source, Mount Directory, Container Path, and Permission.
Note-
The Mount Directory can only be the root directory / or a subdirectory that does not start with /.
-
Container Path cannot be duplicated or nested, such as /tmp and /tmp/nas.
-
Click + Add to add another mount path. You can add a maximum of 10 mount paths.
-
-
-
Click Create Application.
Configure NAS storage when you deploy an application
After you redeploy an application, the application is restarted. To prevent unpredictable errors such as business interruptions, we recommend that you deploy applications during off-peak hours.
The procedure that can be performed to update an application varies based on the number of instances in the application. This section provides an example on how to configure the required features for an application in which the number of instances is greater than or equal to 1. For information about how to update an application in which the number of instances is 0, see Update an application.
-
On the SAE Application List page, select the target region and namespace at the top, and then click the target Application ID to open the application details page.
-
On the Basic Information page of the target application, click Deploy Application.
-
Expand the Persistent Storage section and configure the parameters.
-
Turn on the Enable NAS switch.
-
In the NAS File System row, select the file system to mount, and then set Mount Source, Mount Directory, Container Path, and Permission.
Note-
The Mount Directory can only be the root directory / or a subdirectory that does not start with /.
-
Container Path cannot be duplicated or nested, such as /tmp and /tmp/nas.
-
Click + Add to add another mount path. You can add a maximum of 10 mount paths.
-
-
-
After you complete the configuration, click OK.
Unmount a NAS file system
After you redeploy an application, the application is restarted. To prevent unpredictable errors such as business interruptions, we recommend that you deploy applications during off-peak hours.
If you no longer use NAS storage, you can unmount the NAS file system. Unmounting a file system in the SAE console does not delete the data stored in it. For detailed instructions, see Configure NAS storage when you deploy an application. In Step 4, turn off the Enable NAS file storage switch and click OK.
Verify the result
Use one of the following methods to verify that the NAS file system is mounted:
-
Check the deployment details.
If the application creation or deployment is successful and the new instances start without any errors, the mount is successful.
-
Verify from within the container.
Connect to the container's webshell and run the following command to check the NAS mount information:
cat /proc/mounts | grep nfsIf output similar to the following is returned, the mount is successful.
sh-4.2# cat /proc/mounts | grep nfs 192.168.xxx.xxx:/ /xxx nfs rw,relatime,vers=3,rsize=1048576,wsize=1048576,namlen=255,hard,nolock,noresvport,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=192.168.xxx.xxx,mountvers=3,mountproto=tcp,local_lock=all,addr=192.168.xxx.xxx sh-4.2# -
Verify with a file operation.
In the webshell, perform an operation on the mounted NAS path, such as creating a file. If you can find the file in the NAS file system, the mount is successful.
FAQ
How to view NAS content?
You cannot view NAS file system content directly from the console. Mount the file system to an SAE application or an ECS server instead. For more information, see the following topics:
Can I use NAS to store logs?
We do not recommend using NAS for log persistence. Multiple clients writing to the same file simultaneously can cause concurrent access conflicts and performance bottlenecks.
For logging, we recommend using Simple Log Service (SLS) to ensure data persistence. For more information, see Configure log collection to SLS.