All Products
Search
Document Center

ApsaraDB for MongoDB:Create a replica set instance

Last Updated:Oct 11, 2024

ApsaraDB for MongoDB provides replica set instances that are suitable for scenarios in which the number of read operations is greater than the number of write operations or the number of operations surge during temporary promotional 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 Create an Alibaba Cloud account.

Free trials

Alibaba Cloud offers free trials for ApsaraDB for MongoDB replica set instances. If you are an enterprise user who uses ApsaraDB for MongoDB for the first time, you can go to the All Free Tier Products Available page to apply for a trial. If you are not a first-time user of ApsaraDB for MongoDB, follow the steps described in this topic to create a replica set instance in the ApsaraDB for MongoDB console.

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 replica set instances, see Availability in regions and zones.

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 Replica Set Instances.

  3. On the Replica Set Instances page, click Create Instance.

  4. On the page that appears, set Product Type to Replica Set (Subscription) or Replica Set (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 replica set instance.

    Note
    • After you create the replica set 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 replica set instance in the region in which the ECS instance resides. If the replica set instance and the ECS instance reside in different regions, your application cannot communicate with the replica set instance over an internal network.

    Zone Type

    The zone deployment type of the replica set instance. Valid values:

    • Single-zone: The primary and secondary nodes are deployed in one zone.

    • Multi-zone: The primary and secondary nodes are deployed in different zones to meet the requirements for zone-disaster recovery.

    Note

    You can select Single-zone only for ApsaraDB for MongoDB instances that run MongoDB 4.2 or earlier and use local disks. However, you can configure the Zone parameter to deploy the replica set instances across multiple 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 replica set 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 zones. For more information about supported zones, see Cloud disk-based instances (multi-zone deployment).

    Note

    If your application is deployed on an ECS instance, we recommend that you deploy the replica set instance in the zone in which the ECS instance resides to reduce network latency. If the replica set instances that you want to manage run MongoDB 4.2 and earlier and use local disks, you can migrate the instances from a zone to another zone. For more information, see Migrate an ApsaraDB for MongoDB instance to a different zone.

    Engine Version

    The MongoDB version of the replica set instance.

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

    Note
    • 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. The replica set instance cannot be created.

    • 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 the major version of an ApsaraDB for MongoDB instance.

    Active-standby Nodes

    The number of active-standby nodes in the replica set instance. Configure this parameter based on your business requirements.

    Read-only Nodes

    The number of read-only nodes in the replica set instance. Configure this parameter based on your business requirements. For more information about read-only nodes, see Read-only nodes.

    Storage Engine

    The storage engine of the replica set instance. Set the value only to WiredTiger.

    Storage Type

    The storage type of the replica set instance. Configure this parameter based on your business requirements.

    • Enterprise SSDs (ESSDs) come in the following three 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 on local SSDs to reduce I/O latencies.

    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.

    Provisioned Performance

    The provisioned performance of ESSD AutoPL disks. Valid values: 0 to 50000.

    Note

    This parameter is available only for instances that use ESSD AutoPL disks.

    Encryption Type

    Specifies whether to enable the disk encryption feature for the replica set 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, the value of this parameter is Created 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 you do not have a CMK in a specified 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 replica set instance. Set the value only 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 replica set instance.

    VPC

    The ID of the virtual private cloud (VPC) in which you want to deploy the replica set instance. 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 Create and manage a vSwitch.

    Category

    The instance category.

    Specifications

    The number of CPU cores and the memory capacity of the replica set instance. For more information about the specifications that are supported by replica set instances, see Instance types.

    Storage

    The storage capacity of each node in the replica set instance.

    Note
    • You can configure the storage space of each node, rather than the sum of the storage space of all nodes.

    • The storage capacity determines how many data files, system files, and log files of the replica set instance can be stored.

    Username

    Set the value 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 the root account granted when an instance is created?

    Set Password

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

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

    • 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 replica set 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 special characters.

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

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

    Duration

    The subscription duration of the replica set 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 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. Pay for the standalone instance based on the billing method of the instance.

    Billing method

    Procedure

    Subscription

    1. After you complete the parameter settings, 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 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 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 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 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 runs as expected.

      • If the standalone instance is not displayed, wait for 10 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 upper-left corner of the ApsaraDB for MongoDB console, select the resource group and region to which the standalone instance belongs.

        The standalone instance does not use the instance architecture 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 standalone instance due to insufficient resources. In this case, your payment is refunded.

        After you confirm that the payment is refunded, you can create an instance in another zone.

Pay for the 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 reset the Duration and Quantity parameters.

    • Yes: Click Buy Now.

    • If the orders that you want to pay are not selected, select the orders 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.

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: