All Products
Search
Document Center

File Storage NAS:Mount an NFS file system on multiple ECS instances at a time

Last Updated:Dec 18, 2024

If you want to share the data of a File Storage NAS (NAS) file system among multiple Elastic Compute Service (ECS) instances, you can use Cloud Assistant to mount the NAS file system on the ECS instances at a time. Only the Network File System (NFS) protocol is supported.

Prerequisites

A file system is created. For more information, see Create a file system.

Network

You can use the ECS console to mount your file system on multiple ECS instances if your business network meets the requirements in the following scenarios:

  • The ECS instances and the mount target of the NAS file system reside in the same virtual private cloud (VPC).

  • The ECS instances and the mount target of the NAS file system reside in the classic network. The private IP addresses of the ECS instances are authorized in the permission group that is attached to the mount target. For more information, see Manage permission groups.

  • The ECS instances and the mount target of the NAS file system reside in different VPCs, and the ECS instances can access and be accessed by the file system across VPCs. The private IP addresses of the ECS instances are authorized in the permission group that is attached to the mount target. For more information, see Use CEN to mount a NAS file system across VPCs in the same region.

Limits

  • Operating system

    You can mount the file system only on a Linux ECS instance. Linux distributions such as CoreOS, FreeBSD, and Fedora CoreOS do not support the mount feature of the NAS console. If your ECS instance runs Red Hat Enterprise Linux (RHEL), you must install the Cloud Assistant client by using the RPM Package Manager (RPM) package before you mount your file system. For more information, see Install Cloud Assistant Agent on a Linux instance.

  • Status of Cloud Assistant and ECS instances

    • You can mount your file system only on ECS instances that are in the Running state. If the ECS instances are in the Starting or Stopped state, change the status of each ECS instance to Running.

    • Cloud Assistant must run as expected.

  • ECS instances

    The ECS instances and the NAS file system must reside in the same region. You cannot use Cloud Assistant to mount a file system on an ECS instance that resides in a different region.

  • File systems

    This topic applies only to NFS file systems.

Procedure

  1. Log on to the ECS console.

  2. In the left-side navigation pane, choose Maintenance & Monitoring > Cloud Assistant.

  3. In the top navigation bar, select the region and resource group to which the resource belongs. 地域

  4. On the Common Commands tab, enter ACS-NAS-ClickMount-Mount-Linux-NFS.sh in the search box to search for the mount command, and then click Run.

  5. In the Run Command panel, configure the parameters in the Command Information section and select the ECS instances on which you want to mount the file system. The following table describes the parameters.

    Parameter

    Description

    Command Information

    Command content

    Click View command content to view the command.

    Execution Plan

    Select the execution plan based on which to run the command. If you do not have special requirements, we recommend that you select Immediate execution.

    • Immediate execution: The command is immediately run after you click Run.

    • After the next startup of the system: The command is run the next time the selected instances are started after you click Run.

    • After each system startup: The command is run each time the selected instances are started after you click Run.

    Username

    Specify the username that is used to run the command on ECS instances. You must run the command as the root user or the system user.

    By default, Cloud Assistant commands are run by the root user on Linux instances and by the system user on Windows instances.

    Command Parameters

    In the Command Parameters field, enter values for the custom parameters that are specified in the command.

    • MountTargetDomain: the domain name of the mount target of the NAS file system.

      You can query the domain name of the mount target on the details page of the NAS file system in the NAS console. For example, the domain name is ****.nas.aliyuncs.com. For more information, see View the domain name of a mount target.

    • EcsLocalPath: the local directory of the ECS instances on which you want to mount the NAS file system.

      The value must be an empty absolute path that starts with /. Example: /mnt.

    • NasRemotePath: the name of the shared directory in the NAS file system.

      You can enter the root directory of the NAS file system such as / or a subdirectory such as /abc.

    • ProtocolType: the protocol type of the NAS file system.

      • General-purpose NAS file systems support NFSv3 and NFSv4.0.

      • Extreme NAS file systems support NFSv3.

      Important

      We recommend that you specify a valid value for this parameter. This parameter is case-sensitive. Make sure that the value of this parameter is not preceded or followed by spaces. If the value of this parameter is invalid, the command fails.

    • AutoMountOnBoot: specifies whether to enable automatic mounting of the NAS file system when the ECS instances start.

      Valid values: true and false. After you enable automatic mounting at startup, you do not need to re-mount the file system when you restart the ECS instances.

      Important

      We recommend that you specify a valid value for this parameter. The value can contain only lowercase letters. Make sure that the value of this parameter is not preceded or followed by spaces. If the value of the parameter is invalid, the command fails.

    • MountParam: the mount parameters.

      By default, this parameter is not specified. You can configure this parameter based on your business scenario. For more information, see the mount parameters described in Mount an NFS file system on a Linux ECS instance.

    Select Instance

    Select Instance

    Select one or more ECS instances on which you want to mount the NAS file system.

    If you have multiple instances, you can search for instances by ID, name, or tag, and filter results by client status.

  6. Click Run.

Query the output of a command

After you mount, unmount, or query a NAS file system, you can use Cloud Assistant to query the results.

  1. Log on to the ECS console.

  2. In the left-side navigation pane, choose Maintenance & Monitoring > Cloud Assistant.

  3. In the top navigation bar, select the region and resource group to which the resource belongs. 地域

  4. On the Command Execution Result tab, select Command Name from the drop-down list, enter the name of the command whose output you want to query, and then click the 查询图标 icon.

    • Mount command: ACS-NAS-ClickMount-Mount-Linux-NFS.sh

    • Unmount command: ACS-NAS-ClickMount-Unmount-Linux-NFS.sh

    • Query command: ACS-NAS-ClickMount-Check-Linux-NFS.sh

  5. In the Command Execution Result list, find the command name and click View in the Actions column.

  6. In the Execution Details panel, click the 批量图标001 icon before the instance name to view the command output.

    If an error is returned, identify the cause of the error and fix the error based on the cause. Then, run the command again. For more information, see the Error messages section in this topic.

  7. After the query is complete, click Close.

Error messages

The following table describes the error messages that may be returned in the output of a command.

ErrorCode

ErrorMsg

SystemNoPermission

You do not have the permissions to run the command in the operating system. You must have the root permissions.

SystemMissingMounts

The /proc/self/mounts file does not exist in the operating system.

SystemMissingFstab

The /etc/fstab configuration file for automatic mounting does not exist in the operating system.

SystemBashOutdated

The bash version of the operating system is outdated. Upgrade the version to 4.0 or later.

BadInputMountTarget

The specified value of the mounttargetdomain parameter is invalid. Set the parameter to a value that ends with .nas.aliyuncs.com.

BadInputLocalPath

The specified value of the ecslocalpath parameter is invalid. Set the parameter to a Linux absolute path that starts with /.

BadInputRemotePath

The specified value of the nasremotepath parameter is invalid. Set the parameter to an absolute path that starts with /.

BadInputProtocol

The specified value of the protocoltype parameter is invalid. Enter NFSv3 or NFSv4.0 instead.

BadInputAutoMount

The specified value of the automountonboot parameter is invalid. Set the parameter to true or false.

BadInputForceUnmount

The specified value of the ForceUnmount parameter is invalid. Set the parameter to true or false.

NasClientNfsInstallFail

The NFS client fails to be installed. Install the NFS client again.

LocalPathCreateFail

The local directory fails to be automatically created on the ECS instance. Manually create the directory.

LocalPathAlreadyMounted

The local directory is already mounted on another mount target of the NAS file system. Select a valid local directory.

LocalPathNonEmpty

The mount directory is not empty. Select an empty directory.

LocalPathNotOnMountTarget

The NAS file system is not mounted on the local directory by using the mount target. Mount the NAS file system by using a valid mount target.

LocalPathMultipleMounts

The NAS file system is mounted on the local directory multiple times. Check and forcibly unmount the NAS file system.

LocalPathAncestorMounted

The NAS file system is already mounted on the parent directory of the local directory. Select a valid directory.

LocalPathNonExistent

The local directory does not exist. Select a valid directory.

RemotePathCreateFail

The subdirectory fails to be created for the NAS file system. Select the root directory to mount the NAS file system.

MountFailRemoteRoot

The root directory of the NAS file system fails to be mounted. For more information about how to troubleshoot mount failures, see FAQ about troubleshooting of mount failures.

MountFailRemotePath

The subdirectory of the NAS file system fails to be mounted. Select the root directory to mount the NAS file system.

UnmountFailRemoteRoot

The root directory of the NAS file system fails to be unmounted before you mount the subdirectory. Select the root directory to mount the NAS file system.

UnmountFailLocalPath

The NAS file system fails to be unmounted. Stop the related applications and then forcibly unmount the NAS file system.

UnmountFailRemoveAutoMount

The automatic mounting of the NAS file system fails to be disabled.

Related operations

If you want to query multiple ECS instances or unmount a file system from multiple ECS instances at a time, you can use Cloud Assistant to run commands.

Operation

Command

Description

Unmount a file system from multiple ECS instances

ACS-NAS-ClickMount-Unmount-Linux-NFS.sh

Run commands by using Cloud Assistant and replace the command in Step 5 with the unmount command. This way, you can create a task to unmount a file system from multiple ECS instances at a time.

To run the unmount command, you must configure the following parameters:

  • MountTargetDomain: the domain name of the mount target of the NAS file system.

    You can query the domain name of the mount target on the details page of the NAS file system in the NAS console. For example, the domain name is ****.nas.aliyuncs.com. For more information, see View the domain name of a mount target.

  • EcsLocalPath: the local directory of the ECS instances on which the NAS file system is mounted.

    To view the local directory, perform the following steps: Log on to the NAS console. Go to the Mount Targets page of the file system. Click Mount in the Actions column of the mount target. Then, click Query Mount Details in the Actions column of the ECS instance.

  • CancelAutoMountOnBoot: specifies whether to disable automatic mounting of the NAS file system when the ECS instances start. Valid values: true and false.

    If you set this parameter to true, the /etc/fstab file in the ECS instances is modified.

  • ForceUnmount: specifies whether to forcibly unmount the NAS file system. Valid values: true and false.

    If you set this parameter to true, the umount -lf <mount directory> command is run. Data may be lost from the disk and related applications may unexpectedly exit. We recommend that you run the fuser -mv <mount directory> command on the ECS instances to view the applications that are reading data from or writing data to the NAS file system. If no application is running and you still cannot unmount the NAS file system, you can use the forced unmount feature. For information about the risks of forced unmount, see What happens if I forcibly unmount a NAS file system?

Query multiple ECS instances at a time

ACS-NAS-ClickMount-Check-Linux-NFS.sh

Run commands by using Cloud Assistant and replace the command in Step 5 with the query command. This way, you can create a task to query multiple ECS instances at a time.

To run a query command, you must configure the following parameter:

MountTargetDomain: the domain name of the mount target. If you do not configure this parameter, the details about all NAS file systems that are mounted on the ECS instance are returned.

FAQ