Step 4: Connect to a GaussDB(for Mongo) Cluster Instance Over Public Networks
Scenarios
This section describes how to connect to a GaussDB(for Mongo) cluster instance using the MongoDB client and Robo 3T over public networks.
Different OS scenarios: The following uses Linux ECS and Window client as an example.
Prerequisites
- Bind an EIP to the GaussDB(for Mongo) cluster instance and set security group rules to ensure that the EIP can be accessed through the ECS or Robo 3T. For details, see Step 2: Bind an EIP and Step 3: Configure Security Group Rules.
- Install the MongoDB client or Robo 3T.
- You have created and logged in to an ECS. For details, see Purchasing an ECS and Logging In to an ECS.
- Install the MongoDB client on the ECS.
For details on how to install a MongoDB client, see How Can I Install a MongoDB Client?
If you use a connection address to connect to a cluster instance, download the MongoDB client of version later than 4.0.
Robo 3T
Install Robo 3T. For details, see How Can I Install Robo 3T?
Using Robo 3T to Connect to a DB Instance
- Run the installed Robo 3T. On the displayed dialog box, click Create. Figure 1 Connections
- In the Connection Settings dialog box, set the parameters of the new connection.
- On the Connection tab, enter the name of the new connection in the Name text box and enter the EIP and database port that are bound to the GaussDB(for Mongo) cluster instance in the Address text box. Figure 2 Connection
- On the Authentication tab, set Database to admin, User Name to rwuser, and Password to the administrator password you set during the creation of the cluster instance. Figure 3 Authentication
- Click Save.
- On the Connection tab, enter the name of the new connection in the Name text box and enter the EIP and database port that are bound to the GaussDB(for Mongo) cluster instance in the Address text box.
- On the MongoDB Connections page, click Connect to connect to the GaussDB(for Mongo) cluster instance. Figure 4 Connections
- If the GaussDB(for Mongo) cluster instance is successfully connected, the page shown in Figure 5 is displayed.
Using MongoDB Client to Connect to the DB Instance
- Connect to the ECS.
- Connect to the DB instance in the directory where the MongoDB client is located.
- Method 1: Using Linux commands
./mongo --host <DB_HOST> --port <DB_PORT> -u <DB_USER> -p --authenticationDatabase admin
Enter the password of the database account as prompted:
Enter password:
Example:
./mongo --host 10.154.217.191 --port 8635 -u rwuser -p --authenticationDatabase admin
- Method 2: Connecting to the instance through a public network on the management console
./mongo 'mongodb://rwuser:****@<DB_HOST>:<DB_PORT>/test?authSource=admin'
- DB_HOST indicates the IP address of the remotely connected DB instance. Obtain the value from the EIP column in the node list on the Basic Information page.
- DB_PORT indicates the port number. Obtain the value from Database Port in the Basic Information area on the Connections page.
- DB_USER indicates the database account name. The default value is rwuser.
- **** indicates the password of the database account.
- If the password contains the percent sign (%), change % to %25.
- If the password contains the at sign (@), change @ to %40.
Example:
./mongo 'mongodb://rwuser:****@10.154.217.191/test?authSource=admin'
Single quotation marks are used in the preceding commands to avoid login failures caused by special characters.
- Method 1: Using Linux commands
- Check the connection result. If the following information is displayed, the connection is successful.
mongos>
Last Article: Step 3: Configure Security Group Rules
Next Article: Connecting to a Replica Set Instance Over Public Networks

Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.