All Products
Search
Document Center

ApsaraDB for MongoDB:Create a multi-zone sharded cluster instance

Last Updated:Feb 07, 2024

This topic describes how to create a multi-zone sharded cluster instance. ApsaraDB for MongoDB provides a zone-disaster recovery solution to ensure the high reliability and availability of your sharded cluster instance. The solution deploys the nodes of a sharded cluster instance across three zones in the same region. These nodes exchange data with each other over an internal network. If one of the zones becomes unavailable due to force majeure factors such as a power or network failure, the high availability (HA) system automatically switches services over to another zone.

Prerequisites

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

Usage notes

If your application is deployed on an Elastic Compute Service (ECS) instance, make sure that your ApsaraDB for MongoDB instance and ECS instance meet the following requirements to ensure network connectivity: For information about how to view the information of ECS instances, 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.

Limits

  • You can deploy multi-zone sharded cluster instances that use cloud disks only in specific regions. For more information about the supported regions, see Cloud disk-based instances (multi-zone deployment).

  • You can select only Single-zone for ApsaraDB for MongoDB instances that use local disks. However, you can configure the Zone parameter to deploy sharded cluster instances in different zones. To deploy an ApsaraDB for MongoDB instance in multiple zones, you must select zones in the following format: Region (Zone 1 + Zone 2 + Zone 3). Example: Shenzhen Zones (C + D + E). For more information about the supported regions, see Local disk-based instances.

Node deployment policies

The following node deployment policies are available for sharded cluster instances:

  • Single-zone deployment: Mongos, shard, and Configserver nodes of a sharded cluster instance are deployed in the same zone.

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

    • 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.

Figure 1: Deployment policy for the component nodes in a multi-zone sharded cluster instance

Procedure

For more information about how to create a multi-zone sharded cluster instance, see Create a sharded cluster instance.

References

You can use the service availability feature to view the deployment of nodes in a sharded cluster instance across zones. You can also switch the node roles of the instance based on your business deployment. This way, your applications can connect to the nearest nodes. For more information, see Switch node roles.