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.
- 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.
- Log on to the ApsaraDB for MongoDB console.
- In the upper-left corner of the page, select the region where the target ApsaraDB for MongoDB subscription instance resides.
- In the left-side navigation pane, click Sharding Instances.
- Find the target instance and click its instance ID.
- In the left-side navigation pane, click Database Connection.
- Click Apply for Shard \ ConfigServer Connection String.
- In the dialog box that appears, apply for a connection string for the shard or Configserver
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.Note
- 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.
Note If you forget your password, you can Reset the password for an ApsaraDB for MongoDB instance.
- 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.
Confirm Password Enter the account password again.
- Click OK.
- Wait until the instance status changes from Establishing Network Connection to Running.
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.
|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.