All Products
Search
Document Center

ApsaraDB for MongoDB:Apply for an endpoint for a shard

Last Updated:May 21, 2025

In most cases, you can connect to a mongos node in your sharded cluster instance for reads/writes. To read the oplogs of a shard, you can apply for an endpoint for the shard. This topic describes how to apply for an endpoint for a shard.

Prerequisites

  • A sharded cluster instance is created.

  • The MongoDB protocol is selected.

Background information

The sharded cluster instance contains mongos, shard, and ConfigServer components. You can configure the specifications and quantity of shards to create sharded cluster instances that have different performance capabilities. For more information, see Sharded cluster instances.

Usage notes

  • After you apply for an endpoint for a shard, the system creates an endpoint for the primary, secondary, and read-only nodes in the shard respectively. Each endpoint has its own IP address. Before applying for an endpoint, make sure that you have a sufficient number of available IP addresses.

  • The network type of an endpoint for which you want to apply for must be the same as that of the current mongos node.

  • You cannot modify the endpoint that is allocated to a shard.

  • In this topic, the endpoint that is allocated to a shard is a private endpoint. To access a shard over the Internet, you must apply for a private endpoint for the shard, configure an account name and password, and then apply for a public endpoint. For more information about how to apply for a public endpoint, see (Optional) Apply for a public endpoint for an instance.

  • For a shard in a sharded cluster instance that uses local disks, you can apply for an endpoint along with an account. For a shard in a sharded cluster instance that uses cloud disks, you must create an account on the account management page before applying for an endpoint.

  • You can apply for an endpoint only for a shard in a sharded cluster instance.

Procedure

Instance that uses cloud disks

  1. Go to the Sharded Cluster Instances page. In the top navigation bar, select the region in which the desired instance resides. Then, find the instance and click the instance ID.

  2. Create a shard account.

    Note

    You must create a shard account only for the first application for a shard endpoint. Subsequent applications does not require repeated account configurations.

    a.

    In the left-side navigation pane of the instance details page, click Accounts.

    b. Click Create Account.

    c. In the Create Account(Only shards are supported.) panel, enter a username and password.

    Note

    A shard account is granted read-only permissions.

    Parameter

    Description

    Account Name

    Enter an account name based on the following rules:

    • The name must start with a lowercase letter.

    • The name can contain lowercase letters, digits, and underscores (_).

    • The name must be 4 to 16 characters in length.

    Note
    • Keywords cannot be used as account names.

    • A shard account is granted read-only permissions.

    Account Password

    Enter an account password based on the following rules:

    • The password contains at least three of the following character types: uppercase letters, lowercase letters, digits, and specific special characters.

      These special characters include ! @ # $ % ^ & * ( ) _ + - =

    • The password is 8 to 32 characters in length.

    Note

    You can reset the password of an account for a shard or ConfigServer component. For more information, see Reset the password of an account for an instance.

    Confirm Password

    Re-enter the password.

    d. Click OK.

  3. Apply for a shard endpoint.

    a.

    In the left-side navigation pane of the instance details page, click Database Connections.

    b. In the Internal Connections - VPC section, click Create-Shard-Cs-Connections.

    c. In the Create-Shard-Cs-Connections panel, configure the parameters described in the following table.

    Parameter

    Description

    Node Type

    Set the value to Shard.

    Select Node ID

    Select the ID of the shard for which you want to apply for an endpoint.

    d. Click OK.

  4. On the Database Connections page, view the allocated endpoint.

    a. Wait until the instance state changes from Creating Connection to Running.

    b. In the Internal Connections - VPC section, view the allocated endpoint.

Instance that uses local disks

Note

You can also click Add Shard in the Shard List section of the Basic Information page of an instance. In the panel that appears, set Enable Shard Connection to Yes, and then configure the parameters in the Apply for Shard Private Endpoint section.

  1. Go to the Sharded Cluster Instances page. In the top navigation bar, select the region in which the desired instance resides. Then, find the instance and click the instance ID.

  2. In the left-side navigation pane of the instance details page, click Database Connections.

  3. In the Internal Connections - VPC section, click Create-Shard-Cs-Connections.

  4. In the Create-Shard-Cs-Connections panel, configure the parameters described in the following table.

    Parameter

    Description

    Node Type

    Set the value to Shard.

    Select Node ID

    Select the ID of the shard for which you want to apply for an endpoint.

    Account Name

    Enter an account name based on the following rules:

    • The name must start with a lowercase letter.

    • The name can contain lowercase letters, digits, and underscores (_).

    • The name must be 4 to 16 characters in length.

      Note
      • Keywords cannot be used as account names.

      • A shard account is granted read-only permissions.

      • You must create a shard account only for the first application for a shard endpoint. Subsequent applications does not require repeated account configurations.

    Account Password

    Enter an account password based on the following rules:

    • The password contains at least three of the following character types: uppercase letters, lowercase letters, digits, and specific special characters.

      These special characters include ! @ # $ % ^ & * ( ) _ + - =

    • The password is 8 to 32 characters in length.

    Note

    You can reset the password of an account for a shard or ConfigServer component. For more information, see Reset the password of an account for an instance.

    Confirm Password

    Re-enter the password.

  5. Click OK.

  6. On the Database Connections page, view the allocated endpoint.

    a. Wait until the instance state changes from Creating Connection to Running.

    b. In the Internal Connections - VPC section, view the allocated endpoint.

References

If you no longer need the shard endpoint, you can release it. For more information about how to release an endpoint, see Release the endpoint of a shard or ConfigServer component.