ApsaraDB for MongoDB provides replica set instances that 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.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.
Limits
- ApsaraDB for MongoDB instances that run MongoDB 4.2 or earlier can be created in the following zones:
- China (Hangzhou): Hangzhou Zone G, Zone H, Zone I, Zone J, or Zone K
- China (Shanghai): Shanghai Zone B, Zone D, Zone G, or Zone L
- China (Qingdao): Qingdao Zone B or Zone C
- China (Beijing): Beijing Zone E, Zone F, Zone H, Zone K, or Zone L
- China (Zhangjiakou): Zhangjiakou Zone A, Zone B, or Zone C
- China (Hohhot): Hohhot Zone A or Zone B
- China (Ulanqab): Ulanqab Zone A, Zone B, or Zone C
- China (Shenzhen): Shenzhen Zone A, Zone C, Zone D, Zone E, Zone F, or Zones (C + D + E)
- China (Heyuan): Heyuan Zone A or Zone B
- China (Guangzhou): Guangzhou Zone A
- China (Chengdu): Chengdu Zone A or Zone B
- China (Hong Kong): Hong Kong Zone B, Zone C, Zone D, or Zones (B + C + D)
- Singapore (Singapore): Singapore Zone A, Zone B, Zone C, or Zones (A + B + C)
- Australia (Sydney): Sydney Zone A or Zone B
- Malaysia (Kuala Lumpur): Kuala Lumpur Zone A or Zone B
- Indonesia (Jakarta): Jakarta Zone A, Zone B, or Zone C
- Philippines (Manila): Manila Zone A
- Japan (Tokyo): Tokyo Zone A, Zone B, or Zone C.
- India (Mumbai): Mumbai Zone A or Zone B
- UAE (Dubai): Dubai Zone A
- US (Silicon Valley): Silicon Valley Zone A or Zone B
- US (Virginia): Virginia Zone A or Zone B
- UK (London): London Zone A or Zone B
- Germany (Frankfurt): Frankfurt Zone A, Zone B, or Zone C
- ApsaraDB for MongoDB instances that run MongoDB 4.4 or later can be created in the following zones:
- China (Hangzhou): Hangzhou Zone G, Zone H, or Zone I
- China (Shanghai): Shanghai Zone B or Zone G
- China (Qingdao): Qingdao Zone C
- China (Beijing): Beijing Zone F or Zone H
- China (Zhangjiakou): Zhangjiakou Zone A or Zone C
- China (Hohhot): Hohhot Zone B
- China (Ulanqab): Ulanqab Zone A, Zone B, or Zone C
- China (Shenzhen): Shenzhen Zone E
- China (Heyuan): Heyuan Zone A or Zone B
- China (Chengdu): Chengdu Zone A or Zone B
- China (Hong Kong): Hong Kong Zone B, Zone C, or Zone D
- Singapore (Singapore): Singapore Zone A, Zone B, or Zone C
- Malaysia (Kuala Lumpur): Kuala Lumpur Zone B
- Indonesia (Jakarta): Jakarta Zone A, Zone B, or Zone C
- Thailand (Bangkok): Bangkok Zone A
- Japan (Tokyo): Tokyo Zone A, Zone B, or Zone C.
- South Korea (Seoul): Seoul Zone A
- India (Mumbai): Mumbai Zone B
- US (Silicon Valley): Silicon Valley Zone A or Zone B
- UK (London): London Zone A or Zone B
- US (Virginia): Virginia Zone A or Zone B
- Germany (Frankfurt): Frankfurt Zone A, Zone B, or Zone C
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.
Note 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 operations are required.
- 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) as needed.
- 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 the replica set instance is created, 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 where 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 instance. - Single-zone: The primary and secondary nodes are deployed in one zone.
- Multi-zone: 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. However, you can configure Zone 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 Zone (C + D + E).Zone The zone in which you want to deploy the replica set instance. If you set Zone Type to Multi-zone, the selected zones are for the primary node. You can select only one of the following zones:- Hangzhou Zone G, Zone H, or Zone I
- Shanghai Zone B, Zone G, or Zone L
- Beijing Zone F, Zone H, Zone L, or Zone K
- Shenzhen Zone D, Zone E, or Zone F
- Hong Kong Zone B, Zone C, or Zone D
- Ulanqab Zone A, Zone B, or Zone C
- Singapore Zone A, Zone B, or Zone C
- Jakarta Zone A, Zone B, or Zone C
- Frankfurt Zone A, Zone B, or Zone C
- Tokyo Zone A, Zone B, or Zone C.
Note If your application is deployed on an ECS instance, we recommend that you deploy the replica set instance in the zone where 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 different zones in the same region.Secondary Zone 1 If you set Zone Type to Multi-zone, you must select the zone where the secondary node is deployed. Secondary Zone 1 cannot be the same as Zone. You can select only one of the following zones:- Hangzhou Zone G, Zone H, or Zone I
- Shanghai Zone B, Zone G, or Zone L
- Beijing Zone F, Zone H, Zone L, or Zone K
- Shenzhen Zone D, Zone E, or Zone F
- Hong Kong Zone B, Zone C, or Zone D
- Ulanqab Zone A, Zone B, or Zone C
- Singapore Zone A, Zone B, or Zone C
- Jakarta Zone A, Zone B, or Zone C
- Frankfurt Zone A, Zone B, or Zone C
- Tokyo Zone A, Zone B, or Zone C.
Secondary Zone 2 If you set Zone Type to Multi-zone, you must also select the zone where the hidden node is deployed. Secondary Zone 2 cannot be the same as Zone or Secondary Zone 1. You can select only one of the following zones:- Hangzhou Zone G, Zone H, or Zone I
- Shanghai Zone B, Zone G, or Zone L
- Beijing Zone F, Zone H, Zone L, or Zone K
- Shenzhen Zone D, Zone E, or Zone F
- Hong Kong Zone B, Zone C, or Zone D
- Ulanqab Zone A, Zone B, or Zone C
- Singapore Zone A, Zone B, or Zone C
- Jakarta Zone A, Zone B, or Zone C
- Frankfurt Zone A, Zone B, or Zone C
- Tokyo Zone A, Zone B, or Zone C.
Engine Version The MongoDB version of the replica set instance. Valid values: If you set Zone Type to Multi-zone, you can select only MongoDB 6.0, MongoDB 5.0, and MongoDB 4.4.Note- If the value of the Zone, Secondary Zone 1, or Secondary Zone 2 parameter that you select does not support the 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 MongoDB versions.
Active-standby Nodes The number of active-standby nodes in the replica set instance. Set this parameter based on your business requirements. Note When you create a multi-zone replica set instance, you must set Active-standby Nodes to Three Nodes Replicaset.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 Read-only nodes. Storage Engine The storage engine of the replica set instance. This parameter can be set only to WiredTiger. Storage Type The storage type of the replica set instance. Set this parameter based on your business requirements. - 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.
Network Type The type of network in which you want to deploy the replica set instance. This parameter can be set only to VPC. Note If your application is deployed on an ECS instance, you must make sure that the ECS instance is in a 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 connects. 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 memory capacity for 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, rather than the sum of the storage capacity of all nodes.
- The storage capacity is used to store the data, system, and log files of the replica set instance.
Username Set the value 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: You want to immediately set the password of the root account.
- Set Later: You want 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 specific special characters.
These special characters include
! @ # $ % ^ & * ( ) _ + - =
- 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, 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.
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:
- 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.