This topic describes how to use MongoDB on CloudBox, from creating an instance to connecting to the database.
Step 1: Create an instance
- Log on to the MongoDB console.
- In the navigation pane on the left, click Replica Set Instances.
- On the Replica Set Instances page, click Create Instance.
- On the instance purchase page, configure the following parameters.
Parameter Description Product Type Select Replica Set (Pay-As-You-Go) on CloudBox. Region Select a region customized for CloudBox. Only the following regions support MongoDB on CloudBox instances:- China (Hangzhou)
- China (Beijing)
- China (Heyuan)
Zone Select a zone customized for CloudBox. Database Version Select a database version based on your business needs. - MongoDB 5.0
- MongoDB 4.4
Storage Engine The value is fixed to WiredTiger. Storage Class The value is fixed to standard SSD. Primary and Secondary Nodes The value is fixed to Three Nodes. Resource Group Select a resource group to manage the instance. You can add the instance to an existing resource group or create a new one. For more information about how to create a resource group, see Create a resource group. Note By setting a resource group, you can centrally manage multiple cloud resources across different regions under a single Alibaba Cloud account.Network Type The value is fixed to virtual private cloud (VPC). VPC Select an available VPC. If you do not have an available VPC, create one in the VPC console. For more information, see Create and manage a VPC. After the VPC is created, return to the ApsaraDB for MongoDB purchase page and click the
icon to refresh the list.vSwitch Select an available vSwitch. If you do not have an available vSwitch, create one in the VPC console. For more information, see Create and manage a vSwitch. After the vSwitch is created, return to the ApsaraDB for MongoDB purchase page and click the
icon to refresh the list.Specifications Select the CPU and memory specifications for the instance. For information about the specifications supported by CloudBox instances, see Product specifications.
Storage Space The storage space for each node in the instance. The value must be a multiple of 10 and range from 20 GB to 6000 GB. Username The value is fixed to root. Password Settings Set the password for the root account. You can choose one of the following methods: - Set Now: Set the password immediately.
- Set After Creation: Set the password after the instance is running. For more information, see (Optional) Reset a password.
Password If you choose to set the password now, follow these rules: - It must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters.
The special characters are
!@#$%^&*()_+-=. - The password must be 8 to 32 characters in length.
Quantity Select the number of instances with the same configuration. The value must be an integer from 1 to 10. - After you configure the parameters, click Buy Now.
- On the Confirm Order page, confirm the parameter settings, and then read and select the Terms of Service.
- Click Activate Now. The system automatically deducts the fee within the next hour.
- Click Console to go to the instance list page and view the instance that is being created.
Step 2: Log on to the database
You need to log on to the database to manage its data. This topic uses Data Management (DMS) to demonstrate how to log on to a database.
Log on to the ApsaraDB for MongoDB console .
In the left-side navigation pane, click Replica Set Instances.
In the upper-left corner of the page, select the resource group and region to which the desired instance belongs.
Click the ID of the instance that you want to manage or click Manage in the Actions column.
In the upper-right corner of the page that appears, click Log On and select Primary, Secondary, or Readonly. Then, you are redirected to the DMS page.
NotePrimary: the primary node in the replica set instance. If you connect to this node, you can perform both read and write operations on the databases of the replica set instance.
Secondary: secondary nodes in the replica set instance. If you connect to a secondary node, you can perform only read operations on the databases of the replica set instance.
Readonly: read-only nodes in the replica set instance. If you connect to a read-only node, you can perform only read operations on the databases of the replica set instance.
In the Log on to Database Instance dialog box, configure the parameters described in the following table.
Parameter
Description
Database Type
The engine of the database. By default, the engine of the database to be connected is selected.
Instance Region
The region in which the instance is deployed. By default, the region of the current instance is selected.
Connection String Address
The endpoint of the instance. By default, the endpoint of the current instance is displayed.
Database Name
The name of the authentication database in which the database account is created.
NoteIf Database Account is set to root, the database name is admin.
We recommend that you do not log on to a database as the root user in the production environment. You can create a user and grant permissions based on your requirements. For more information, see Manage user permissions on MongoDB databases.
Security hosting
The instance for which you enable security hosting enters the logon-free state. For more information about how to enable security hosting, see Security hosting.
Database Account
The account that is used to access the database. The initial account is
root.Database Password
The password of the database account.
NoteIf you have forgotten the password of the root account, reset a password.
Control Mode
The mode that you use to manage the instance. Select a control mode based on your business requirements.
Click Login.
NoteIf you want the browser to save the password, select Remember password and then click Login.