ApsaraDB for MongoDB provides replica set instances. These instances are suitable for scenarios in which the number of read operations is larger than the number of write operations or the number of operations surges due to impromptu events. These scenarios are common in websites that provide online reading services and in systems that provide order queries. This topic describes how to create a replica set instance in the ApsaraDB for MongoDB console.

Prerequisites

  • An Alibaba Cloud account is created. For more information, see Sign up with Alibaba Cloud.
  • If you want to create a standalone instance that is charged based on the pay-as-you-go billing method, make sure that you have sufficient balance within your account.

Precautions

If your application is deployed on an Elastic Compute Service (ECS) instance, make sure that your replica set instance and the ECS instance meet the following requirements to ensure network connectivity:
  • Your replica set instance and the ECS instance reside in the same region, and preferably belong to the same zone. This reduces network latency. You can view the region of a created ECS instance. For more information, see View instance information.
  • Your replica set instance and the ECS instance reside in the same type of network. You can view the network type of a created ECS instance. For more information, see View instance information. If an ECS instance resides in the classic network, you can migrate the ECS instance from the classic network to a virtual private cloud (VPC). For more information, see Migrate an ECS instance from the classic network to a VPC.

Limits

Replica set instances that run MongoDB 5.0 or 4.4 can be created only in the regions and zones listed in the following table.
Region Zone
China (Hangzhou) Hangzhou Zone G, H, or I
China (Shanghai) Shanghai Zone B or G
China (Qingdao) Qingdao Zone C
China (Beijing) Beijing Zone F or H
China (Zhangjiakou) Zhangjiakou Zone A or C
China (Hohhot) Hohhot Zone B
China (Shenzhen) Shenzhen Zone E
China (Heyuan) Heyuan Zone A or B
China (Chengdu) Chengdu Zone A or B
Singapore (Singapore) Singapore Zone A, B, or C
US (Silicon Valley) Silicon Valley Zone B
US (Virginia) Virginia Zone A or B

Billing

ApsaraDB for MongoDB supports the subscription and pay-as-you-go billing methods. You can select a billing method based on your business requirements.
  • 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 configurations of the instance. Fees are automatically deducted from your Alibaba Cloud account.

For more information, see Billable items and pricing.

Procedure

After you perform the following steps, ApsaraDB for MongoDB automatically creates one or more standalone instances. No manual interventions are required.

  1. Log on to the ApsaraDB for MongoDB console.
  2. In the upper-left corner of the page, select the resource group and the region of the target instance.
  3. On the Replica Set Instances page, click Create Instance.
  4. Click the Replica Set (Subscription) tab or the Replica Set (Pay-as-you-go) tab.
  5. Configure the following parameters.
    Parameter Description
    Region The region where the replica set instance is deployed.
    Note
    • After the replica set instance is created, you cannot change the region of the instance. Proceed with caution.
    • If your application is deployed on an ECS instance, the replica set instance and the ECS instance must belong to the same region. If the replica set instance and the ECS instance belong to different regions, your application cannot communicate with the replica set instance over an internal network.
    • Replica set instances that run MongoDB 5.0 or 4.4 can be created only in some regions. For more information about these regions, see Limits.
    Zone The zone where the replica set instance is deployed.
    Note
    • If your application is deployed on an ECS instance, we recommend that you make sure that the replica set instance and the ECS instance belong to the same zone. This reduces network latency. If the replica set instance runs MongoDB 4.2 or earlier, you can migrate the instance to a different zone. For more information, see Migrate an ApsaraDB for MongoDB instance to different zones in the same region.
    • You can select multiple zones for the replica set instance to implement zone-disaster recovery. For more information, see Create a multi-zone replica set instance.
    • Replica set instances that run MongoDB 5.0 or 4.4 can be created only in some zones. For more information about these zones, see Limits.
    Database Version The MongoDB version of the replica set instance. Valid values:
    • MongoDB 5.0
    • MongoDB 4.4
    • MongoDB 4.2
    • MongoDB 4.0
    • MongoDB 3.4
    Note
    • Replica set instances that run MongoDB 5.0 or 4.4 can be created only in some regions and zones. For more information about these regions and zones, see Limits.
    • When a replica set instance is in the Running state, you can manually upgrade the MongoDB version of the instance. For more information, see Upgrade MongoDB versions.
    Storage Engine The storage engine of the replica set instance. Set the value to WiredTiger.
    Nodes The number of nodes in the replica set instance. Set this parameter based on your business requirements.
    Note Set the value to Three Nodes Replicaset for replica set instances that run MongoDB 5.0 or 4.4.
    Read-only Nodes The number of read-only nodes in the replica set instance. Set this parameter based on your business requirements. For more information about read-only nodes, see ApsaraDB for MongoDB read-only nodes.
    Note Read-only nodes are not supported for replica set instances that run MongoDB 5.0 or 4.4.
    Network Type The network type of the replica set instance. We recommend that you select VPC.
    • Classic Network: In the classic network, you can block unauthorized traffic only by configuring security groups or IP address whitelists.
    • VPC: A VPC is an isolated virtual network that provides higher security and higher performance than the classic network.
      Note If your application is deployed on an ECS instance, you must make sure that the ECS instance resides in a VPC. This ensures the network connectivity between your application and the replica set instance.
    VPC The ID of the VPC to which the replica set instance belongs. If no VPCs are available, you can create a VPC in the VPC console. For more information, see Create and manage a VPC.
    vSwitch The ID of the vSwitch to which the replica set instance is connected. If no vSwitches are available, you can create a vSwitch in the VPC console. For more information, see Work with vSwitches.
    Specification The number of cores and memory space of the replica set instance. For more information about the specifications that are supported by replica set instances, see Instance types.
    Storage Space The storage space of the replica set instance.
    Note The storage space stores the data, system, and log files of the replica set instance.
    Set Password The time at which you want to set the password of the root user. Valid values:
    Password The password of the root user. If you set the Set Password parameter to Set Now, you must set the password of the root user in compliance with the following rules:
    • The password must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. Special characters include

      !@#$%^&*()_+-=

    • The password must be 8 to 32 characters in length.
    Duration The subscription period of the replica set instance. This parameter appears only when you specify to create a subscription replica set instance. Valid monthly subscription periods range from one month to nine months. Valid yearly subscription periods range from one year to five years.
    Note If you want to enable auto-renewal for the replica set instance, select Auto-renewal and make sure that you have sufficient balance within your account before the system automatically renews the instance.
    Quantity The number of replica set instances that you want to create. All the created replica set instances have the same specifications. Valid values: 1 to 10.
  6. Purchase the replica set instance based on the billing method of the instance.
    Billing method Procedure
    Subscription
    1. Confirm the parameter settings and click Buy Now.
    2. On the Confirm Order page, check the parameter settings. Then, read MongoDB Replica Set (Subscription) Agreement of Service and select I have read and agree to MongoDB Replica Set (Subscription) Agreement 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 Pay for orders in the cart.
    Pay-as-you-go
    1. Confirm the parameter settings and click Buy Now.
    2. On the Confirm Order page, check the parameter settings. Then, read MongoDB Replica Set (Pay-as-you-go) Agreement of Service and select I have read and agree to MongoDB Replica Set (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 replica set instance has been created.
    1. After you complete the payment, click Console to go to the ApsaraDB for MongoDB console.
    2. In the top navigation bar, select the resource group and region to which the replica set instance belongs.
    3. In the left-side navigation pane, click Replica Set Instances.
    4. In the instance list that appears, check whether the standalone instance that you created is displayed.
      • If the standalone instance is displayed, the instance is created. If the standalone instance is in the Running state, the instance is running.
      • If the standalone instance is not displayed, wait for 10 minutes to 15 minutes. Then, refresh the page. If the standalone 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 standalone instance is not displayed.
        Possible cause Solution
        The standalone instance does not belong to the region that you select. In the top navigation bar of the ApsaraDB for MongoDB console, select the resource group and region to which the standalone instance belongs.
        The standalone instance does not belong to the architecture of instance that you select. In the left-side navigation pane of the ApsaraDB for MongoDB console, click Replica Set 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. Go to the Billing Management console and open the Orders page to check whether you receive a refund.

        After you confirm the refund, perform one of the following operations:
        • Select a different zone and try again.
        • Submit a ticket. To submit a ticket, go to the New Ticket page.

Pay for orders in the cart

If you want to purchase a subscription replica set 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 products that you want to buy and click Proceed to Checkout.
  3. On the Cart page, check whether the products that you want to buy are selected.
    Note You can also re-specify the Subscription Cycle and Quantity parameters.
    • If the products that you want to buy are selected, click Buy Now.
    • If the products that you want to buy are not selected, select them and click Buy Now.
  4. On the Confirm Order page, read MongoDB Replica Set (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 as instructed.

Related API operations

Operation Description
CreateDBInstance
  • Creates an ApsaraDB for MongoDB standalone instance or replica set instance.
  • Clones an ApsaraDB for MongoDB standalone instance or replica set 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 replica set instance is created, perform the following operations: