If you want to share the data of an Apsara File Storage 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 the same time.

Scenario

You can use the NAS console to mount your file system on multiple ECS instances in the following scenarios:

  • The ECS instance and the mount target of the NAS file system reside in the same virtual private cloud (VPC).
  • The ECS instance and the mount target of the NAS file system reside in the classic network. The private IP address of the ECS instance is authorized in the permission group that is attached to the mount target. For more information, see Manage a permission group.
  • The ECS instance and the mount target of the NAS file system reside in different VPCs, and the ECS instance can access and be accessed by the file system across VPCs. The private IP address of the ECS instance is authorized in the permission group that is attached to the mount target. For more information, see Create a CEN instance and Attach a VPC to the CEN instance.

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 the client on Linux instances by using the RPM package.

  • 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 state or the Stopped state, change the status of each ECS instance to Running.
    • Cloud Assistant must run as expected.
  • ECS instance

    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.

Procedure

  1. Log on to the ECS console.
  2. In the left-side navigation pane, choose Maintenance & Monitoring > ECS Cloud Assistant.
  3. In the top navigation bar, select a region.
  4. On the Commands tab, select Common Commands and enter ACS-NAS-ClickMount-Mount-Linux-NFS.sh in the search box to search for the name of the mount command. After the command name appears, click Create Task in the Actions column.
  5. In the Create Task panel, configure the parameters in the Command Information section and select the ECS instance to which you want to mount the file system. The following table describes the parameters.
    Section Parameter Description
    Command Information Command Click View to view the command.
    Implementation Plan Select a point in time at which you want 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 The username that is used to run the command on the ECS instance. 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.

      On the details page of the NAS file system in the NAS console, you can query the domain name of the mount target. For example, the domain name is ****.nas.aliyuncs.com.

    • ecslocalpath: the mount directory that resides on the current ECS instance.

      The value must be an absolute path that starts with /.

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

      You can enter the root directory such as / or a subdirectory such as /abc.

    • protocoltype: Select the protocol type of the file system.
      General-purpose NAS file systems support NFSv3 and NFSv4.0. Extreme NAS file systems support NFSv3.
      Notice 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 instance starts.
      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 instance.
      Notice We recommend that you specify a valid value for this parameter. The value must consist of 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: mount parameters.

      By default, you do not need configure this parameter. You can configure this parameter based on your business scenario. For more information, see Parameter description.

    Select Instances Select one or more ECS instances on which you want to mount a 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 Create Task.

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 > ECS Cloud Assistant.
  3. In the top navigation bar, select a region.
  4. On the Command Execution Result tab, enter the name of the command whose output you want to query and click the Query icon 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 Show icon icon to the right of 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 Error messages.
  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 The error message returned because you do not have the permissions to run the command in the operating system. You must use the root permissions.
SystemMissingMounts The error message returned because the /proc/self/mounts file does not exist in the operating system.
SystemMissingFstab The error message returned because the /etc/fstab configuration file for automatic mounting does not exist in the operating system.
SystemBashOutdated The error message returned because the bash version of the operating system is outdated. Upgrade the version to 4.0 or later.
BadInputMountTarget The error message returned because the specified value of the mounttargetdomain parameter is invalid. Set the parameter to a value that ends with .nas.aliyuncs.com.
BadInputLocalPath The error message returned because the specified value of the ecslocalpath parameter is invalid. Set the parameter to a Linux absolute path that starts with a /.
BadInputRemotePath The error message returned because the specified value of the nasremotepath parameter is invalid. Set the parameter to an absolute path that starts with /.
BadInputProtocol The error message returned because the specified value of the protocoltype parameter is invalid. Enter NFSv3 or NFSv4.0 instead.
BadInputAutoMount The error message returned because the specified value of the automountonboot parameter is invalid. Set the parameter to true or false.
BadInputForceUnmount The error message returned because the specified value of the ForceUnmount parameter is invalid. Set the parameter to true or false.
NasClientNfsInstallFail The error message returned because the NFS client fails to be installed. Install the NFS client again.
LocalPathCreateFail The error message returned because the local directory fails to be created on the ECS instance. Create the directory.
LocalPathAlreadyMounted The error message returned because the local directory is already mounted on another mount target of the NAS file system. Select a valid local directory.
LocalPathNonEmpty The error message returned because the mount directory is not empty. Select an empty directory.
LocalPathNotOnMountTarget The error message returned because 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 error message returned because the NAS file system is mounted on the local directory multiple times. Check and forcibly unmount the NAS file system.
LocalPathAncestorMounted The error message returned because a NAS file system is already mounted on the parent directory of the local directory. Select a valid directory.
LocalPathNonExistent The error message returned because the local directory does not exist. Select a valid directory.
RemotePathCreateFail The error message returned because the subdirectory fails to be created for the NAS file system. Select the root directory to mount the NAS file system.
MountFailRemoteRoot The error message returned because the root directory of the NAS file system fails to be mounted. For more information about how to fix issues, see Fix mount issues.
MountFailRemotePath The error message returned because the subdirectory of the NAS file system fails to be mounted. Select the root directory to mount the NAS file system.
UnmountFailRemoteRoot The error message returned because 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 error message returned because the NAS file system fails to be unmounted. Stop the related applications and then forcibly unmount the NAS file system.
UnmountFailRemoveAutoMount The error message returned because automatic mounting of the NAS file system fails to be disabled.

What to do next

If you want to query multiple ECS instances or unmount a file system from multiple ECS instances at the same 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:
  • CancelAutoMountOnBoot: specifies whether to disable the automatic mounting feature. Valid values: true and false.

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

  • ForceUnmount: specifies whether to forcibly unmount the 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 instance 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 mount the NAS file system, you can use the forced unmount feature.

Query multiple ECS instances at the same 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 the same time.

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

  • 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 to the query result.