A sharded cluster instance consists of Mongos, shard, and Configserver nodes. Typically, you only need to connect to the Mongos node to read and write data. In some special scenarios such as data synchronization between clusters, you need to read the oplog of a shard node or the configuration information of a Configserver node. You can apply for a connection string of the corresponding node to meet your business needs.


Sharded cluster instances must be used.


  • After you apply for a connection string, two connection strings are allocated to each node, one for the primary node and one for the secondary node.
  • The network type of the connection strings must be the same as that of the current Mongos node.
  • You cannot modify the connection string of a shard or Configserver node.
  • The connection strings allocated here can only be used to access the node over the internal network. If you want to access the node over the Internet, you can Apply for a public endpoint for a sharded cluster instance.

Introduction to the sharded cluster architecture and nodes

For more information, see Architecture of sharded cluster instances.


  1. Log on to the ApsaraDB for MongoDB console.
  2. In the upper-left corner of the page, select the resource group and the region of the target instance.
  3. In the left-side navigation pane, click Sharded Cluster Instances.
  4. Find the target instance and click its ID.
  5. In the left-side navigation pane, click Database Connection.
  6. Click More > Apply for Shard or ConfigServer Connection String .
  7. In the dialog box that appears, apply for a connection string for the shard or Configserver node.
    Apply for a connection string
    Parameter Description
    Node Type
    • shard: the shard node.
    • cs: the Configserver node.
    Select Node ID Select a check box corresponding to the ID of the node for which you want to create a connection string.
    Account The account name must be 4 to 16 characters in length and can contain lowercase letters, digits, and underscores (_). It must start with a lowercase letter.
    • You must set the account and password only when applying for the connection string of a shard or Configserver node for the first time. The account and password are required for all shard and Configserver nodes.
    • The permissions of this account are fixed to read-only.
    • The password must contain at least three types of the following characters: uppercase letters, lowercase letters, digits, and special characters. Special characters include ! # $ % ^ & * ( ) _ + - =
    • The password must be 8 to 32 characters in length.
    Note If you forget your password, you can Reset the password for an ApsaraDB for MongoDB instance.
    Confirm Password Enter the account password again.
  8. Click Submit.
  9. Wait until the instance status changes from Establishing Network Connection to Running.

Node types

After applying for the connection string of a shard or Configserver node, you can view the connection string on the Database Connection page. The following table describes node types.

Node type Description
db The shard node.
cs The Configserver node.
mongos The Mongos node.


If the connection string of a shard or Configserver node is no longer needed, you can Release the connection string of a shard or Configserver node.