Connecting to a DB Instance Through an ECS
This section uses a DDS cluster instance and a Linux ECS as an example to describe how to connect to a DDS DB instance by logging in to an ECS with an EIP assigned using SSH. The procedures are as follows:
Step 1: Create an ECS
- Log in to the management console.
- Choose Computing > Elastic Cloud Server. On the ECS console, check whether there is an ECS meeting the following requirements:
- The region, VPC subnet, and security group of the ECS are the same as those of the DDS DB instance to be connected.
Figure 1 DB instance basic information
- The ECS has had an EIP bound and the EIP meets the bandwidth requirements.
- If an ECS that meets the preceding conditions is available, go to Step 2: Log in to the ECS.
- If you need to create an ECS, go to the next step.
- The region, VPC subnet, and security group of the ECS are the same as those of the DDS DB instance to be connected.
- On the page for buying ECSs, select the region, AZ, VPC subnet, and security group that are the same as those of the DDS DB instance to be connected.
Figure 2 Buying an ECS
Figure 3 Network
- If you select Automatically assign, the system automatically assigns an EIP for the ECS. The EIP provides dedicated bandwidth that is configurable.
For more details, see Methods of Purchasing ECSs.
Step 2: Log in to the ECS
Obtain the EIP bound to the ECS, and use the client tool to log in to the ECS in SSH mode.
For more details, see Login Overview.
Step 3: Connect to a DDS DB Instance
- Create a file on the ECS to install mongo shell. The following uses the file /ycsb as an example.
mkdir /ycsb
- Open the /ycsb file and create the mongo directory.
cd /ycsb
mkdir mongo
cd /ycsb/mongo
- Download mongo shell.
curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.4.17.tgz
- Decompress the mongo shell package.
- Move the decompressed file to an existing directory, for example, /usr/local/mongodb.
mv mongodb-linux-x86_64-3.4.17/* /usr/local/mongodb
- Set environment variables.
Add the following two lines to the end of the file and save the file:
export MONGODB_HOME=/usr/local/mongodb export PATH=$PATH:$MONGODB_HOME/bin
Figure 5 Setting environment variables
- Make the configurations take effect.
- Connect to the cluster instance using mong shell.
mongo 192.168.0.90:8635 --authenticationDatabase admin -u rwuser -p xxxxx
- The proceeding command is used to disable the SSL connection for a cluster instance and connect to a single mongos node.
- 192.168.0.90 indicates the private IP address. Obtain the value from the Private IP Address column in the Node Information area on the Basic Information page of the DB instance.
- 8635 indicates the port number. Obtain the value from the Database Port field in the Network Information area on the Basic Information page.
- rwuser indicates the administrator account.
- xxxxx indicates the password of the administrator.
Figure 6 Connection information
- If the DDS DB instance is successfully connected, the following information is displayed:
[root@ecs-dds-mongos~]# mongo 192.168.0.90:8635 --authenticationDatabase admin -u rwuser -p xxxxx MongoDB shell version: 3.4.17 connecting to: 192.168.0.90:8635/test mongos>
Last Article: Connecting to a DB Instance Through an EIP
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.