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 Sign up with Alibaba Cloud.Free trial
Alibaba Cloud offers free trials for ApsaraDB for MongoDB replica set instances. If you are an enterprise user who use ApsaraDB for MongoDB for the first time, you can go to the Free Tier 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.
Precautions
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 more information about how to view ECS instance information, 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
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.
Procedure
- Log on to the ApsaraDB for MongoDB console.
- In the left-side navigation pane, click Replica Set Instances.
- On the Replica Set Instances page, click Create Instance.
- Set Product Type to Replica Set (Subscription) or Replica Set (Pay-as-you-go) based on your requirements.
- 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 Elastic Compute Service (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 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 ApsaraDB for MongoDB instances that run MongoDB 4.2 or earlier allow you to select only Single-zone. You can configure the Zone parameter to deploy the replica set instance in multiple zones. To implement multi-zone deployment, you must select zones in the following format: Region (Zone 1 + Zone 2 + Zone 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 a 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 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 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. - Enhanced 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 performance differences of ESSDs, such as differences in capacity range, maximum IOPS per disk, and maximum throughput per disk, see ESSDs. - 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.
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 feature, see Disk encryption.Service-linked Role The Resource Access Management (RAM) role that only the linked Alibaba Cloud service can assume. A service-linked role is required to use the disk encryption feature. 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 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. 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- This parameter specifies the storage capacity of each node, but not the sum of the storage capacity 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 This value indicates the root account of the admin database. For more information about 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 replica set 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. - Pay for the replica set instance based on the billing method of the instance.
Billing method Procedure Subscription - Complete the parameter settings and click Buy Now.
- 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.
- 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 - Complete the parameter settings and click Buy Now.
- 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.
- Click Activate Now. The system collects the amount due within the next hour.
- Check whether the replica set instance is created.
- After you complete the payment, click Console to go to the ApsaraDB for MongoDB console.
- In the upper-left corner of the page, select the resource group and region in which the replica set instance resides.
- In the left-side navigation pane, click Replica Set Instances.
- 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 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.
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. Go to the Billing Management console and open the Orders page to check whether you receive refunds.
After you confirm that the payment is refunded, try to create an instance in another zone.
Pay for orders in the cart
- In the lower-right corner of the page, click the Cart icon.
- In the Cart panel, select the orders that you want to pay and click Proceed to Checkout.
- On the Cart page, check whether the orders that you want to pay are selected. Note You can also reset the Subscription Cycle and Quantity parameters.
- If the orders that you want to pay are selected, click Buy Now.
- If the orders that you want to pay are not selected, select the orders and click Buy Now.
- On the Confirm Order page, read ApsaraDB for MongoDB (Subscription) Service Agreement, select I have read and agreed to the terms, and then click Confirm Purchase.
- On the Purchase page, complete the payment.
Related API operations
Operation | Description |
CreateDBInstance |
|
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:- Optional: If you did not set the password of the root account for the replica set instance when you created the instance, set the password of the root account. For more information, see (Optional) Reset a password.
- Configure whitelists for the replica set instance to allow specific IP addresses or CIDR blocks to access the instance. For more information, see Configure a whitelist for an ApsaraDB for MongoDB instance.
- Optional: If you want to connect to a replica set instance over the Internet, apply for a public endpoint for the instance. For more information, see (Optional) Apply for a public endpoint for an ApsaraDB for MongoDB instance.