Help Center > > Best Practices> Connecting to an Instance from an ECS

Connecting to an Instance from an ECS

Updated at: Jan 20, 2022 GMT+08:00

This section uses the Linux OS as an example to describe how to purchase and connect to a cluster instance over a private network.

Step 1: Create an ECS

Step 2: Create a Cluster Instance

Step 3: Connect to a Cluster Instance

Step 1: Create an ECS

  1. Log in to the management console.
  2. Under Compute, select Elastic Cloud Server. On the Elastic Cloud Server page displayed, click Buy ECS.
  3. Configure basic settings and click Next: Configure Network. The region and AZ of the ECS are the same as those of the cluster instance to be connected.
    Figure 1 Basic configurations
    Figure 2 Selecting an image
  4. Configure the ECS network information and click Next: Configure Advanced Settings. The VPC and security group of the ECS are the same as those of the cluster instance to be connected.
    Figure 3 Network settings
  5. Configure the ECS password, and click Next: Confirm.
    Figure 4 Advanced settings
  6. Confirm the configuration information and click Submit.
    Figure 5 Confirming the configurations
  7. View the purchased ECS.
    Figure 6 Purchase succeeded

Step 2: Create a Cluster Instance

  1. Log in to the management console.
  2. Choose Databases > Document Database Service. On the displayed page, click Buy DB Instance.
  3. Configure the instance information and click Submit. The region, AZ, VPC, and security group of the ECS are the same as those of the cluster instance to be connected.
    Figure 7 Basic configurations
    Figure 8 Administrator settings
    Figure 9 Network settings and validity period
    Figure 10 Advanced settings
  4. View the purchased DDS instance.
    Figure 11 Purchase succeeded

Step 3: Connect to a Cluster Instance

  1. Use the Linux remote connection tool to log in to the ECS. Remote host is the EIP bound to the ECS.
    Figure 12 Creating a session
  2. Enter the password of the ECS.
    Figure 13 Entering the password
    Figure 14 Successful login
  3. Download the mongodb-linux-x86_64-rhel70-4.0.27.tgz client installation package.
    Figure 15 Downloading the client
  4. Upload the client installation package to the ECS.
    Figure 16 Uploading the client
    Figure 17 Client uploaded
  5. Decompress the installation package on the ECS.

    tar zxvf mongodb-linux-x86_64-rhel70-4.0.27.tgz

  6. Obtain the installation package under the bin directory.

    cd mongodb-linux-x86_64-rhel70-4.0.27/bin

    The common tools are as follows:

    • MongoDB client mongo
    • Data export tool mongoexport
    • Data import tool mongoimport
  7. Before using a client tool, assign the execute permission to it.
    • Run the chmod +x mongo command to grant a client permission to connect to an instance.
    • Run the chmod +x mongoexport command to grant a client permission to export data.
    • Run the chmod +x mongoimport command to grant a client permission to import data.
  8. Connect to the DDS instance.

    ./mongo mongodb://rwuser:<password>@<DB_HOST1>:<DB_PORT1>,<DB_HOST2>:<DB_PORT2>/test?authSource=admin

    Figure 18 Connection succeeded
  9. Create a database and a collection.
    Figure 19 Creating a database
    Figure 20 Creating a collection

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel