dds
Connecting to an Instance from an ECS
Updated at: Jan 24, 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 2: Create a Cluster Instance
Step 3: Connect to a Cluster Instance
Step 1: Create an ECS
- Log in to the management console.
- Under Compute, select Elastic Cloud Server. On the Elastic Cloud Server page displayed, click Buy ECS.
- 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 configurationsFigure 2 Selecting an image
- 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
- Configure the ECS password, and click Next: Confirm.Figure 4 Advanced settings
- Confirm the configuration information and click Submit.Figure 5 Confirming the configurations
- View the purchased ECS.Figure 6 Purchase succeeded
Step 2: Create a Cluster Instance
- Log in to the management console.
- Choose Databases > Document Database Service. On the displayed page, click Buy DB Instance.
- 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 configurationsFigure 8 Administrator settingsFigure 9 Network settings and validity periodFigure 10 Advanced settings
- View the purchased DDS instance.Figure 11 Purchase succeeded
Step 3: Connect to a Cluster Instance
- 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
- Enter the password of the ECS.Figure 13 Entering the passwordFigure 14 Successful login
- Download the mongodb-linux-x86_64-rhel70-4.0.27.tgz client installation package.Figure 15 Downloading the client
- Upload the client installation package to the ECS.Figure 16 Uploading the clientFigure 17 Client uploaded
- Decompress the installation package on the ECS.
- 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
- 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.
- Connect to the DDS instance.
./mongo mongodb://rwuser:<password>@<DB_HOST1>:<DB_PORT1>,<DB_HOST2>:<DB_PORT2>/test?authSource=admin
Figure 18 Connection succeeded - Create a database and a collection.Figure 19 Creating a databaseFigure 20 Creating a collection
