This topic describes how to upload local data to an NFS file system over the Internet and download data from an NFS file system to a local server.

Prerequisites

Configure an ECS instance

In Solution 1: SFTP and Solution 2: rsync, you must configure an Elastic Compute Service (ECS) instance as an intermediate node to access Apsara File Storage NAS from the Internet. We recommend that you purchase a new ECS instance as an intermediate node to mount a NAS file system. You can also mount the NAS file system on an existing ECS instance.

Note Uploading data to or downloading data from a NAS file system consumes the Internet bandwidth of an ECS instance. We recommend that you purchase a new ECS instance and use it to upload and download data.
  • We recommend that you use a newly purchased ECS instance to mount the NAS file system as an intermediate node. The following figure shows the recommended configurations. For more information about how to mount a NAS file system, see Mount a NAS file system when you purchase an ECS instance.
    Table 1. Basic configurations
    Parameter Description
    Image We recommend that you select CentOS 8.0 64-bit.
    Table 2. Networking
    Parameter Description
    Public IP address Select Assign Public IP Address.
    Bandwidth Billing Select Pay-By-Traffic.
    Peak Bandwidth The peak bandwidth. Maximum value: 100 Mbit/s. We recommend that you set this parameter to 100 Mbit/s.
  • Use an existing ECS instance as the intermediate node to mount the NAS file system. For more information, see Mount an NFS file system.
Note Inbound traffic of an elastic IP address (EIP) does not incur fees, but outbound traffic of an EIP does. Therefore, uploading data to the NAS file system over the Internet does not incur traffic fees, but downloading data from the NAS file system does. For more information about billing details, see Pay-as-you-go.

Solution 1: SFTP

If you need to upload and download a small number of files, we recommend that you install and use an SFTP client in your local server. This solution has the following benefits:
  • Supports multiple operating systems.
  • Provides a graphical user interface (GUI).
  1. Install an SFTP client.
    Download and install SFTP client based on your local operating system. Multiple SFTP versions are available. FileZilla is used in the following example.
  2. Establish a connection between the SFTP client and the ECS instance.
    1. Open and configure FileZilla client. The following table describes the parameters. Click Quickconnect to establish a connection.
      After the local client and the ECS instance are connected, the local file system is displayed on the left pane. The file system that is mounted on the ECS instance is displayed on the right pane. U-D NFS0201
      Parameter Description
      Host The public IP address of the ECS instance, for example, 1.2.3.4.
      Username The username, for example, root.
      Password The password, for example, the logon password of root.
      Port SFTP port number. Default value: 22.
    2. In the Remote site field on the right pane, change the path to the directory where the NAS file system is mounted, for example, /mnt. Press Enter to view the list of files in the NAS file system.
      UD-NFS0202
  3. Upload data.
    Drag and drop one or more files or directories from the left pane to the right pane to upload the data.
  4. Download data.
    Drag and drop one or more files or directories from the right pane to the left pane to download the data.

Solution 2: rsync

If you need to frequently upload and download a large number of files, we recommend that you install the rsync command-line tool on your local server. This solution has the following benefits:
  • After a file is uploaded or downloaded, the metadata of the file remains unchanged, including the owner and permission information.
  • Incremental data synchronization is supported.
  • You can configure crontab for your local Linux or macOS system to automatically back up data to the NAS file system.
  1. Install the rsync tool.
    • Linux
      • If you are using a CentOS or Red Hat operating system, run the following command to install rsync by using the yum package manager:
        sudo yum install rsync
      • If you are using an Ubuntu or Debian operating system, run the following command to install rsync by using the apt package manager:
        sudo apt-get install rsync
    • macOS
      Download and install the homebrew package manager, and then run the following command to install rsync:
      brew install rsync
    • Windows

      Download and install Cygwin simulation environment. You can search for and install rsync during the installation process. You can also download, compile, and install rsync.

  2. Upload data.
    Run the following command to upload a specified local directory to the NAS file system in the incremental synchronization mode:
    rsync -avP DirToSync/ root@1.2.3.4:/mnt/DirToSync/
    Modify the parameters in the command based on the actual values. The following table describes the parameters.
    Parameter Description
    DirToSync The name of the local directory that you want to upload.
    root The owner of the destination directory in the NAS file system.
    1.2.3.4 The public IP address of a Linux ECS instance on which an NFS file system is mounted.
    /mnt A path in the ECS instance. The path is used to mount the NAS file system.
    Note The source path in the rsync command must end with a forward slash (/). Otherwise, the source path does not match the destination path after the data is synchronized.
  3. Download data.
    Run the following command to download data from the NAS file system to a local directory:
    rsync -avP root@1.2.3.4:/mnt/DirToSync/ DirToSync/
  4. Configure automatic upload.
    You can configure crontab for your local Linux or macOS system to upload data at a regular interval by running rsync commands.
    • For Linux operating systems:
      1. Establish a password-free connection between the local server and the ECS instance. For more information, seeConnect to a Linux instance by using an SSH key pair .
        Run the following command to check whether the connection is successful:
        ssh -i ~/.ssh/ecs.pem root@1.2.3.4
        Note ~/.ssh/ecs.pem is the path of the key file on your local server.
      2. Configure crontab.
        Run the crontab -e command to open the editor and configure a scheduled time to upload tasks. The following example shows the sample settings:
        0 23 * * * rsync -av -e "ssh -i ~/.ssh/ecs.pem" ~/Documents/ root@1.2.3.4:/mnt/Documents/
        The preceding crontab configuration allows Linux operating systems to automatically upload data from the local Documents directory to the NAS file system at 23:00 every day. You can modify the parameters in the crontab configuration based on your business requirements.
    • For macOS:
      1. Configure access permissions on the /usr/sbin/cron directory.

        Go to System Preferences. In the window that appears, choose Security & Privacy > Privacy > Full Disk Access, click Unlock, and then click +. In the window that appears, select Macintosh HD Directory, press cmd+ shift+. to show the hidden directories, and then select /usr/sbin/cron.

      2. Establish a password-free connection between the local server and the ECS instance. For more information, see Connect to a Linux instance by using an SSH key pair.
        Run the following command to check whether the connection is successful:
        ssh -i ~/.ssh/ecs.pem root@1.2.3.4
        Note ~/.ssh/ecs.pem is the path of the key file on your local server.
      3. Configure crontab.
        Run the crontab -e command to open the editor and configure a scheduled time to upload tasks. The following example shows the sample settings:
        0 23 * * * rsync -av -e "ssh -i ~/.ssh/ecs.pem" ~/Documents/ root@1.2.3.4:/mnt/Documents/
        The preceding crontab configuration allows Linux operating systems to automatically upload data from the local Documents directory to the NAS file system at 23:00 every day. You can modify the parameters in the crontab configuration based on your business requirements.

Solution 3: Upload data to OSS, and then migrate the data to NAS

If you need to upload a large volume of data to the NAS file system, you can upload the data to OSS and then migrate the data from OSS to NAS. We recommend that you use this solution if the Internet bandwidth of the ECS instance cannot meet your requirements. For more information, see Upload objects and Migrate data from OSS to NAS .
Note
  • The migration service is in the public preview process. If you need to migrate your business data, you can to apply for a whitelist.
  • After you migrate your business data, the metadata may be modified. However, you can run rsync commands to restore the metadata.

Solution 4: Mount the NAS file system to an on-premises database

If your on-premises database frequently reads and writes a large volume of data to and from the NAS file system, you must create a physical connection and mount the NAS file system to the database. For more information, seeAccess an Apsara File Storage NAS file system from a local data center by using VPN Gateway and Access an Apsara File Storage NAS file system from a local IDC by using NAT Gateway.

Access uploaded data

After the data is uploaded, you can mount the NAS file system on the ECS instance or the container to which your business belongs. This allows you to share the data in the NAS file system.

For example, you can mount an NFS file system on a Linux ECS instance and access data on the NAS file system in the same way as you access your local data. For more information, see Mount an NFS file system.

You can also deploy business applications on the cloud. Then, you can read and write a large volume of data to and from the NAS file system by using programs on multiple compute nodes. For example, you can Use NGINX as a proxy for Apsara File Storage NAS.