Help Center> GeminiDB> Getting Started> Getting Started with GaussDB(for Mongo)> Connecting to a Cluster Instance Over Private Networks> Step 3: Connect to a GaussDB(for Mongo) Cluster Instance Over Private Networks

Step 3: Connect to a GaussDB(for Mongo) Cluster Instance Over Private Networks

Scenarios

This section describes how to connect to a GaussDB(for Mongo) cluster instance through an ECS over private networks.

Different OS scenarios: The following uses Linux ECS and Window client as an example.

Constraints

  • The DB instances must be in the same VPC subnet as the ECS.
  • The ECS must be allowed in a security group that has access to the DB instances.
    • If the security group that the target DB instance belongs to is the default security group, you do not need to configure security group rules.
    • If the security group that the target DB instance belongs to is not the default security group, check whether the security group rules allow the ECS to connect to the DB instance. For details, see section Step 2: Configure Security Group Rules.

      If the security group rules allow the access from the ECS, the ECS can connect to the DB instance.

      If the security group rule does not allow the access from the ECS, you need to add an inbound rule to the security group.

  • The default port of the GaussDB(for Mongo) instance is 8635.

Prerequisites

  1. You have created and logged in to an ECS. For details, see Purchasing an ECS and Logging In to an ECS.
  2. You have installed the MongoDB client on the ECS.

    For details on how to install a MongoDB client, see How Can I Install a MongoDB Client?

Procedure

  1. Connect to the ECS.
  2. Connect to the DB instance in the directory where the MongoDB client is located.

    In Linux, for example, run the following command:

    ./mongo --host <DB_HOST> --port <DB_PORT> -u <DB_USER> -p --authenticationDatabase admin

    Enter the password of the database account as prompted:

    Enter password:
    • DB_HOST indicates the IP address of the remotely connected DB instance. Obtain the value from the Private IP Address 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 Basic Information page.
    • DB_USER indicates the database account name. The default value is rwuser.

    Example:

    ./mongo --host 192.168.141.85 --port 8635 -u rwuser -p --authenticationDatabase admin

  3. Check the connection result. If the following information is displayed, the connection is successful.

    mongos>