By default, applications connect to an ApsaraDB for MongoDB sharded cluster instance through a Mongos node. This is sufficient for standard read and write operations. For advanced tasks, such as reading a Shard's oplog, you must apply for a dedicated endpoint for the Shard.
Prerequisites
-
The instance is a sharded cluster instance.
-
The instance uses the MongoDB protocol.
Background information
An ApsaraDB for MongoDB sharded cluster instance consists of three components: Mongos, Shard, and ConfigServer. You can customize the number and specifications of Shard components to match your performance requirements. For more information, see Sharded cluster architecture.
Usage notes
-
When you apply for a Shard endpoint, the system creates endpoints for the primary node, secondary node, and read-only node within the Shard. Each endpoint consumes one IP address. Make sure you have enough available IP addresses.
-
The Shard endpoint uses the same network type as the instance's Mongos nodes.
-
A Shard endpoint cannot be modified after it is created.
-
The endpoint described in this topic is a private endpoint. To access the instance over the Internet, first apply for a private endpoint and configure an account as described in this topic, then apply for a public endpoint. For instructions, see Apply for a public endpoint.
-
For an instance with local disks, you can create a Shard account while applying for the Shard endpoint. For an instance with cloud disks, you must first create a Shard account on the Account Management page before you apply for the Shard endpoint.
-
Shard endpoints are available only for ApsaraDB for MongoDB sharded cluster instances.
Procedure
Cloud disk instance
Applying for a Shard endpoint on a cloud disk instance may cause a transient disconnection for existing sessions. Make sure your application has a reconnection mechanism. We recommend that you perform this operation during off-peak hours.
-
Go to the ApsaraDB for MongoDB sharded cluster instances list. At the top of the page, select a resource group and a region, and then click the ID of the target instance.
-
Create a Shard account.
NoteYou only need to create a Shard account when you apply for a Shard endpoint for the first time. This step is not required for subsequent applications.
-
In the left-side navigation pane of the instance details page, click Accounts.
-
Click Create Account.
-
In the Create Account (Shard Only) panel, enter the account name and password.
NoteThe Shard account has fixed read-only permissions.
Parameter
Description
Account Name
The account name must meet the following requirements:
-
Start with a lowercase letter.
-
Contain only lowercase letters, digits, and underscores (_).
-
Be 4 to 16 characters in length.
Note-
Reserved keywords cannot be used as the account name in ApsaraDB for MongoDB.
-
The account has fixed read-only permissions.
Account Password
The password must meet the following requirements:
-
Contain characters from at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters.
The supported special characters are
!@#$%^&*()_+-=. -
Be 8 to 32 characters in length.
NoteApsaraDB for MongoDB allows you to reset passwords for ConfigServer and Shard node accounts. For more information, see Reset a password.
Confirm Password
Enter the password again to confirm.
-
-
Click Confirm.
-
-
Create the Shard endpoint.
-
In the left-side navigation pane, click Database Connections.
-
In the Private Endpoint - VPC section, click Apply for Shard Endpoint.
-
In the Apply for Shard Endpoint panel, set the following parameters.
Parameter
Description
Node Type
This parameter is fixed to Shard.
Select Node ID
Select the ID of the node that requires an endpoint.
-
Click OK.
-
-
On the Database Connections page, view the new endpoint.
-
Wait for the instance status to change from Establishing Network Connection to Running.
-
In the Private Endpoint - VPC section, view the endpoint for the node.
-
Local disk instance
Alternatively, go to the Basic Information page of the instance, find the Shard List section, and click Add Shard. Select the option to enable a direct Shard connection and then apply for the Shard endpoint in the Apply for Shard Private Endpoint section.
-
Go to the ApsaraDB for MongoDB sharded cluster instances list. At the top of the page, select a resource group and a region, and then click the ID of the target instance.
-
In the left-side navigation pane, click Database Connections.
-
In the Private Endpoint - VPC section, click Apply for Shard Endpoint.
-
In the Apply for Shard Endpoint panel, set the following parameters.
Parameter
Description
Node Type
This parameter is fixed to Shard.
Select Node ID
Select the ID of the node that requires an endpoint.
Account Name
The account name must meet the following requirements:
-
Start with a lowercase letter.
-
Contain only lowercase letters, digits, and underscores (_).
-
Be 4 to 16 characters in length.
Note-
Reserved keywords cannot be used as the account name in ApsaraDB for MongoDB.
-
The account has fixed read-only permissions.
-
You only need to set an account name and password for the first endpoint application on a Shard or ConfigServer node. This is not required for subsequent applications.
Account Password
The password must meet the following requirements:
-
Contain characters from at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters.
The supported special characters are
!@#$%^&*()_+-=. -
Be 8 to 32 characters in length.
NoteApsaraDB for MongoDB allows you to reset passwords for ConfigServer and Shard node accounts. For more information, see Reset a password.
Confirm Password
Enter the password again to confirm.
-
-
Click OK.
-
On the Database Connections page, view the new endpoint.
-
Wait for the instance status to change from Establishing Network Connection to Running.
-
In the Private Endpoint - VPC section, view the endpoint for the node.
-
Related topics
To release a Shard endpoint that you no longer need, see Release a Shard or ConfigServer node endpoint.