Buying and Connecting to a GeminiDB Mongo Instance
This section describes how to buy a GeminiDB Mongo instance and uses a Linux ECS as an example to describe how to connect to the instance over a private network.
- Step 1: Buy a GeminiDB Mongo Instance
- Step 2: Buy an Instance
- Step 3: Connect to the GeminiDB Mongo Instance
Step 1: Buy a GeminiDB Mongo Instance
- Log in to the management console.
- In the service list, choose Databases > GeminiDB Mongo API.
- On the Instances page, click Buy DB Instance.
- Click Buy DB Instance, select a billing mode, and configure instance parameters. Then, click Next and complete subsequent operations.
Figure 1 Basic information
Figure 2 Selecting specifications
Figure 3 Setting a password
- View the purchased GeminiDB Mongo instance.
Figure 4 Successful purchase
Step 2: Buy an Instance
- Log in to the management console.
- In the service list, choose > . On the Elastic Cloud Server console, click Buy ECS.
- Configure basic settings and click Next: Configure Network. Make sure that the ECS is in the same region, AZ, VPC, and security group as the GeminiDB Mongo instance you created.
Figure 5 Basic settings
Figure 6 Selecting specifications
Figure 7 Selecting an image
- Configure the ECS network and click Next: Configure Advanced Settings. Make sure that the ECS is in the same VPC and security group as the GeminiDB Mongo instance.
- If security group rules allow access from the ECS, you can connect to the instance using the ECS.
- If the security group rules do not allow access from the ECS, add an inbound rule to the security group.
Figure 8 Network settings
Figure 9 Selecting an EIP
- Configure a password for the ECS and click Next: Confirm.
Figure 10 Advanced settings
- Confirm the configurations and click Submit.
Figure 11 Confirming the configurations
- View the purchased ECS.
Step 3: Connect to the GeminiDB Mongo Instance
- On the ECS console, log in to the ECS using the remote login option.
Figure 12 Remote login
- Enter the username and password of the ECS.
Figure 13 Entering the username and password
- Install the MongoDB client by referring to How Can I Install a MongoDB Client?
- Connect to the instance in the directory where the MongoDB client is located.
- Connect to a replica set using its connection address (recommended).
GeminiDB Mongo provides a connection address for each instance on the console. The address includes IP addresses of the primary, standby and hidden nodes and their port numbers. Connecting to a replica set with this method allows access to the primary, standby, and hidden nodes at the same time, so write errors can be avoided after a primary/standby switchover.
Command format:
./mongo "<Connection address>"
The following is an example command:
./mongo "mongodb://rwuser:****@192.168.0.196:8635,192.168.0.67:8635,192.168.0.32:8635/test?authSource=admin&replicaSet=replica"
Table 1 Required description Parameter
Description
<Connection address>
Connection address of the replica set. You can obtain the connection address in either of the following ways:
In the instance list, locate the replica set and click its name. On the Basic Information page, in the Network Information area, view the connection address beside the Address field.
Alternatively, click the instance name to go to the Basic Information page. In the navigation pane on the left, choose Connections to obtain the address of the instance.
- In the preceding command, ***** needs to be replaced with the password of the instance administrator.
If the password contains at signs (@),exclamation marks (!), or percent signs (%), replace them with hexadecimal URL codes %40, %21, and %25 respectively.
For example, if the password is ****@%***!, enter URL code is ****%40%25***%21.
- replica in replicaSet=replica indicates the name of a replica set. All Huawei Cloud GeminiDB Mongo replica sets are named replica here and cannot be changed.
If information similar to the following is displayed, the connection was successful.replica:PRIMARY>
- In the preceding command, ***** needs to be replaced with the password of the instance administrator.
- Connect to a node of the replica set.
You can also access a specified node of the replica set using the node private IP address.
Command format:
./mongo --host <DB_HOST> --port <DB_PORT> -u <DB_USER> -p --authenticationDatabase admin
Example:
./mongo --host 192.168.1.6 --port 8635 -u rwuser -p --authenticationDatabase admin
Table 2 Required description Parameter
Description
<DB_HOST>
Private IP address of the primary or standby node of the replica set to be connected.
- If the primary node is accessed, you can read and write data from and to the replica set.
- If the standby node is accessed, you can only read data from the replica set.
You can locate the replica set and click its name to switch to the Basic Information page, and then view the private IP address of the required replica set node in the node list.
Alternatively, click the instance name to go to the Basic Information page. In the navigation pane on the left, choose Connections and view the private IP address of the node.
<DB_PORT>
Database port.
<DB_USER>
Username of the instance administrator. The default value is rwuser.
Enter the password of the database account if the following information is displayed:
Enter password:
If information similar to the following is displayed, the connection was successful.
Connection results if the primary node is connected:
replica:PRIMARY>
Connection results if the standby node is connected:
replica:SECONDARY>
- Connect to a replica set using its connection address (recommended).
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot