All Products
Search
Document Center

ApsaraDB for MongoDB:Create a sharded cluster instance

Last Updated:Oct 09, 2024

ApsaraDB for MongoDB sharded cluster instances are suitable for scenarios in which high-concurrency read and write operations are involved. This topic describes how to create an ApsaraDB for MongoDB sharded cluster instance.

Prerequisites

An Alibaba Cloud account is created. For more information, see Create an Alibaba Cloud account.

Usage notes

If your application is deployed on an Elastic Compute Service (ECS) instance, make sure that your ApsaraDB for MongoDB instance and the ECS instance meet the following requirements to ensure network connectivity. For more information about how to view the information of an ECS instance, see View instance information.

  • Your ApsaraDB for MongoDB instance and ECS instance are deployed in the same region.

  • Your ApsaraDB for MongoDB instance and ECS instance use the same network type.

    Note
    • The same zone is recommended because the same zone reduces network latency.

    • VPC is recommended because VPC provides higher security.

    • If the network type is VPC, you must ensure that they use the same VPC ID.

    • If you want to use VPC, but the network type of the ECS instance is classic network, you can change the network type of the ECS instance to VPC. For more information, see Migrate ECS instances from the classic network to a VPC.

Supported regions and zones

For more information about the regions and zones in which you can create sharded cluster instances, see Sharded cluster instances.

Billing rules

An Alibaba Cloud account is created. For more information, see Sign up with Alibaba Cloud.

  • Subscription: If you purchase a subscription instance, you must pay an upfront fee for the instance.

  • Pay-as-you-go: A pay-as-you-go instance is charged per hour based on the configuration of the instance. Fees are automatically deducted from your Alibaba Cloud account.

Note

For more information, see Billable items.

Procedure

  1. Log on to the ApsaraDB for MongoDB console.

  2. In the left-side navigation pane, click Sharded Cluster Instances.

  3. On the Sharded Cluster Instances page, click Create Instance.

  4. On the page that appears, set the Product Type parameter to Sharded Cluster (Subscription) or Sharded Cluster (Pay-as-you-go).

  5. Configure the parameters described in the following table.

    Parameter

    Description

    Region

    The region in which you want to deploy the sharded cluster instance.

    Note
    • After you create the sharded cluster instance, you cannot change the region of the instance. Proceed with caution.

    • If your application is deployed on an ECS instance, we recommend that you deploy the sharded cluster instance in the region in which the ECS instance resides. If the sharded cluster instance and the ECS instance reside in different regions, your application cannot communicate with the sharded cluster instance over an internal network.

    Zone Type

    The zone deployment type of the sharded cluster instance. Valid values:

    • Single-zone: Mongos, shard, and ConfigServer nodes of a sharded cluster instance are deployed in one zone.

    • Multi-zone: Mongos, shard, and ConfigServer nodes of a sharded cluster instance are deployed across three different zones.

    Note

    You can select only Single-zone for ApsaraDB for MongoDB instances that use local disks. However, you can configure the Zone parameter to deploy the sharded cluster instances across zones. To deploy the instances across zones, you must select a region that includes a combination of multiple zones in the following format: Region Zones (1 + 2 + 3). Example: Shenzhen Zones (C + D + E).

    Zone

    The zone in which you want to deploy the sharded cluster instance.

    If you set the Zone Type parameter to Multi-zone, you must configure the Secondary Zone 1 and Secondary Zone 2 parameters. You must select three different zones. For more information about zones in which you can create sharded cluster instances, see Cloud disk-based instances (multi-zone deployment).

    The following multi-zone deployment rules can be used for a sharded cluster instance:

    • Mongos nodes: Mongos nodes are evenly deployed across all data centers. The sharded cluster instance must contain at least two mongos nodes that are deployed across two zones. By default, when you add a third mongos node, the node is deployed in the third zone. Subsequent nodes to be added are deployed across the three zones in turn.

    • Shard nodes: The primary, secondary, and hidden nodes of a shard node are not deployed across the three zones in sequence. Node zones may change due to manual primary/secondary switchover or automatic HA switchover.

    • Configserver nodes: The primary, secondary, and hidden nodes of a Configserver node are deployed across the three zones.

    Note

    If your application is deployed on an ECS instance, we recommend that you deploy the sharded cluster instance in the zone in which the ECS instance resides to reduce network latency. If the sharded cluster instance uses local disks, you can migrate the instance from a zone to another zone. For more information, see Migrate an ApsaraDB for MongoDB instance to a different zone.

    Protocol Type

    The protocol type of the sharded cluster instance. Valid values:

    • MongoDB

    • DynamoDB

    Note

    For more information about the DynamoDB protocol, see Compatibility details of DynamoDB-compatible ApsaraDB for MongoDB instances.

    Engine Version

    The MongoDB version of the sharded cluster instance.

    If you set the Deployment Type parameter to Multi-Zone, you can select only MongoDB 7.0, MongoDB 6.0, MongoDB 5.0, or MongoDB 4.4.

    Note
    • You can select only MongoDB 4.0 for sharded cluster instances that have the DynamoDB protocol type selected.

    • If the value of the Zone, Secondary Zone 1, or Secondary Zone 2 parameter that you select does not support multi-zone deployment, the Engine Version parameter is not displayed. In this case, the sharded cluster instance cannot be created.

    • When an instance is in the Running state, you can manually upgrade the MongoDB version of the instance. For more information, see Upgrade the major version of an ApsaraDB for MongoDB instance.

    Storage Engine

    The storage engine of the sharded cluster instance. Set the value to WiredTiger.

    Storage Type

    The storage type of the sharded cluster instance.

    • Enterprise SSDs (ESSDs) come in the following performance levels (PLs):

      • ESSD PL1: This is the basic PL of ESSDs.

      • ESSD PL2: An ESSD of PL2 delivers IOPS and throughput that are approximately two times the IOPS and throughput delivered by an ESSD of PL1.

      • ESSD PL3: An ESSD of PL3 delivers IOPS that is up to 20 times the IOPS delivered by an ESSD of PL1. An ESSD of PL3 also delivers throughput that is up to 11 times the throughput delivered by an ESSD of PL1. ESSDs of PL3 are suitable for business scenarios in which concurrent requests must be processed with high I/O performance and at low read and write latencies.

      Note

      For more information about the performance differences of the preceding disk types, see ESSDs. The performance comparison items include capacity range, maximum IOPS per disk, and maximum throughput per disk.

    • ESSD AutoPL: ESSD AutoPL disks are compatible with all features of ESSDs and provide the same baseline performance as that of PL1 ESSDs. You can configure the provisioned performance of ESSD AutoPL disks.

    • Local SSD: A local SSD resides on the same host as the database engine. You can store data in local SSDs to reduce I/O latency.

    The storage types supported by an instance vary based on the edition of the instance. The storage types displayed in the ApsaraDB for MongoDB console shall prevail.

    Encryption Type

    Specifies whether to enable the disk encryption feature for the sharded cluster instance.

    Note

    The disk encryption feature can be enabled only for instances that use ESSDs. For more information about the disk encryption feature, see Disk encryption.

    Service-linked Role

    The Resource Access Management (RAM) role that only the linked Alibaba Cloud service can assume. To use the disk encryption feature, you must create a service-linked role.

    If you have already created a service-linked role, Created is displayed on the buy page. If you have not created a service-linked role, click Create Service-linked Role.

    Encryption Key

    The customer master key (CMK) that is used for disk encryption. If no CMK exists in the current region, you can create a CMK in the Key Management Service (KMS) console. For more information, see Create a CMK.

    Network Type

    The network type of the sharded cluster instance. Set the value to VPC.

    Note

    If your application is deployed on an ECS instance, you must make sure that the network type of the ECS instance is VPC. This ensures network connectivity between your application and the sharded cluster instance.

    VPC

    The ID of the virtual private cloud (VPC) in which you want to deploy the sharded cluster instance. If no VPCs are available, you can create a VPC in the VPC console. For more information, see Create and manage a VPC.

    Note

    vSwitch

    The ID of the vSwitch to which the sharded cluster instance is connected. If no vSwitches are available, you can create a vSwitch in the VPC console. For more information, see Create and manage a vSwitch.

    Mongos Specification

    The specifications of each mongos component in the sharded cluster instance. For more information about the specifications supported by mongos components in a sharded cluster instance, see Sharded cluster instance types.

    Note

    When the sharded cluster instance is in the Running state, you can change the configurations and quantity of mongos components in the instance.

    Mongos Quantity

    The number of mongos nodes in the sharded cluster instance. Valid values: 2 to 32.

    Note
    • By default, mongos nodes use the standalone architecture. We recommend that you specify two or more mongos nodes to ensure high availability.

    • You can add up to 32 mongos nodes to each sharded cluster instance.

    Shard Specifications

    The specifications of each shard component in the sharded cluster instance. For more information about the specifications supported by shard components in a sharded cluster instance, see Sharded cluster instance types.

    Note

    When the sharded cluster instance is in the Running state, you can change the configurations and quantity of shard components in the instance.

    Shard Storage

    The storage capacity of each shard component in the sharded cluster instance. For more information, see Sharded cluster instance types.

    Note
    • This parameter specifies the storage capacity of each node, but not the sum of the storage capacity of all nodes.

    • The storage space of shard components in the instance is used to store the data, system, and log files.

    Shard Read-only Nodes

    The number of read-only nodes in a shard node of the sharded cluster instance. Valid values: 0 to 5. For more information about read-only nodes, see Read-only nodes.

    Shard Quantity

    The number of shard nodes in the sharded cluster instance. Valid values: 2 to 32.

    Note
    • By default, shard nodes use the three-node replica set architecture. We recommend that you specify two or more shard nodes to ensure proper sharding configurations. This way, the storage space and computing performance of shard nodes can be fully utilized. For more information, see Configure sharding to maximize the performance of shards.

    • You can add up to 32 shard nodes to each sharded cluster instance.

    ConfigServer Specification

    The specifications of the ConfigServer component in the sharded cluster instance. For more information about the specifications supported by the ConfigServer component in a sharded cluster instance, see Sharded cluster instance types.

    ConfigServer Storage

    The storage capacity of the ConfigServer component in the sharded cluster instance. For more information, see Sharded cluster instance types.

    Username

    This parameter can set only to root.

    Note

    For more information about the root account of the admin database and the permissions of the root account, see What permissions are granted to the root account when an instance is created?

    Set Password

    The time when you want to set the password of the root account. Valid values:

    • Set Now: You want to immediately set the password of the root account.

    • Set Later: specifies to set the password of the root account after the standalone instance is created. For more information, see (Optional) Reset a password.

    Password

    The password of the root account. If you set the Set Password parameter to Set Now, you must set the password of the root account when you create the sharded cluster instance. You must set the password in compliance with the following rules:

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

      The following special characters are supported: ! @ # $ % ^ & * () _ + - =

    • The password must be 8 to 32 characters in length.

    Duration

    The subscription duration of the sharded cluster instance. This parameter is available only when you create a subscription instance. Valid values: 1 Month, 2 Months, 3 Months, 4 Months, 5 Months, 6 Months, 7 Months, 8 Months, 9 Months, 1 Year, 2 Years, 3 Years, and 5 Years.

    Note

    If you want to enable auto-renewal for the sharded cluster instance, select Auto-renewal and make sure that you have sufficient balance within your Alibaba Cloud account before the system automatically renews the instance.

  6. Pay for the sharded cluster instance based on the billing method of the instance.

    Billing method

    Operation

    Subscription

    1. After you complete the parameter settings, click Buy Now.

    2. On the Confirm Order page, check the parameter settings. Then, read and select Terms of Service.

    3. Click Pay. On the Purchase page, complete the payment.

    Note

    You can also click Add to Cart to pay for orders in the cart in a lump sum. For more information, see the "Pay for orders in the cart" section in the Create a standalone instance topic.

    Pay-as-you-go

    1. After you complete the parameter settings, click Buy Now.

    2. On the Confirm Order page, check the parameter settings. Then, read MongoDB Sharded Cluster (Pay-as-you-go) Agreement of Service and select I have read and agree to MongoDB Sharded Cluster (Pay-as-you-go) Agreement of Service.

    3. Click Activate Now.The system collects the amount due within the next hour.

  7. Check whether the sharded cluster instance has been created.

    1. After you complete the payment, click Console to go to the ApsaraDB for MongoDB console.

    2. In the upper-left corner of the page that appears, select the resource group and region to which the desired instance belongs.

    3. In the left-side navigation pane, click Sharded Cluster Instances.

    4. Check whether the created instance is in the sharded cluster instance list.

      • If the sharded cluster instance is displayed, the instance is created. If the sharded cluster instance is in the Running state, the instance runs as expected.

      • If the sharded cluster instance is not displayed, wait for 10 to 15 minutes. Then, refresh the page. If the sharded cluster instance is still not displayed, check whether the issues that are described in the following table occur. If none of the issues occur, contact Alibaba Cloud technical support.

        The following table describes the possible causes of and solutions to the issues due to which the created sharded cluster instance is not displayed.

        Possible cause

        Solution

        The sharded cluster instance does not belong to the region that you select.

        In the upper-left corner of the ApsaraDB for MongoDB console, select the resource group and region to which the sharded cluster instance belongs.

        The sharded cluster instance does not use the instance architecture that you select.

        In the left-side navigation pane of the ApsaraDB for MongoDB console, click Sharded Cluster Instances.

        The standalone instance is not created due to insufficient resources.

        The system may fail to create the instance due to insufficient resources. In this case, your payment is refunded.

        After you confirm that the payment is refunded, try to create a sharded cluster instance in another zone.

Pay for the orders in the cart

If you want to purchase a subscription sharded cluster instance, you can also click Add to Cart to pay for orders in the cart in a lump sum after you complete the parameter settings. You can perform the following steps to pay for orders in the cart:

  1. In the lower-right corner of the page, click the Cart icon.

  2. In the Cart panel, select the orders that you want to pay and click Proceed to Checkout.

  3. On the Cart page, check whether the orders for which you want to pay are selected.

    Note

    You can also reset the Duration and Quantity parameters.

    • If the orders for which you want to pay are selected, click Buy Now.

    • Otherwise, select the orders and click Buy Now.

  4. On the Confirm Order page, read MongoDB Sharded Cluster (Subscription) Service Agreement, select I have read and agreed to the terms, and then click Confirm Purchase.

  5. On the Purchase page, complete the payment.

Related API operations

Operation

Description

CreateShardingDBInstance

  • Creates an ApsaraDB for MongoDB sharded cluster instance.

  • Clones an ApsaraDB for MongoDB sharded cluster instance.

DescribeInstanceAutoRenewalAttribute

Queries whether auto-renewal is enabled for an ApsaraDB for MongoDB instance.

DescribeDBInstanceAttribute

Queries the detailed information of an ApsaraDB for MongoDB instance.

What to do next

After the sharded cluster instance is created, perform the following operations: