TencentDB for MongoDB

TencentDB for MongoDB
Operation Guide
Product Documentation©2013-2022 Tencent Cloud. All rights reserved.

Page 1 of 257

TencentDB for MongoDB

Copyright Notice©2013-2024 Tencent Cloud. All rights reserved.
Copyright in this document is exclusively owned by Tencent Cloud. You must not reproduce, modify, copy or distributein any way, in whole or in part, the contents of this document without Tencent Cloud's the prior written consent.
Trademark Notice

All trademarks associated with Tencent Cloud and its services are owned by Tencent Cloud Computing (Beijing)
Company Limited and its affiliated companies. Trademarks of third parties referred to in this document are owned bytheir respective proprietors.
Service Statement
This document is intended to provide users with general information about Tencent Cloud's products and services
only and does not form part of Tencent Cloud's terms and conditions. Tencent Cloud's products or services are
subject to change. Specific products and services and the standards applicable to them are exclusively provided for in
Tencent Cloud's applicable terms and conditions.

©2013-2022 Tencent Cloud. All rights reserved.

Page 2 of 257

TencentDB for MongoDB

Contents
Operation Guide
Access Management
Overview
Authorization Policy Syntax
Authorization Permission Policy
Instance Management
Viewing Instance Details
Adjusting Instance Specification
Switching Instance Network
Accessing Instance Without Authentication
Changing Instance AZ
Setting Instance Maintenance Period
Specifying Project for Instance
Editing Instance Tag
Restarting InstanceTerminating Instance
Adjusting Oplog Capacity
Node Management
Node Overview
Viewing Node Information
Adjusting Mongod Node Specification
Adding Secondary Node
Deleting Secondary Node
Adding Read-Only NodeAdjusting Shard Quantity
Adjusting Mongos Node Specification
Adding Mongos Node
Enabling Mongos Access Address
Promoting Secondary Node to Primary Node
Version Upgrade
Public Network Access
Enabling Public Network Access
FAQs
Monitoring
Monitoring Feature©2013-2022 Tencent Cloud. All rights reserved.

Page 3 of 257

TencentDB for MongoDB

Viewing Monitoring Data
Configuring Alarm Policy
Configuring Event Alarms
Backup and Rollback
Data Backup
Data Rollback
Data Clone
Database and Table Rollback
Batch Rollback
Restoring to Self-built Database
Data Security
Configuring Security GroupSSL Authentication
Enabling SSL Authentication
Using Mongo Shell to Connect to Database by SSL Authentication
Using Multi-Language SDKs to Connect to Database by SSL Authentication
Database Management
Account Management
Slow Log Management
Connection Management
Multi-AZ Deployment
Disaster Recovery/Read-Only Instances
Overview
Creating Read-Only Instances
Creating Disaster Recovery InstanceParameter Configuration
Recycle Bin
Task Management
Performance Optimization
Data Migration Guide
Creating Migration Task
Creating Data Consistency Check Task
Technical Scheme and Common Problems of Data Consistency Check
Creating MongoDB Data Subscription©2013-2022 Tencent Cloud. All rights reserved.

Page 4 of 257

TencentDB for MongoDB

Operation Guide
Access Management
Overview：

Last updated 2024-01-15 14:40:06
Cloud Access Management (CAM) is a web-based Tencent Cloud service that helps you securely manage and control
access permissions to your Tencent Cloud resources. Using CAM, you can create, manage, and terminate users(groups), and control the Tencent Cloud resources that can be used by the specified user through identity and policy
management.

BackgroundIf you have multiple users managing different Tencent Cloud services such as CVM, VPC, and TencentDB, and they
all share your Tencent Cloud account access key, you may face the following problems:Your key will be easily compromised because it is shared by several users.
You cannot restrict the access from other users and your service will be vulnerable to the security risks caused bytheir maloperations.

Basic Concepts
Root accountWhen you sign up for a Tencent Cloud account, the system creates a root account identity for you to log in to Tencent
Cloud services. Tencent Cloud records your usage and bills you based on the root account. The root account has fullaccess to the resources under it by default and can create sub-accounts and set permissions for them.
Sub-accountA sub-account is created by and belongs to the root account. Every sub-account has a definite ID and identity
credential.
Identity credential
An identity credential includes a login credential and an access certificate. The former refers to a user's loginname and password. The latter refers to Tencent Cloud API keys (SecretId and SecretKey).
Resource
A resource is an object manipulated in Tencent Cloud services, such as a TencentDB for MongoDB instance.
Permission
It is an authorization that allows or forbids users to perform certain operations. By default, the root account has full©2013-2022 Tencent Cloud. All rights reserved.

Page 5 of 257

TencentDB for MongoDB

access to all resources under the account, while a sub-account does not have access to any resources under its rootaccount.
PolicyIt is a syntax rule that defines and describes one or more permissions. By default, a sub-account has no access toTencent Cloud services or resources. To grant a sub-account such access, you need to create a CAM policy.

References
For more information on access management, see CAM Overview.

©2013-2022 Tencent Cloud. All rights reserved.

Page 6 of 257

TencentDB for MongoDB

Authorization Policy Syntax：

Last updated 2024-01-15 14:40:06
A policy is a syntactic specification of a user permission set, which accurately describes the authorized resource set,
operation set, and authorization conditions.

CAM Policy Syntax©2013-2022 Tencent Cloud. All rights reserved.

Page 7 of 257

TencentDB for MongoDB{"version":"2.0","statement":[{"effect":"effect","action":["action"],"resource":["resource"],"condition": {"key":{"value"}}}]©2013-2022 Tencent Cloud. All rights reserved.

Page 8 of 257

TencentDB for MongoDB}
The following table describes policy statements.
Parameter

Subparameter

Required

Description

versionN/A

Yes

Currently, only the value 2.0 is allowed.

effectYes

actionYes

It describes the result of a statement. The result can be "allow" oran "explicit deny".
It describes the allowed or denied operation which can be an API
or a feature set (a set of specific APIs prefixed with permid ).
It describes the details of authorization. All resources can bestatement

resource

Yes

described in the six-segment format. Each service has its own
resources and detailed resource definition.
It describes the condition for the policy to take effect. A condition

condition

Yes

consists of operator, action key, and action value. A condition
value may contain information such as time and IP address. A
condition value may be the time, IP address, etc. Some services
allow you to specify additional values in a condition.

Note:
The statement element describes the details of one or more permissions. This element contains a permission or
permission set of other elements such as effect , action , resource , and condition . One policy has
only one statement .

Defining an action
In a CAM policy statement, you can specify any API operation from any service that supports CAM. APIs prefixed withmongodb:

should be used for TencentDB for MongoDB, such as mongodb:BackupDBInstance ormongodb:CreateAccountUser .
To specify multiple operations in a single statement, separate them by comma:©2013-2022 Tencent Cloud. All rights reserved.

Page 9 of 257

TencentDB for MongoDB"action":["mongodb:action1","mongodb:action2"]
You can also specify multiple operations by using a wildcard. For example, you can specify all operations beginningwith "Describe" in the name as shown below:©2013-2022 Tencent Cloud. All rights reserved.

Page 10 of 257

TencentDB for MongoDB"action":["mongodb:Describe*"]If you want to specify all operations in MongoDB, use a wildcard "*" as shown below:©2013-2022 Tencent Cloud. All rights reserved.

Page 11 of 257

TencentDB for MongoDB："action" ["mongodb:*"]Defining a resource
Each CAM policy statement has its own applicable resources. Resource paths are generally in the following format:©2013-2022 Tencent Cloud. All rights reserved.

Page 12 of 257

TencentDB for MongoDB

qcs:project_id:service_type:region:account:resource
Project_id describes the project information, which is only used to enable compatibility with legacy CAM logic andcan be left empty.
service_type describes the product abbreviation, such as mongodb .
region describes the region information, such as bj .
account describes the root account of the resource owner, such as uin/12345678 .
resource describes the detailed resource information of each product, such as instance/instance_id or
instance/* .

©2013-2022 Tencent Cloud. All rights reserved.

Page 13 of 257

TencentDB for MongoDB

You can set resource to an instance ID (cmgo-aw6g1g0z) in a statement as shown below:"resource":[ "qcs::mongodb:bj:uin/12345678:instance/cmgo-aw6g1g0z"]
You can also use the wildcard "*" to specify all instances that belong to a specific account as shown below:©2013-2022 Tencent Cloud. All rights reserved.

Page 14 of 257

TencentDB for MongoDB"resource":[ "qcs::mongodb:bj:uin/12345678:instance/*"]If you want to specify all resources or if a specific API operation does not support resource-level permission control,
you can use the wildcard "*" in the resource element as shown below:©2013-2022 Tencent Cloud. All rights reserved.

Page 15 of 257

TencentDB for MongoDB"resource": ["*"]
If you want to specify multiple resources in a single command, separate them by comma. In the following example, two
resources are specified:©2013-2022 Tencent Cloud. All rights reserved.

Page 16 of 257

TencentDB for MongoDB"resource":["resource1","resource2"]
The table below describes the resources that can be used by MongoDB and the corresponding resource description
methods, where words prefixed with $ are placeholders, region refers to a region, and account refers toan account ID.
Resource
Type

Resource Description Method in Authorization Policy

Instance

qcs::mongodb:$region:$account:instance/*©2013-2022 Tencent Cloud. All rights reserved.

Page 17 of 257

TencentDB for MongoDB

qcs::mongodb:$region:$account:instance/$instanceId
VPC

qcs::vpc:$region:$account:vpc/$vpcId

SecurityGroup

qcs::cvm:$region:$account:sg/$sgId

Default Permission Policy of TencentDB for MongoDB
TencentDB for MongoDB supports the following system permission policies.
Policy Name

Note

QcloudMongoDBFullAccess

TencentDB for MongoDB management permission. A Tencent
Cloud sub-account granted with this permission has the same
permissions as the root account, including all permissions ofconsole and API operations.
Read-only permission. A Tencent Cloud sub-account granted with

QcloudMongoDBReadOnlyAccessthis permission has only the read-only permission of all resources
under the Tencent Cloud root account but not operation permissionsof the console and APIs.

The system permission policy QcloudMongoDFullAccess is as follows:©2013-2022 Tencent Cloud. All rights reserved.

Page 18 of 257

TencentDB for MongoDB{"version": "2.0","statement": [{"action": ["monitor:GetMonitorData","monitor:DescribeBaseMetrics","mongodb:*"],"resource": "*",
"effect": "allow"©2013-2022 Tencent Cloud. All rights reserved.

Page 19 of 257

TencentDB for MongoDB}]}
The system permission policy QcloudMongoDBReadOnlyAccess is as follows:{"version": "2.0","statement": [{"action": [©2013-2022 Tencent Cloud. All rights reserved.

Page 20 of 257

TencentDB for MongoDB"monitor:GetMonitorData","monitor:DescribeBaseMetrics","mongodb:Describe*"],"resource": "*",
"effect": "allow"}]}

Custom Permission Policy of TencentDB for MongoDB
Currently, TencentDB for MongoDB supports custom policies for the following resource-level permissions.
Note:
TencentDB API operations not listed here do not support resource-level permissions. You can still authorize a user toperform such a TencentDB API operation, but you must specify * as the resource element of the policy statement.
Action Name

Permission Description

Resource Description

BackupDBInstanceBacks up a databaseinstance

qcs::mongodb:$region:$account:instance/*
qcs::mongodb:$region:$account:instance/$instanceId

CreateAccountUser

Creates an accountqcs::mongodb:$region:$account:instance/*
qcs::mongodb:$region:$account:instance/$instanceId

CreateDBInstanceHour

Creates a pay-as-yougo TencentDB for
MongoDB instanceDeleteAccountUser

Deletes an accountDescribeAccountUsers

Queries the user
information of an
account

DescribeBackupAccess

Gets the permission to
download an instancebackupDescribeBackupRules

Gets the backup rulesof a TencentDB
instance

DescribeClientConnections

Gets the number of©2013-2022 Tencent Cloud. All rights reserved.

qcs::mongodb:$region:$account:instance/*
qcs::mongodb:$region:$account:instance/$instanceId
qcs::mongodb:$region:$account:instance/*
qcs::mongodb:$region:$account:instance/$instanceId
qcs::mongodb:$region:$account:instance/*
qcs::mongodb:$region:$account:instance/$instanceId

qcs::mongodb:$region:$account:instance/*
qcs::mongodb:$region:$account:instance/$instanceId

qcs::mongodb:$region:$account:instance/*
qcs::mongodb:$region:$account:instance/$instanceId
qcs::mongodb:$region:$account:instance/*

Page 21 of 257

TencentDB for MongoDB

client connections

qcs::mongodb:$region:$account:instance/$instanceId

DescribeDBBackups

Queries the list of
backups of an instance

qcs::mongodb:$region:$account:instance/*
qcs::mongodb:$region:$account:instance/$instanceId

DescribeDBInstances

Queries the list of
database instances

qcs::mongodb:$region:$account:instance/*
qcs::mongodb:$region:$account:instance/$instanceId

Queries thecollection/databaseqcs::mongodb:$region:$account:instance/*

DescribeInstanceDB

information of an
instance

qcs::mongodb:$region:$account:instance/$instanceId

DescribeSlowLog

Gets the slow log
information

qcs::mongodb:$region:$account:instance/*
qcs::mongodb:$region:$account:instance/$instanceId

DescribeSlowLogPattern

Gets the slow log
statistics

qcs::mongodb:$region:$account:instance/*
qcs::mongodb:$region:$account:instance/$instanceId

Queries purchasable

qcs::mongodb:$region:$account:instance/*

instance specifications

qcs::mongodb:$region:$account:instance/$instanceId

DescribeSpecInfo

Replaces the original
ExchangeInstance

IsolateDBInstance

ModifyDBInstanceSpec

instance with a temp
instance
Isolates a TencentDB
instance
Adjusts theconfigurations of aTencentDB instance
Deactivates an

OfflineIsolatedDBInstanceisolated TencentDB
instance

qcs::mongodb:$region:$account:instance/*
qcs::mongodb:$region:$account:instance/$instanceId
qcs::mongodb:$region:$account:instance/*
qcs::mongodb:$region:$account:instance/$instanceId
qcs::mongodb:$region:$account:instance/*
qcs::mongodb:$region:$account:instance/$instanceId

qcs::mongodb:$region:$account:instance/*
qcs::mongodb:$region:$account:instance/$instanceId

RemoveCloneInstanceDeletes a temp
instance

qcs::mongodb:$region:$account:instance/*
qcs::mongodb:$region:$account:instance/$instanceId

RenameInstance

Renames an instance

qcs::mongodb:$region:$account:instance/*
qcs::mongodb:$region:$account:instance/$instanceId

Renews a TencentDB

qcs::mongodb:$region:$account:instance/*

instance

qcs::mongodb:$region:$account:instance/$instanceId

Adjusts the oplog size

qcs::mongodb:$region:$account:instance/*of an instance

qcs::mongodb:$region:$account:instance/$instanceId

RenewInstance

ResizeOplog©2013-2022 Tencent Cloud. All rights reserved.

Page 22 of 257

TencentDB for MongoDB

RestartInstance

Restarts an instance

qcs::mongodb:$region:$account:instance/*
qcs::mongodb:$region:$account:instance/$instanceId

RestoreDBInstance

Restores a databaseinstance

qcs::mongodb:$region:$account:instance/*
qcs::mongodb:$region:$account:instance/$instanceId

SetAccountUserPrivilege

Sets user permissions

qcs::mongodb:$region:$account:instance/*
qcs::mongodb:$region:$account:instance/$instanceId

SetAutoRenew

Sets auto-renewal

qcs::mongodb:$region:$account:instance/*
qcs::mongodb:$region:$account:instance/$instanceId

SetBackupRules

Sets backup rules

qcs::mongodb:$region:$account:instance/*
qcs::mongodb:$region:$account:instance/$instanceId

Promotes a temp
SetInstanceFormal

instance to the primary
instance

qcs::mongodb:$region:$account:instance/*
qcs::mongodb:$region:$account:instance/$instanceId

SetInstanceMaintenance

Sets the instancemaintenance time

qcs::mongodb:$region:$account:instance/*
qcs::mongodb:$region:$account:instance/$instanceId

SetPassword

Sets password

qcs::mongodb:$region:$account:instance/*
qcs::mongodb:$region:$account:instance/$instanceId

SetReadOnlyToNormal

Promotes a read-only
instance to the primary
instance

TerminateDBInstanceHour

UpgradeDBInstanceHour

qcs::mongodb:$region:$account:instance/*
qcs::mongodb:$region:$account:instance/$instanceId

Terminates a pay-asyou-go instance

qcs::mongodb:$region:$account:instance/*
qcs::mongodb:$region:$account:instance/$instanceId

Upgrades a pay-as-

qcs::mongodb:$region:$account:instance/*

you-go instance

qcs::mongodb:$region:$account:instance/$instanceId

Custom permission policy example
If you want to grant an account the CreateDBInstance and CreateAccountUser permissions on the"cmgo-aw6g****" instance, you can create a policy as follows:©2013-2022 Tencent Cloud. All rights reserved.

Page 23 of 257

TencentDB for MongoDB{"version": "2.0","statement": [{"effect": "allow","action": ["mongodb:CreateDBInstance","mongodb:CreateAccountUser"],"resource": ["qcs::mongodb::uin/100001540306:instanceId/cmgo-aw6g****"©2013-2022 Tencent Cloud. All rights reserved.

Page 24 of 257

TencentDB for MongoDB],"condition": {"ip_equal": {"qcs:ip": ["10.0.0.4"
]
}
}
}
]
}

Creating a custom permission policy
You can create a custom policy on the Policies page in the CAM console. For detailed directions, see Creating
Custom Policy.

©2013-2022 Tencent Cloud. All rights reserved.

Page 25 of 257

TencentDB for MongoDB

Authorization Permission Policy：

Last updated 2024-01-15 14:40:06
Permissions of Tencent Cloud root accounts and sub-accounts are separated. You can grant sub-accounts different
permissions as needed, which avoids security risks caused by exposure of your Tencent Cloud account key.

Granting a sub-account a permission policy
Background
Company A activates the TencentDB for MongoDB service and wants its team members to manipulate the involved
resources. For security or trust considerations, it doesn't want to directly disclose its Tencent Cloud account key to theteam members; instead, it wants to create corresponding sub-accounts for them. The sub-accounts can manipulate
resources only with authorization by its root account and separate usage calculation and billing are not required, as allfees are charged to its Tencent Cloud account. It also wants to be able to revoke or delete the operation permissionsof sub-accounts at any time.

Directions
Step 1. Create a sub-account user
You can create a sub-account user through the console or an API.
Log in to the CAM console and enter the User List page to create a user. For detailed directions, see Creating SubUser.
Create a sub-user and configure permissions for them by calling the AddUser API with an access key. For more
information, see AddUser.
(Optional) Step 2. Create a custom permission policy
1. On the Policies page in the CAM console, search for a target policy by policy name in the search box in the top-rightcorner.
2. If the permission policy does not exist, you need to customize one. For detailed directions, see Creating Custom
Policy.
Step 3. Assign the permission policy to the sub-accountOn the Policies page in the CAM console, find the target permission policy and associate it with the target subaccount. For detailed directions, see Authorization Management.
On the User List page in the CAM console, find the target sub-account and associate them with the target policy. For
detailed directions, see Authorization Management.

©2013-2022 Tencent Cloud. All rights reserved.

Page 26 of 257

TencentDB for MongoDB

References
Logging in to the console
You can let your team members use a sub-account to log in to the Tencent Cloud console and access TencentDB for
MongoDB. For detailed directions, see Logging in to Console with Sub-account.
Modifying a sub-account
You can view and modify the information of a sub-account as instructed in User Information.
Deleting a sub-account
You can revoke or delete the operation permissions of a sub-account as instructed in Deleting Sub-Users.

Granting a permission policy across Tencent Cloud accounts
Background
Company A activates TencentDB for MongoDB and wants company B to have part of the permissions of its
TencentDB for MongoDB operations, such as instance read/write and slow query operation. Company B wants tohave a sub-account to take care of such businesses. In this case, company A can authorize the root account ofcompany B to access TencentDB for MongoDB resources through a role. For the specific concept and use cases ofrole, see Role Overview.

Directions
Step 1. Company A creates a role for company B
1. Log in to the CAM console and go to the Roles page.
2. Click Create Role. In the Select role entity window, select Tencent Cloud Account
3. On the Create Custom Role page, create a role.
a. On the Enter role entity info page, select Other root account as Tencent Cloud account, enter the rootaccount of company B as Account ID, set other parameters as prompted, and click Next.
b. On the Configure Role Policy page, select the target policy and click Next.
c. On the Review page, enter a role name such as DevOpsRole in the Role Name box, review the selected
policy, and click Complete.
Step 2. Company B grants a sub-account the permission to assume the role
1. On the Policies page in the CAM console, click Create Custom Policy.
2. In the Select Policy Creation Method window, select Create by Policy Syntax.
3. On the Create by Policy Syntax page, create a policy.
a. In the Select a template type section, select Blank Template and click Next.

©2013-2022 Tencent Cloud. All rights reserved.

Page 27 of 257

TencentDB for MongoDB

b. On the Edit Policy page, enter a policy name such as sts:AssumeRole in the Policy Name input box.
c. In Policy Content, set the policy content according to the policy syntax and click Complete. Below are examples:{"version": "2.0","statement": [{"effect": "allow","action": ["name/sts:AssumeRole"],"resource": ["qcs::cam::uin/12345:RoleName/DevOpsRole"]}©2013-2022 Tencent Cloud. All rights reserved.

Page 28 of 257

TencentDB for MongoDB]}
4. Return to the Policies page, find the created custom policy, and click Associate Users/Groups in the Operation
column.
5. Associate the custom policy with the sub-account of company B and click OK.
Step 3. Company B uses the sub-account to access Tencent Cloud resources through the role
1. Log in to the console with the sub-account of company B and select Switch Role in the profile photo drop-down list.
2. On the role switch page, enter the root account of company A and role name to switch to the role of company A.

References
You can modify a role as instructed in Modifying Role.
You can delete a role as instructed in Deleting a Role.
For more information on how to use CAM, see Overview.

©2013-2022 Tencent Cloud. All rights reserved.

Page 29 of 257

TencentDB for MongoDB

Instance Management
Viewing Instance Details：

Last updated 2024-04-02 17:55:34

Overview
After purchasing a TencentDB for MongoDB instance, you can quickly view its details in the console, such as thestatus, capacity usage, primary/secondary nodes in the cluster, and network status. You can also perform Ops andmanagement operations efficiently.

Prerequisites
You have created a TencentDB for MongoDB instance. For more information, see Creating TencentDB for MongoDB
Instance.
The instance hasn't been terminated or isolated into the recycle bin. For more information, see Recycle Bin.

Viewing the Instance List
1. Log in to the TencentDB for MongoDB console.
2. In the MongoDB drop-down list on the left sidebar, select Replica Set Instance or Sharded Cluster Instance.
The directions for the two types of instances are similar.
3. Above the Instance List on the right, select the region.
4. In the instance list, find the target instance.
In the search box in the top-right corner, you can search for the target instance by instance ID, instance name, private
IP, or tag key.
If you can't find the target instance in the instance list, select Recycle Bin on the left sidebar to check whether it isisolated there due to overdue payments. For more information, see Recycle Bin.
5. View the target instance information, such as the status, specification, and storage engine.

©2013-2022 Tencent Cloud. All rights reserved.

Page 30 of 257

TencentDB for MongoDB

Parameter

Description
Instance ID: The instance's unique ID.
Name: The instance name set during instance creation. You can hover over the

Instance ID/Nameinstance name and click

to rename the instance for easier identification and management.
Monitoring: You can click

Monitoring/Status

to enter the monitoring panel and view the instance monitoring data. For more
information, see Viewing Monitoring Data.
Status: Instance status. The normal status is Running. If a task is being executed in
the instance, the task name, such as Changing configuration, will be displayed
here.

Specification/Network

Specification: The specification of each instance node.
Replica set: Memory/Disk capacity.
Sharded cluster instance: Memory/Disk capacity × shard quantity.
Network: The network information of the instance.

Version and Engine

Database version information. Supported versions include 3.2, 3.6, 4.0, 4.2, and 4.4.
v3.2 is no longer for sales.
Storage Engine: It is WiredTiger by default.
The private IPv4 address and port of all primary and secondary mongod nodes in

Private Network
Address

the TencentDB instance. A TencentDB instance can be accessed only over theprivate network.
When using MongoDB Shell for access, you need to configure the private IP
address and port. For detailed directions, see Connecting to TencentDB for
MongoDB Instance.

Billing Mode

Instance billing mode, which is pay-as-you-go. For more information, see Billing
Overview.

©2013-2022 Tencent Cloud. All rights reserved.

Page 31 of 257

TencentDB for MongoDB

The used/total disk capacity of the instance. This parameter helps you quickly checkthe disk utilization of the current instance.

Used/Total

You can click View/Adjust to view the disk capacity reserved for oplog or adjust it
Oplog/Shard Infobased on your business needs. For detailed directions, see Adjusting Oplog
Capacity.
Instance project. You can view the information of all instances in this project. You
can also move the instance to another project as instructed in Specifying Project for

Project

Instance.
Select Adjust Specification to adjust the instance's memory and disk capacity as
instructed in Adjusting Instance Specification.
Select Adjust Specification > Node Management to manage the mongod andmongos nodes of the instance as instructed in Viewing Node Information.
Select More > Security Group to change security group inbound rules.
Select More > Restart to restart the instance as instructed in Restarting Instance.

Operation

Select More > Manage to view the instance details.
Select More > Edit Tag to edit the instance tag keys and values as instructed in
Editing Instance Tag.

Viewing Instance Details
In the Instance ID/Name column of the target instance, click the instance ID to enter the Instance Details page.
SectionParameter

Description

Instance Name

Custom instance name.

Instance ID

The instance's unique ID.

Instance Status

The instance's current status. The normal status is Running.

Basic Info
RegionSpecification
Info

Instance region and AZ. You can click Modify AZs to switch to another
AZ in the same region. For more information, see Changing Instance AZ.

Project

The project to which the instance belongs. You can click Switch to
Another Project to assign the instance to another project as instructed inSpecifying Project for Instance.

Instance TypeYou can set the instance cluster architecture type as Replica Set or
Sharded Cluster. For more information, see System Architecture.

Model Type

Fixed:Ten-Gigabit High IO.

©2013-2022 Tencent Cloud. All rights reserved.

Page 32 of 257

TencentDB for MongoDB

Configuration

Version andEngineThe version and the storage engine of the instance. Version upgrade issupported. For detailed directions, see Version Upgrade.

Mongod NodeSpecification

The specification of a single mongod node, including the CPU corequantity, memory, disk capacity, and node quantity. For the detailed
specifications supported by replica set and sharded cluster instances, see
Product Specifications.

Mongos NodeSpecification

The specification of a single mongos node, including the CPU corequantity, memory, and node quantity. For the detailed specifications
supported by replica set and sharded cluster instances, see ProductSpecifications.

Disk Capacity

The total disk capacity of the instance.

Billing Mode

Billing mode of the instance: Pay-as-you-go.

Creation TimeCreation time of the instance.

Maintenance
PeriodInfo

Network
Configuration

Instance maintenance period. To ensure the stability of the database, thebackend system will periodically perform maintenance operations on the
instance. You can click Modify to adjust the maintenance period as
instructed in Setting Instance Maintenance Period. We recommend you
schedule maintenance during off-peak hours.

Auth-Free
Access

You can view whether auth-free access to databases is enabled. If thestatus is Not enabled yet, you can click Enable to enable this feature as
instructed in Accessing Instance Without Authentication.

Tag

Tags associated with the instance. You can change them as instructed in
Editing Instance Tag.

Network

Instance VPC name. You can click Switch Network to switch the VPC
and subnet as instructed in Switching Instance Network. If needed, you
can also create a VPC as instructed in Creating VPC.
AZ-specific subnet in the instance VPC. A VPC allows for subnets in

SubnetConnectionType

different AZs, which can communicate with each other over the private
network by default. After you modify the instance AZ, we recommend thatyou also switch the subnet to reduce the access latency.
The node type for database access.
Access read/write primary node: Access the database through the primarynode of the instance, which allows both read and write operations.
Access read-only node only: Access the database exclusively throughread-only nodes. If no read-only nodes are configured when creating an
instance, they will not be displayed.

©2013-2022 Tencent Cloud. All rights reserved.

Page 33 of 257

TencentDB for MongoDB

Access secondary node only: Access the database exclusively through asecondary node.
Access secondary node and read-only node: Access the database througha secondary node preferentially. If all secondary nodes are unavailable,
the database will be accessed through a read-only node.
Access address(connection

The URI encoded connection string of each connection type. You candirectly copy a string to access the database as instructed in Connecting

string)to TencentDB for MongoDB Instance.

More operations
Renaming an instance
1. In the Instance List, hover over the name of the target instance and clickon the right.
2. In the instance name input box, enter a new name, which must meet the following requirements:
Minimum of 1 character, maximum of 60 characters.
A combination of letters, digits, underscores, and hyphens.
A letter, digit, or special symbol is counted as one character.

Setting fields in the instance list
1. Clickin the top-right corner of the instance list.
2. On the Display Settings page, select the fields to be displayed.
3. Click OK, and you can see the reset fields in the instance list.

Exporting the instance list
You can clickin the top-right corner of the instance list to export the entire list.

Related APIs

©2013-2022 Tencent Cloud. All rights reserved.

Page 34 of 257

TencentDB for MongoDB

API

Description

DescribeDBInstances

Queries the list of TencentDB instances

RenameInstance

Renames an instance©2013-2022 Tencent Cloud. All rights reserved.

Page 35 of 257

TencentDB for MongoDB

Adjusting Instance Specification：

Last updated 2024-04-02 16:55:54

Overview
If the specification of your purchased TencentDB for MongoDB instance doesn't meet your current business
requirements, whether it's below or above, you can easily adjust it according to your actual business conditions (at theinitial stage, at the rapid development stage, during peak hours, or during off-peak hours), so as to better meet yourneeds such as full utilization of resources and real-time cost optimization.

Adjusting the specification
The memory and CPU cores of mongod and mongos nodes are in fixed combinations, and the disk capacity has acorresponding value range. For example, if the specification of a mongod node is 2-core 4 GB MEM, then the disk
capacity can range from 100 to 500 GB.
‌Mongod replica secondary nodes: You have the option to choose between 3 nodes (one-primary-two-secondary), five(one-primary-four-secondary), or seven (one-primary-six-secondary) nodes. Currently, you cannot customize thenumber of secondary nodes.
The numbers of mongos nodes supported by single-AZ deployed and multi-AZ deployed instances are different. A
single-AZ deployed instance can contain 3–32 nodes, while a multi-AZ deployed instance can contain 6–32 nodes.
You can select a specification based on your business conditions as described in Product Specifications first. Then,
select an adjustment type and make adjustments based on the following table.
Specification
Adjustment
Type

Specification Description

Adjust themongod nodespecification

You can adjust the memory, disk capacity, and oplog capacity of a mongod node.

Adjust the
replica nodequantity﻿You can add or remove secondary nodes in both replica set and sharded cluster. You havethe option to choose between 3 nodes (one-primary-two-secondary), five (one-primary-foursecondary), or seven (one-primary-six-secondary) nodes. Currently, you cannot customize
the number of secondary nodes.

Adjust the shard
quantity

You can add or remove mongod shards in a sharded cluster.

©2013-2022 Tencent Cloud. All rights reserved.

Page 36 of 257

TencentDB for MongoDB

Adjust the

You can adjust the CPU cores and memory of mongos nodes in a sharded cluster.

mongos nodespecification
Adjust themongos nodequantity

You can add mongos nodes in a sharded cluster.

Add read-onlynodes

You can add 0 to 5 read-only nodes.

©2013-2022 Tencent Cloud. All rights reserved.

Page 37 of 257

TencentDB for MongoDB

Switching Instance Network：

Last updated 2024-06-24 17:45:05
You can directly switch the network of a TencentDB for MongoDB instance in the console to adjust the network status
promptly.

Overview
Tencent Cloud supports classic network and VPC as described in Overview, which are capable of offering a diversityof smooth services. On this basis, we provide more flexible services as shown below to help you manage network
connectivity with ease.
Switch from classic network to VPC: A single TencentDB source instance can be switched from classic network to
VPC.
Switch from VPC A to VPC B: A single TencentDB source instance can be switched from VPC A to VPC B.

Version Description
Currently, TencentDB for MongoDB 3.2, 3.6, 4.0, 4.2, 4.4, 5.0, and 6.0 support instance network switch.

Billing Overview
Switching the instance network doesn't incur additional fees.

Note
Switching the network may cause the change of instance's private IP. The original IP will become invalid after thereclamation time has elapsed. You need to change the instance IP on the client promptly.
The switch from classic network to VPC is irreversible. After the switch to a VPC, the TencentDB instance cannot
communicate with Tencent Cloud services in another VPC or classic network.
The network switch of a primary instance doesn't apply to its associated read-only instances or disaster recovery
instances, you need to manually switch the network for these instances.

Prerequisites©2013-2022 Tencent Cloud. All rights reserved.

Page 38 of 257

TencentDB for MongoDB

You have created a TencentDB for MongoDB instance. For more information, see Creating TencentDB for MongoDB
Instance.
The TencentDB for MongoDB replica set or sharded cluster instance is in Running status.

Directions
1. Log in to the TencentDB for MongoDB console.
2. In the MongoDB drop-down list on the left sidebar, select Replica Set Instance or Sharded Cluster Instance.
The directions for replica set instances and sharded cluster instances are similar.
3. Above the Instance List on the right, select the region.
4. In the instance list, find the target instance.
5. Click the target instance ID to enter the Instance Details page and click Change Network on the right of
Network.
6. In the Change Network pop-up window, select a VPC and subnet in the current region in the drop-down list next to
Network.
If existing networks can't meet your requirements, you can click Create VPCs or Create Subnets to create a
network and select it.

New IP Assignment Method: Select Auto Assign or Designate address.

©2013-2022 Tencent Cloud. All rights reserved.

Page 39 of 257

TencentDB for MongoDB

Auto Assign: The system will automatically assign an available IP address based on the currently selected network
environment.
Designate Address: You can enter a specific IP address in the New IPv4 Address input box. The specified IP
address must be unoccupied and within the IP range of the specified VPC.
Note:
You can only select a VPC in the region of the instance.
We recommend that the VPC where the CVM instance resides should be selected; otherwise, the CVM instance will
not be able to access TencentDB for MongoDB over the private network, unless a CCN is created between the two
VPCs.
Old IP: For a replica set instance, the old IP address can be released immediately. For a sharded cluster instance,
you need to select the release time of the old IP address in the drop-down list, which can be Release Now, Release
after 1 day, Release after 2 days, Release after 3 days, or Release after 7 days. The IP address will be
released after the retention time has elapsed.
Note:
When the delayed release is selected, there will be a transition period for IP address conversion, which is called "delaytime". During the delay time, the old IP address can still be connected to, and the new IP address also takes effect.
When the delay time is over, the old IP address will be reclaimed, the relevant cleanup task will be started to clear theconfigurations and records related to it, and all network connections to it will be closed immediately. You shouldchoose the release time carefully.
7. After confirming the network switch, click OK. Return to the instance details page where you can view the new
network of the instance.

©2013-2022 Tencent Cloud. All rights reserved.

Page 40 of 257

TencentDB for MongoDB

Accessing Instance Without Authentication：

Last updated 2024-04-02 16:49:12

Overview
Auth-free access allows you to access your TencentDB instance quickly and efficiently, but it also exposes yourinstance to security threats. We recommend that you enable this feature only in test or maintenance scenarios anddisable it during routine business operations.

Version Description
Currently, TencentDB for MongoDB versions 3.6, 4.0, 4.2, 4.4, and 5.0 support auth-free access.

Note
Upgrading to the auth-free access version involves kernel upgrade and momentary disconnections.
Enabling auth-free access will require the instance to restart. It is advisable to enable this feature during off-peakhours.

Prerequisites
You have created a TencentDB for MongoDB instance. For more information, see Creating TencentDB for MongoDB
Instance.
The TencentDB for MongoDB instance is in Running status.
On the Instance Details page, the status of Auth-Free Access is Not enabled yet.

Enabling Auth-Free Access
1. Log in to the TencentDB for MongoDB console.
2. In the MongoDB drop-down list on the left sidebar, select Replica Set Instance or Sharded Cluster Instance.
The directions for replica set instances and sharded cluster instances are similar.
3. Above the Instance List on the right, select the region.
4. In the instance list, find the target instance.

©2013-2022 Tencent Cloud. All rights reserved.

Page 41 of 257

TencentDB for MongoDB

5. Click the instance ID to enter the Instance Details page.
6. On the Instance Details page, click Enable next to Auth-Free Access.
7. In the Enable Auth-Free Access pop-up window, confirm the impact of enabling this feature and click OK.

8. On the Instance Details page, wait until the instance status changes to Running. Once completed, Then, you canconnect to the database using the private IPv4 address and port without the need for a username and password.

Disabling Auth-Free AccessOn the Instance Details page, click Disable next to Auth-Free Access to disable this feature.

Relevant Operations
You can access TencentDB for MongoDB databases using MongoDB shell or drivers in various programming
languages as instructed in Connecting to TencentDB for MongoDB Instance.

©2013-2022 Tencent Cloud. All rights reserved.

Page 42 of 257

TencentDB for MongoDB

Changing Instance AZ：

Last updated 2024-04-02 16:42:38

Overview
During regular maintenance, you can place your TencentDB for MongoDB and CVM instances in the same AZ tolower the network latency. TencentDB for MongoDB multi-AZ instances support free AZ switch, and single-AZ
instances can be upgraded to multi-AZ instances.

Billing Overview
Changes to the AZ doesn't affect instance billing.

Note‌Changes to the AZ may lead to primary-secondary switch and a momentary disconnection of about 10 seconds. It isadvisable to make these changes during off-peak hours of your business.

‌Instructions
All attributes, specifications, and connection addresses of the instance will stay unchanged after AZ modification.
However, the private IP of the database will change after network switch, so you need to reconnect to the instance.

Prerequisites
You have created a TencentDB for MongoDB instance. For more information, see Creating TencentDB for MongoDB
Instance.
The instance is in Running status.
The target AZ and the current instance AZ are in the same region.

Directions©2013-2022 Tencent Cloud. All rights reserved.

Page 43 of 257

TencentDB for MongoDB

1. Log in to the TencentDB for MongoDB console.
2. In the MongoDB drop-down list on the left sidebar, select Replica Set Instance or Sharded Cluster Instance.
The directions for the two types of instances are similar.
3. Above the Instance List on the right, select the region.
4. In the instance list, find the target instance.
5. Click the instance ID to enter the Instance Details page.
6. On the Instance Details page, click Change AZs next to Region.

7. In the Change AZs window, read the notes on AZ modification. For a multi-AZ deployed instance, configure
different AZs for the primary and secondary nodes respectively. For a single-AZ deployed instance, configure thesame AZ for both the primary and secondary nodes.

©2013-2022 Tencent Cloud. All rights reserved.

Page 44 of 257

TencentDB for MongoDB

Note:
Changes to the AZ may lead to primary-secondary switch and a momentary disconnection of about 10 seconds. It isadvisable to make these changes during off-peak hours of your business.
8. Select the time for executing the AZ switch task next to Switch Time. You can click Learn more about switch
time and change the instance maintenance period to the off-peak hours of your business. For detailed directions, see
Setting Instance Maintenance Period.
Note:
If you have selected During maintenance period, do not select Upon modification completion to immediately
execute the task before the configured maintenance period; otherwise, a program exception will occur. An initiatedtask cannot be stopped manually. To stop it, submit a ticket for application.
Upon modification completion: The task will be executed immediately after the configuration is completed.
During maintenance period: The task will be executed during the maintenance period.

©2013-2022 Tencent Cloud. All rights reserved.

Page 45 of 257

TencentDB for MongoDB

9. Confirm Total Fees, click OK to enter the order page, check the order, click Submit Order, and make thepayment to complete the operation.The instance status becomes Changing AZ. Wait for the task to be completed,and you can see that the AZ has been changed.

Subsequent operations
After changing the AZ, switch the VPC subnet to avoid a high access latency. For detailed directions, see Switching
Instance Network.

©2013-2022 Tencent Cloud. All rights reserved.

Page 46 of 257

TencentDB for MongoDB

Setting Instance Maintenance Period：

Last updated 2024-04-02 16:25:58
TencentDB for MongoDB allows you to adjust the instance maintenance period in the console to meet the changes inyour business requirements.

Overview
The maintenance period is crucial for ensuring the stability of your TencentDB for MongoDB instance. During thisperiod, the backend system performs necessary maintenance operations on your instance. To minimize the potential
impact on your business, we recommend you set an acceptable maintenance period, preferably during off-peak hours.
This will help mitigate any disruptions to your business operations.
In addition, we also recommend you perform operations involving data migration, such as adjusting the memory
specification or AZ of mongod or mongos nodes, during the maintenance period. Taking the database instance AZchange as an example, as the full and incremental data needs to be synced from the original AZ to the new AZ, data
migration will be involved. After the AZ is changed, a momentary disconnection from the database may occur. Whenthe task is initiated, the Switch Time can be selected as During maintenance period, so that the instance data
migration will be started during the next maintenance period after the data sync is completed.
Note:
Before maintenance is carried out for TencentDB for MongoDB, notifications will be sent to the contacts configured inyour Tencent Cloud account through SMS and email.

Version Description
Currently, TencentDB for MongoDB versions 3.2, 3.6, 4.0, 4.2, 4.4, and 5.0 support maintenance period configuration.

Prerequisites
You have created a TencentDB for MongoDB instance. For more information, see Creating TencentDB for MongoDB
Instance.
The TencentDB for MongoDB replica set or sharded cluster instance is in Running status.

Directions©2013-2022 Tencent Cloud. All rights reserved.

Page 47 of 257

TencentDB for MongoDB

1. Log in to the TencentDB for MongoDB console.
2. In the MongoDB drop-down list on the left sidebar, select Replica Set Instance or Sharded Cluster Instance.
The directions for replica set instances and sharded cluster instances are similar.
3. Above the Instance List on the right, select the region.
4. In the instance list, find the target instance.
5. Click the target instance ID to enter the Instance Details page.
6. On the Instance Details page, click Change on the right of Maintenance Period.
7. In the Change Maintenance Period window, set Start Time and Duration.

8. Click OK. You can view the newly set maintenance period on the Instance Details page.

©2013-2022 Tencent Cloud. All rights reserved.

Page 48 of 257

TencentDB for MongoDB

Specifying Project for Instance：

Last updated 2024-01-15 14:40:06
TencentDB for MongoDB allows you to assign an instance to a new project in the console to meet your requirementsin ever-changing business scenarios.

Overview
A project is a set of applications or services that share resources. Each project is unique, with its own applications,services, and resources isolated from and unaffected by those in other projects.
You can specify an appropriate project for your database instances to facilitate collaboration. In this way, you caneasily manage your instances globally and stay on top of the operational conditions of the entire project.

Version Description
Currently, TencentDB for MongoDB 3.2, 3.6, 4.0, 4.2, 4.4, and 5.0 support instance restart.

Billing Overview
Changing the instance project doesn't incur additional fees.

Note
Assigning and reassigning TencentDB instances among projects will not affect the services provided by the instances.

Prerequisites
You have created a TencentDB for MongoDB instance. For more information, see Creating TencentDB for MongoDB
Instance.
You have specified a project for the instance. The Default Project is used by default.

Directions©2013-2022 Tencent Cloud. All rights reserved.

Page 49 of 257

TencentDB for MongoDB

1. Log in to the TencentDB for MongoDB console.
2. In the MongoDB drop-down list on the left sidebar, select Replica Set Instance or Sharded Cluster Instance.
The directions for replica set instances and sharded cluster instances are similar.
3. Above the Instance List on the right, select the region.
4. In the instance list, find the target instance.
5. Click the target instance ID to enter the Instance Details page.
6. In the Basic Info section, click Switch to Another Project on the right of Project.
7. On the Assign to Project page, select the target project.
8. Click OK. In the Basic Info section,

will be displayed on the right of Instance Status.
9. Wait for the task to be completed. On the right of Project, you can see the project to which the instance isreassigned.
You can filter instances by Project in the instance list to view the running status of each instance in the entire project.

API
API Name

Description

AssignProjectSpecifies the project to which an instance belongs©2013-2022 Tencent Cloud. All rights reserved.

Page 50 of 257

TencentDB for MongoDB

Editing Instance Tag：

Last updated 2024-01-15 14:40:06
TencentDB for MongoDB allows you to edit instance tags in the console for easier instance management.

Overview
A tag consists of a tag key and value. It can be used to tag TencentDB for MongoDB instances. If you have multiple
types of resources under your Tencent Cloud account which are correlated in many ways, and your resources are
growing and becoming increasingly difficult to manage, you can use tags to group and categorize resources that serve
the same purpose or are associated with each other. In this way, when performing daily Ops or troubleshooting, you
can quickly search for resources and perform batch operations for more efficient Ops.

Version Description
Currently, TencentDB for MongoDB 3.2, 3.6, 4.0, 4.2, 4.4, and 5.0 support tag management.

Billing Overview
Tag management is a free service provided by Tencent Cloud for your Tencent Cloud account. You can simply go to
the console to use this service.

Note
A tag consists of 1 tag key and 1 tag value (tagKey:tagValue).
Up to 50 tags can be bound to an instance.
For each instance, a tag key can correspond to only one tag value.

Prerequisite
You have created a TencentDB for MongoDB instance. For more information, see Creating TencentDB for MongoDB
Instance.

©2013-2022 Tencent Cloud. All rights reserved.

Page 51 of 257

TencentDB for MongoDB

Directions
1. Log in to the TencentDB for MongoDB console.
2. In the MongoDB drop-down list on the left sidebar, select Replica Set Instance or Sharded Cluster Instance.
The directions for replica set instances and sharded cluster instances are similar.
3. Above the Instance List on the right, select the region.
4. In the instance list, find the target instance.
5. Enter the Edit Tag page in any of the following ways:
In the Operation column of the target instance, select More > Edit Tag.
Click the target instance ID and clickon the right of Tag in the Configuration section on the Instance Details page.
6. On the Edit Tag page, select an appropriate tag key from the Tag Key drop-down list and select the tag value fromthe Tag Value drop-down list.

7. (Optional) If existing tags don't meet your business requirements, perform the following operations:
7.1 In the top-right corner of the current page, click Manage Tags.
7.2 On the Manage Tags page, click Create Tag.
7.3 On the Create Tag page, carefully read the notes on tag configuration.
7.4 Set a new tag key in the Tag Key input box and enter the tag value in the Tag Value input box. The requirements
for the tag key are as follows:©2013-2022 Tencent Cloud. All rights reserved.

Page 52 of 257

TencentDB for MongoDB- It can contain 1–63 characters.
- It can contain letters and digits.
- It can contain the following special symbols: plus sign, equal sign, underscore, hyphen, dot, colon, slash, @,parentheses, and brackets.
7.5 Click OK to complete the creation.
7.6 Go back to the Edit Tag page of the database instance. Click Reload in the Tag Key drop-down list, select thecreated tag key, and select the tag value.
8. Click OK.

References
For more information on tag management, see Tag.

©2013-2022 Tencent Cloud. All rights reserved.

Page 53 of 257

TencentDB for MongoDB

Restarting Instance：

Last updated 2024-01-15 14:40:06
If the number of connections to an instance reaches the threshold or the instance has performance problems, youneed to restart it manually. This document describes how to restart a replica set or sharded cluster instance.

Overview
When the system becomes completely unavailable due to a high load, you can restart it to resume node operations.
Due to the architecture of the TencentDB for MongoDB instance, instance restart divides into mongos restart andmongod restart.
mongos is a routing service configured for MongoDB sharding. It processes query requests from the application layerand determines the location of data in a sharded clustermongod is the primary daemon process for the MongoDB system. It handles data requests, manages data access,and performs background management operations.

Version Description
Currently, TencentDB for MongoDB 3.2, 3.6, 4.0, 4.2, 4.4, and 5.0 support instance restart.
The architecture of MongoDB 4.0 replica set instance is simplified, where the mongos component is removed;
therefore, instance restart doesn't involve mongos restart.

Note
During restart, there may be one or two momentary disconnections for around 10s each. We recommend that you
configure an automatic reconnection feature for your application.
You cannot cancel an ongoing restart operation; therefore, proceed with caution.

Prerequisites
You have created a TencentDB for MongoDB instance. For more information, see Creating TencentDB for MongoDB
Instance.
The TencentDB for MongoDB instance is in Running status.

©2013-2022 Tencent Cloud. All rights reserved.

Page 54 of 257

TencentDB for MongoDB

Directions
Restarting one instance
1. Log in to the TencentDB for MongoDB console.
2. In the MongoDB drop-down list on the left sidebar, select Replica Set Instance or Sharded Cluster Instance.
The directions for replica set instances and sharded cluster instances are similar.
3. Above the Instance List on the right, select the region.
4. In the instance list, find the target instance.
5. On the row of the target instance, click More > Restart in the Operation column.

6. In the Restart MongoDB window, click View Details to confirm the information of the instance to be restarted.
7. Select the components to be restarted and click OK.
8. In the instance list, you can see that the instance enters the Restarting status. Wait for the task to be completed.

Restarting multiple instances
1. In the instance list, select the instances to be restarted.
2. Above the instance list, click Restart.
3. In the Restart MongoDB window, click View Details to confirm the information of all the instances to be restarted.
4. Select the components to be restarted and click OK.

©2013-2022 Tencent Cloud. All rights reserved.

Page 55 of 257

TencentDB for MongoDB

Terminating Instance：

Last updated 2024-01-15 14:40:06
If you no longer need a TencentDB for MongoDB instance, you can directly terminate and return it in the console.

Overview
You can terminate an instance if you no longer need it. The terminated instance will be put into the recycle bin. For
instances in the recycle bin, you can restore or release them as needed based on different scenarios.

Version Description
Currently, TencentDB for MongoDB 3.2, 3.6, 4.0, 4.2, 4.4, and 5.0 support instance termination.

Billing Overview
When an instance is returned and its status has changed to Isolated, it will no longer generate fees.
For instances that met the 5-day no-questions-asked refund policy, the payment will be returned to your Tencent
Cloud account.
For normal instances, the payment will be returned to your Tencent Cloud account by the proportion of the cash andgift cards paid for the purchase.
After a pay-as-you-go instance is returned, it will be moved to the recycle bin and retained there for three days. During
the retention period, the instance cannot be accessed, but it can be restored after top-up.

Note
After an instance is completely terminated, its data will be cleared and cannot be recovered. You need to back up thedata in advance.

Note
When an instance is terminated, its read-only instances will not be terminated simultaneously.

©2013-2022 Tencent Cloud. All rights reserved.

Page 56 of 257

TencentDB for MongoDB

After an instance is terminated, it will be moved to the recycle bin. During the retention period, the instance cannot be
accessed. To use the instance again, you can restore it from the recycle bin. For detailed directions, see Recycle Bin.
When the instance is terminated, its IP resources will be released simultaneously. The DR instance will be
disconnected from the synchronous connection and automatically upgraded to the master instance.

Prerequisites
You have created a TencentDB for MongoDB instance. For more information, see Creating TencentDB for MongoDB
Instance.
The TencentDB for MongoDB instance is in Running status.

Directions
Pay-as-you-go instance
1. Log in to the TencentDB for MongoDB console.
2. In the MongoDB drop-down list on the left sidebar, select Replica Set Instance or Sharded Cluster Instance.
The directions for replica set instances and sharded cluster instances are similar.
3. Above the Instance List on the right, select the region.
4. In the instance list, find the target instance.
5. In the Operation column of the target instance, select More > Terminate.
6. In the pop-up window, read the prompt message carefully, confirm the instance to be terminated, and click OK.

Recycle Bin
Terminated instances will be put into the recycle bin and can be restored during the retention period. For more
information, see Recycle Bin.

©2013-2022 Tencent Cloud. All rights reserved.

Page 57 of 257

TencentDB for MongoDB

Adjusting Oplog Capacity：

Last updated 2024-01-15 14:40:06

Overview
Oplog is an important component in MongoDB used to log the operations in the database. The oplog capacity should
be at least 10% of the node capacity, as the oplog records all database operations, including insertions, updates, anddeletions. If the oplog capacity is too small, the oplog may be overwritten, affecting the rollback feature of MongoDB.
When you purchase an instance, the oplog capacity is 10% of the instance capacity by default and can be expanded
to 90% of the instance capacity as needed; however, it cannot be shrunk currently.

Prerequisites
You have created a TencentDB for MongoDB instance. For more information, see Creating TencentDB for MongoDB
Instance.
If your instance is pay-as-you-go, make sure that your Tencent Cloud account balance is sufficient.
The instance and its associated instances are in Running status and are not executing any tasks.

Directions
1. Log in to the TencentDB for MongoDB console.
2. In the MongoDB drop-down list on the left sidebar, select Replica Set Instance or Sharded Cluster Instance.
The directions for the two types of instances are similar.
3. Above the Instance List on the right, select the region.
4. In the instance list, find the target instance.
5. In the Oplog/Shard Info column, click View/Adjust.
6. In the Adjust Oplog pop-up window, confirm the instance information and evaluate the target oplog capacity basedon the current capacity.
Note:
The oplog capacity is at least 10% of the node capacity. When the size of the oplog file reaches the maximum
capacity, MongoDB will overwrite previous operation records from the beginning of the file. If the oplog is too small,data may be easily overwritten, thereby affecting the rollback feature of MongoDB.
Parameter

Description

Shard ID

The instance ID.

©2013-2022 Tencent Cloud. All rights reserved.

Page 58 of 257

TencentDB for MongoDB

Storage Node Quantity

The number of primary and secondary mongod nodes in the instance.

Total capacity of shard

The mongod node disk capacity per shard.

Occupied shard capacity

The occupied mongod node capacity per shard.

Oplog Capacity

The mongod node oplog storage capacity per shard.

7. Click Next to adjust the oplog capacity.
Parameter

Description

Resource ID

The instance ID.

Time taken for remaining
capacity to be fully
occupied

The time it will take for the remaining capacity to be fully occupied.

Current Total Capacity

The mongod node oplog storage capacity per shard.

Capacity after Expansion

Expand the oplog capacity on the slider.

8. Click OK.

©2013-2022 Tencent Cloud. All rights reserved.

Page 59 of 257

TencentDB for MongoDB

Node Management
Node Overview：

Last updated 2024-06-26 16:34:04
The replica set architecture of TencentDB for MongoDB achieves high availability and read/write separation by
deploying multiple types of nodes. Each replica set instance consists of one primary node, one or multiple secondary
nodes, and one hidden node.
The sharded cluster architecture implements the horizontal capacity expansion of data based on the replica set
architecture by combining multiple replica sets, each of which is a shard.
Each node is as described below:
Node

FeatureDescription

Primarynode

It is responsible for handling read/write
operations.

There can be only one primary node in each
replica set instance.

Secondarynode

It replicates the data of the primary node
by periodically polling the oplogs of the
primary node with data consistency
guaranteed. When the original primarynode fails, a new primary node will beelected from multiple secondary nodes
to ensure the high availability.

When a client connects to a secondary node, it
has read-only access and cannot write data.
A secondary node can be expanded as described
in Adding Secondary Node.
A secondary node can be promoted to primarynode as described in Promoting Secondary Nodeto Primary Node.

Hidden node

A secondary node will be designated as
the hidden node by default for each
newly purchased instance.
It serves as an invisible replica node toback up data.
When a secondary or a read-only node
fails, this hidden node and the faulty
secondary node can be switched to new
secondary nodes, thereby achieving
high availability.

There can be only one hidden node in each replica
set instance.
It is not possible to delete a secondary node thathas been designated as a hidden node.
A hidden node is not included in the "Primary
Node's Replica List" and will not be elected as theprimary node. However, it can participate in thevoting process to elect the primary node.

Read-onlynode

If the read-only replica feature isenabled, the system will set one or moresecondary nodes as read-only nodes.
Read-only nodes are primarily used in
scenarios with a large volume of readrequests. They synchronize data fromthe primary or secondary nodes throughthe operation log. The system©2013-2022 Tencent Cloud. All rights reserved.

Read-only nodes do not participate in the electionof the primary node.
There can be multiple read-only nodes in each
replica set instance. For more information, see
Adding Read-Only Node.

Page 60 of 257

TencentDB for MongoDB

automatically routes read requests to
the read-only nodes to reduce theaccess pressure on the primary node.

©2013-2022 Tencent Cloud. All rights reserved.

Page 61 of 257

TencentDB for MongoDB

Viewing Node Information：

Last updated 2024-04-02 16:14:18

Overview
TencentDB for MongoDB allows you to view the instance node information, including node ID, role, running status,
and used capacity. In addition, it supports node management operations, such as adjusting node specification,
promoting secondary node to primary node, enabling read-only replica, and configuring primary/secondary failover.
You can use node management to efficiently manage instance nodes and locate node exceptions.

Directions
1. Log in to the TencentDB for MongoDB console.
2. In the MongoDB drop-down list on the left sidebar, select Replica Set Instance or Sharded Cluster Instance.
The directions for the two types of instances are similar.
3. Above the Instance List on the right, select the region.
4. In the instance list, find the target instance.
5. Click the Instance ID to enter the Instance Details page and click the Node Management tab.
6. View the mongod and mongos node information.
Mongod NodeParameter

Description

Node ID

Mongod node ID.

Monitoring

Click©2013-2022 Tencent Cloud. All rights reserved.

Page 62 of 257

TencentDB for MongoDB, and you can view the monitoring metrics of the node on the monitoring panel on theright. For more information, see Viewing Monitoring Data.
StatusStatus of the current node.

AZ

AZ of the current node.
Role of the current node.
PRIMARY : Primary node.

Role

SECONDARY : Secondary node.
READONLY : Read-only node.
The priority of a node for being elected as the primary node. The greater the value, thePriority

higher the priority.

HiddenWhether the node is hidden. Default value: false .

Primary/Secondary
Delay (second)
Used Disk SpaceThe latency in syncing data from the primary node to the secondary node in seconds.
The storage usage of the node disk.

Mongos NodeParameter

Description

Node ID

Mongos node ID.
Click

Monitoring, and you can view the monitoring metrics of the node on the monitoring panel on the right.
For more information, see Viewing Monitoring Data.
StatusStatus of the node.

AZ

AZ of the mongos node.

©2013-2022 Tencent Cloud. All rights reserved.

Page 63 of 257

TencentDB for MongoDB

Adjusting Mongod Node Specification：

Last updated 2024-05-06 11:52:34

Overview
If your purchased TencentDB for MongoDB instance is over-provisioned or under-provisioned, your business needs
cannot be best met, and you can quickly adjust its specifications as needed (at the start, during rapid development, or
during peak/off-peak hours), so you can get the most out of your resources and reduce unnecessary costs in real time.
You can change the computing specification and disk capacity for mongod nodes. In order to choose thespecifications that best suit your needs, we recommend that you first check TencentDB Product Specifications before
making a choice.

Billing Overview
The instance will be billed by the new specifications after its specifications are changed. Make sure that your Tencent
Cloud account balance is sufficient to cover the updated billing. For more information, see Specification Adjustment
Billing.

Prerequisites
You have created a TencentDB for MongoDB instance. For more information, see Creating TencentDB for MongoDB
Instance.
If your instance is pay-as-you-go, make sure that your Tencent Cloud account balance is sufficient.
The instance and its associated instances are in Running status and and there are currently no tasks being executed.

How Expansion Works and Impacts
If there are sufficient physical machine resources where the node resides, the storage space will be expanded in thisnode. This expansion process does not require any migration or switching between nodes, ensuring uninterrupted
connections..
If there are insufficient physical machine resources where the node resides, expanding the storage space will requirecross-node data migration. After the expansion task is initiated, the system will create nodes and sync data as
required by new specifications, and perform the switch as scheduled. As a momentary disconnection of about 10s will
occur during the switch, we recommend that you include the reconnection mechanism in your business code and©2013-2022 Tencent Cloud. All rights reserved.

Page 64 of 257

TencentDB for MongoDB

perform the adjustment during off-peak hours. The higher volume of data, the longer time it takes to complete theconfiguration adjustment.

：

Note

After the scaling operation is executed, the system will re-trigger a new automatic backup task.

Notes
During adjustment, there may be one or two momentary disconnections for about 10s each. We recommend that you
configure an automatic reconnection feature for your application.
During adjustment, if you set the write concern level to write majority, there may be a short request delay; therefore, itis advisable to set an appropriate business timeout period.
The name, private network address, and port of the instance remain unchanged after specification adjustment.
A started specification adjustment task cannot be canceled.
After the instance is upgraded, we recommend that you adjust the Oplog capacity to avoid having a small Oplog size.
This is important to prevent data overwriting, which could potentially impact the rollback feature of MongoDB. For
more information, see Adjusting Oplog Capacity.

Directions
1. Log in to the TencentDB for MongoDB console.
2. In the MongoDB drop-down list on the left sidebar, select Replica Set Instance or Sharded Cluster Instance.
The directions for the two types of instances are similar.
3. Above the Instance List on the right, select the region.
4. In the instance list, find the target instance.
5. In the Operation column of the target instance, select Adjust Configuration in the drop-down list.
6. On the Adjust Configuration page, you can adjust the node memory and total node capacity.

©2013-2022 Tencent Cloud. All rights reserved.

Page 65 of 257

TencentDB for MongoDB

Parameter

Description

Instance

The name of the instance that requires specificationNameadjustment.

Exampletest-4dot2-XXX
A sharded cluster instance

Instance
Architecture

The description of the instance's cluster architecture. For
more information, see System Architecture.

has two shards, and eachshard consists of threestorage nodes to form areplica set. Hence, theentire instance has six
storage nodes in total.

The mongod node memory and total capacity per node in the
NodeMemory/Total

current instance. For a sharded cluster, the total nodecapacity is the node capacity per shard. For how to query the

Capacity

number of CPU cores of an instance, see the mongod
specifications in Product Specifications.

Node
MemoryTotal Node
Capacity

4 GB/100 GB MEM

Select the new memory per mongod node in the drop-downlist. For how to choose a specification, see the mongod
specifications in Product Specifications.

8 GB MEM

Adjust the total disk capacity per mongod node on the slider,which is the same as the total capacity of the current node by

500 GB MEM©2013-2022 Tencent Cloud. All rights reserved.

Page 66 of 257

TencentDB for MongoDB

default. For how to choose a specification, see the mongod
specifications in Product Specifications.
If you select Upon modification completion, the instancespecification adjustment task will be executed immediately.
Instance memory and disk adjustment may involve node
Switch TimeFees

migration or primary-secondary switch. As the switch time isuncontrollable, disconnection or restart may occur.
If you select During maintenance period, the task will be
executed during the maintenance period. For more
information, see Setting Instance Maintenance Period.
Pay-as-you-go: Hourly unit price after instance specification
adjustment. You can click Billing Details to view the billable
items and billing formula and confirm the fees.

During maintenance period

177.991 USD

7. After confirming that everything is correct, click Submit.

Related APIs
API Name

Description

ModifyDBInstanceSpec

Adjusts the specifications of a TencentDB instance©2013-2022 Tencent Cloud. All rights reserved.

Page 67 of 257

TencentDB for MongoDB

Adding Secondary Node：

Last updated 2024-04-02 15:54:16

Overview
All secondary nodes of an instance contribute to the system's high availability. When the primary node fails, eachsecondary node may be elected as the new primary node to execute data write requests. Therefore, the more thereplicas, the higher the availability. In scenarios with a high number of concurrent requests with more reads and lesswrites, if read/write separation is enabled, you can add secondary nodes to improve the read performance and greatly
relieve the read pressure on the primary node.
A TencentDB for MongoDB cluster can have three (one-primary-two-secondary), five (one-primary-four-secondary), or
seven (one-primary-six-secondary) nodes in total. You can add secondary nodes appropriately based on the surge inthe concurrent requests to your business and remove secondary nodes when the business load drops. This helps you
better utilize resources and reduce unnecessary costs in real time.

Billing
The instance will be billed by the new specifications after its specifications are changed. Make sure that your Tencent
Cloud account balance is sufficient to cover the updated billing. For more information, see Specification Adjustment
Billing.

Notes
After new nodes are added to the cluster, data sync will start without affecting the business.
Be sure to plan for disaster recovery. We recommend you initiate a specification adjustment task during themaintenance period. For more information, see Setting Instance Maintenance Period.
Do not adjust the node quantity and node computing/storage specifications at the same time.
After the node quantity is adjusted, billing will start based on the new specification.
The name, private network address, and port of the instance remain unchanged after node quantity adjustment.
A started specification adjustment task cannot be canceled.

Prerequisites
You have created a TencentDB for MongoDB instance.

©2013-2022 Tencent Cloud. All rights reserved.

Page 68 of 257

TencentDB for MongoDB

If your instance is pay-as-you-go, make sure that your Tencent Cloud account balance is sufficient.
The instance and its associated instances are in Running status and and there are currently no tasks being executed.

Adding a secondary node (replica set)
1. Log in to the TencentDB for MongoDB console.
2. In the MongoDB drop-down list on the left sidebar, select Replica Set Instance.
3. Above the instance list on the right, select the region.
4. In the instance list, find the target instance.
5. Click the Instance ID to enter the Instance Details page and click the Node Management tab.
6. On the Mongod Node tab on the Node Management tab, click Add Secondary Node.
7. In the Adjust Node Quantity pop-up window, read the notes on node quantity adjustment, and proceed to confirm
and configure the parameters as detailed below:

Parameter

Description

Instance
ID/NameThe name of the instance that requires node quantity adjustment.

Instance

Check the current specification of the instance, including the CPU core quantity, memory,©2013-2022 Tencent Cloud. All rights reserved.

Page 69 of 257

TencentDB for MongoDB

Specification

disk capacity, and node quantity. The node quantity includes all primary and secondary
nodes. You should determine the number of nodes to be added based on the current
specification.

Add Node

Select the number of secondary nodes to be added from the drop-down list.

Deployment AZThis parameter will be displayed if the instance nodes are in the same AZ. It indicates theAZ where all instance nodes are deployed.

Secondary NodenThis parameter will be displayed if the instance nodes are in different AZs. It indicates theAZs of different nodes and ranges from 0 to 6. Select the AZs for the new secondary nodes
from the drop-down list.

Fees

Pay-as-you-go: Hourly unit price after instance speciation adjustment. You can click Billing
Details to view the billable items and billing formula and confirm the fees.For more
information, see Specification Adjustment Billing.

8. Confirm the fees and click OK.
9. On the left sidebar, select Task Management, and you can view the ongoing task. Wait until Task Progress
becomes 100% and Task Status becomes Completed.

Increasing the node quantity per shard (for sharded cluster instance)
1. Log in to the TencentDB for MongoDB console.
2. In the MongoDB drop-down list on the left sidebar, select Sharded Cluster Instance.
3. Above the instance list on the right, select the region.
4. In the instance list, find the target instance.
5. Click the Instance ID to enter the Instance Details page and click the Node Management tab.
6. On the Mongod Node tab on the Node Management tab, click Add Secondary Node.
7. In the Adjust Node Quantity per Shard pop-up window, read the notes on node quantity adjustment, and proceed toconfirm and configure the parameters as detailed below:
The instance nodes are deployed in the same AZ:©2013-2022 Tencent Cloud. All rights reserved.

Page 70 of 257

TencentDB for MongoDB

The instance nodes are deployed in different AZs:

©2013-2022 Tencent Cloud. All rights reserved.

Page 71 of 257

TencentDB for MongoDB

Parameter

Description

Instance ID/Name

Confirm the name of the instance that requires node quantity per shard
adjustment.
Check the current specification of the instance, including the CPU core

Instance Specification

quantity, memory, disk capacity, and node quantity. The node quantity includes
all primary and secondary nodes. The nodes are evenly distributed to shards;
for example, if there are two shards and eight nodes, each shard will have four
nodes. You should determine the number of nodes to be added based on thecurrent specification.

Add Node

Select the number of secondary nodes to be added per shard from the dropdown list.

Deployment AZThis parameter will be displayed if the instance nodes are in the same AZ. It
indicates the AZ where all instance nodes are deployed.

©2013-2022 Tencent Cloud. All rights reserved.

Page 72 of 257

TencentDB for MongoDB

Secondary Node-nThis parameter will be displayed if the instance shard nodes are in different
AZs. It indicates the AZs of different nodes and ranges from 0 to 6. Select theAZs for the new secondary nodes from the drop-down list.

Fees

Pay-as-you-go: Hourly unit price after instance speciation adjustment. You canclick Billing Details to view the billable items and billing formula and confirm thefees.

8. Conform the fees and click OK.
9. On the left sidebar, select Task Management, and you can view the ongoing task. Wait until Task Progress
becomes 100% and Task Status becomes Completed.

Related APIsAPI

Description

ModifyDBInstanceSpec

Adjust the specification of a TencentDB instance©2013-2022 Tencent Cloud. All rights reserved.

Page 73 of 257

TencentDB for MongoDB

Deleting Secondary Node：

Last updated 2024-04-02 15:44:10

Overview
Deleting secondary nodes can reduce the high availability of a cluster. When the business load is low, you can remove
secondary nodes appropriately to avoid wasting resources.

Instructions
Deleting secondary nodes can reduce the high availability of a cluster. Therefore, proceed with caution. Make surethat after some secondary nodes are deleted, the cluster still has three (one-primary-two-secondary), five (oneprimary-four-secondary), or seven (one-primary-six-secondary) nodes in total.
A hidden node cannot be deleted, as when a secondary node fails, the system will automatically switch it with thehidden node to guarantee the cluster's high availability.
The IP address of a deleted secondary node won't be retained, so connections to the secondary node will be closed.

Prerequisites
You have created a TencentDB for MongoDB instance.
If your instance is pay-as-you-go, make sure that your Tencent Cloud account balance is sufficient.
The instance and its associated instances are in Running status and and there are currently no tasks being executed.

Deleting a secondary node (replica set)
1. Log in to the TencentDB for MongoDB console.
2. In the MongoDB drop-down list on the left sidebar, select Replica Set Instance.
3. Above the instance list on the right, select the region.
4. In the instance list, find the target instance.
5. Click the Instance ID to enter the Instance Details page and click the Node Management tab.
6. On the Mongod Node tab on the Node Management tab, select the target secondary node in the Instance Listand select Operation > Delete Secondary Node.
Note:
In the node list, if the value of a node in the Hidden column is true, the node is hidden and cannot be deleted.

©2013-2022 Tencent Cloud. All rights reserved.

Page 74 of 257

TencentDB for MongoDB

7. In the Delete Secondary Node pop-up window, read the notes on node quantity adjustment and confirm theinstance name.
Parameter

Description

Instance
ID/NameThe name of the instance that requires node quantity adjustment.

Instance
Specification

Check the current specification of the instance, including the CPU core quantity, memory,disk capacity, and node quantity. The node quantity includes all primary and secondary
nodes. The nodes are evenly distributed to shards; for example, if there are two shards andeight nodes, each shard will have four nodes. You should determine the number of nodes
to be deleted based on the current specification.

Secondary Node
Information

Confirm the information of the secondary nodes to be deleted, including the node ID, AZ,
role, and tags.

Specification
Change Fees

Fees after specification adjustment. In pay-as-you-go billing mode, fees are charged hourly
by the new specification in three billing tiers.

CompareYou can compare the specifications and maximum numbers of connections before andafter the specification adjustment of mongod secondary nodes in order to assess whether
the new specification meets your needs.

Related APIsAPI

Description

ModifyDBInstanceSpec

Adjust the specification of a TencentDB instance©2013-2022 Tencent Cloud. All rights reserved.

Page 75 of 257

TencentDB for MongoDB

Adding Read-Only Node：

Last updated 2024-06-25 11:19:53

Overview
When your business has a massive number of read requests, the primary and secondary database nodes may
struggle to handle them, causing high latency, slow response, and severely dropped throughput. To solve thisproblem, TencentDB for MongoDB provides read-only nodes with an independent connection address, allowing data
to be synced from a primary or secondary node with the lowest latency through oplog. You can create one or multiple
read-only nodes to implement read/write separation and relieve the access pressure on the primary and secondary
nodes.
Two or more nodes can implement load balancing for read requests and guarantee a high availability; that is, when aread-only node fails, the system will automatically switch it with a hidden node. If automatic switch isn't performed, you
can switch the node on the Node Management tab, and the connection address to the node will remain unchanged.
You can directly get the connection string in the Network section on the Instance Details page.
If a read-only node isn't in the candidate list of the primary node, it won't be elected as the primary node or participate
in the election.

Version Description
TencentDB for MongoDB versions 4.0, 4.2, 4.4, 5.0 and 6.0 support adding read-only nodes, while v3.6 doesn't.

Directions
1. Log in to the TencentDB for MongoDB console.
2. In the MongoDB drop-down list on the left sidebar, select Replica Set Instance or Sharded Instance. The
directions for replica set instances and sharded instances are similar.
3. Above the Instance List on the right, select the region.
4. In the instance list, find the target instance.
5. Click the Instance ID to enter the Instance Details page and click the Node Management tab.
6. On the Mongod Node tab, click Add Read-only Node.

©2013-2022 Tencent Cloud. All rights reserved.

Page 76 of 257

TencentDB for MongoDB

Parameter

Description

Instance
Specification

Check the current specification of the instance, including the CPU core quantity, memory,disk capacity, total node quantity, and read-only node quantity to evaluate the number ofread-only nodes to be added.

Add Read-OnlyNode

The number of new read-only nodes. Value range: 0–5.

AZ

The AZ where all read-only nodes are deployed. This parameter will be displayed if theinstance nodes are in the same AZ.

CompareCompare the specifications before and after adding the read-only node to evaluate whether
the new specification meets your needs.
The specification of a replica set instance includes mongod specification, disk capacity,
number of read-only nodes, and maximum number of connections.
The specification of a sharded cluster instance includes number of shards, mongod
specification, disk capacity, number of read-only nodes, and maximum number ofconnections.

Total Fees

Pay-as-you-go: Hourly unit price after instance speciation adjustment. You can click
Billing Details to view the billable items and billing formula and confirm the fees.

©2013-2022 Tencent Cloud. All rights reserved.

Page 77 of 257

TencentDB for MongoDB

7. Click OK.
8. On the left sidebar, select Task Management. In the task list, find the instance by ID or name and wait until the
Task Status for adding the read-only node is marked as Completed.

©2013-2022 Tencent Cloud. All rights reserved.

Page 78 of 257

TencentDB for MongoDB

Adjusting Shard Quantity：

Last updated 2024-04-02 15:33:32

Overview
You can adjust the shard quantity after purchasing a sharded cluster instance to adapt to your changing businessscenarios.

Billing
The instance will be billed by the new specifications after its specifications are changed. Make sure that your Tencent
Cloud account balance is sufficient to cover the updated billing. For more information, see Specification Adjustment
Billing.

Note
After new nodes are added to the cluster, data sync will start without affecting the business.
Do not adjust the node quantity and node computing/storage specifications at the same time.
After the node quantity is adjusted, billing will start based on the new specification.
The name, private network address, and port of the instance remain unchanged after node quantity adjustment.
A started specification adjustment task cannot be canceled.

Prerequisites
You have created a TencentDB for MongoDB instance. For more information, see Creating TencentDB for MongoDB
Instance.
If your instance is pay-as-you-go, make sure that your Tencent Cloud account balance is sufficient.
The sharded cluster instance and its associated instances are in Running status and there are currently no tasks
being executed.

Directions
1. Log in to the TencentDB for MongoDB console.

©2013-2022 Tencent Cloud. All rights reserved.

Page 79 of 257

TencentDB for MongoDB

2. In the MongoDB drop-down list on the left sidebar, select Sharded Cluster Instance.
3. Above the Instance List on the right, select the region.
4. In the instance list, find the target instance.
5. Click the Instance ID to enter the Instance Details page and click the Node Management tab.
6. On the Mongod Node tab on the Node Management tab, click Adjust Shard Quantity.
7. In the Adjust Shard Quantity window, read the notes on shard quantity adjustment, specify the new number ofshards as describe below, and confirm the fees.

Parameter

Description

ExampleInstance
Name

The name of the instance that requires node quantity
adjustment.

test-4dot2-XXX

The expiration time of the instance (for billing purpose).

2022-04-24 19:23:43

Instance
Architecture

The description of the instance's cluster architecture. For more
information, see System Architecture.

Sharded cluster instancewith two shards and fivestorage nodes per shard

Node

The shard node specification information of the current sharded

2 cores, 4 GB memory,

ExpirationTime©2013-2022 Tencent Cloud. All rights reserved.

Page 80 of 257

TencentDB for MongoDB

Specification

cluster instance, including the number of CPU cores, memory,storage capacity, and node quantity.

250 GB storage, 10
nodes in total

Add Shard

Select the number of shards to be added to the instance. Value
range: [1,36].

3

Fees

Pay-as-you-go: Hourly unit price after instance speciation
adjustment. You can click Billing Details to view the billable
items and billing formula and confirm the fees.
For billing details after the configuration adjustment, see
Configuration Adjustment Billing.

0.99 USD/hour

8. After confirming that everything is correct, click OK.

Related APIs
API Name

Description

ModifyDBInstanceSpec

Adjust the specification of a TencentDB instance©2013-2022 Tencent Cloud. All rights reserved.

Page 81 of 257

TencentDB for MongoDB

Adjusting Mongos Node Specification：

Last updated 2024-04-02 15:19:28

Overview
Upgrading the computing specification of mongos nodes can increase the maximum number of connections to the
database. You can adjust the mongos node specification appropriately based on the actual conditions of yourbusiness access.

Notes
Upgrading the CPU performance and memory capacity of mongos nodes may involve cross-node data migration andcause a momentary disconnection. Therefore, before performing this operation, make sure that your business has an
automatic reconnection mechanism. We recommend that you complete this operation within the maintenance time
during off-peak hours.

Version requirements
TencentDB for MongoDB 4.0, 4.2 and 4.4 support adjusting the mongos node specification.

Prerequisites
Instance type: Sharded cluster instance.
Instance status: Running.
The CPU performance and memory capacity of the mongos nodes are insufficient and need to be upgraded.

Directions
1. Log in to the TencentDB for MongoDB console.
2. In the MongoDB drop-down list on the left sidebar, select Sharded Cluster Instance.
3. Above the Instance List on the right, select the region.
4. In the Instance List, find the target instance.
5. Click the Instance ID to enter the Instance Details page and click the Node Management tab.

©2013-2022 Tencent Cloud. All rights reserved.

Page 82 of 257

TencentDB for MongoDB

6. On the Node Management tab, click the Mongos Node tab.
7. On the Mongos Node tab, click Change Mongos Specification. In the pop-up window, configure the new
specification.
Parameter

Description

Instance ID/Name

The unique ID and name of the instance.

AZ

The AZ where the instance resides.

Mongos Quantity

The current number of mongos nodes.

Mongos Specs

Select the new mongos node specification in the drop-down list, which
can be 1-core 2 GB MEM, 2-core 4 GB MEM, 4-core 8 GB MEM, 8core 16 GB MEM, or 16-core 32 GB MEM.

Switch TimeIf you select Upon modification completion, the instance specification
adjustment task will be executed immediately. Instance memory andcapacity adjustment may involve node migration or primary-secondary
switch. As the switch time point is uncontrollable, disconnection orrestart may occur.
If you select During maintenance period, the task will be executedduring the maintenance period. For more information, see Setting
Instance Maintenance Period.

Specification Change Fees

Fees after specification adjustment. In pay-as-you-go billing mode, fees
are charged hourly by the new specification in three billing tiers.

CompareYou can compare the maximum number of connections before and after
the mongos specification adjustment to evaluate whether the new
specification meets your needs.

8. Click OK.

©2013-2022 Tencent Cloud. All rights reserved.

Page 83 of 257

TencentDB for MongoDB

Adding Mongos Node：

Last updated 2024-04-02 15:13:12

Overview
You can add more mongos nodes to increase the maximum number of connections to the database instance.

Version requirements
Currently, sharded cluster instances on v4.0, v4.2 and v4.4 support adding mongos nodes.

Instructions
After you add a mongos node, the system will automatically bind an IP address to it and enable the connection string
for mongos access. Then, you can directly copy the connection string in the Network section on the Instance Details
page.

Prerequisites
Instance type: Sharded cluster instance.
Instance status: Running.
The CPU performance and memory capacity of the mongos nodes are insufficient and need to be upgraded.

Directions
1. Log in to the TencentDB for MongoDB console.
2. In the MongoDB drop-down list on the left sidebar, select Sharded Cluster Instance.
3. Above the Instance List on the right, select the region.
4. In the Instance List, find the target instance.
5. Click the Instance ID to enter the Instance Details page and click the Node Management tab.
6. On the Node Management tab, click the Mongos Node tab.
7. On the Mongos Node tab, click Add Mongos NodeThe instance nodes are in the same AZ:©2013-2022 Tencent Cloud. All rights reserved.

Page 84 of 257

TencentDB for MongoDB

The instance nodes are in different AZs:

©2013-2022 Tencent Cloud. All rights reserved.

Page 85 of 257

TencentDB for MongoDB

Parameter

Description

Instance ID/Name

The unique ID and name of the instance.

AZ

The AZ where the instance resides. This parameter will be displayed if theinstance nodes are in the same AZ.

Mongos Quantity

The current number of mongos nodes configured for the instance. Thisparameter will be displayed if the instance nodes are in the same AZ.

Mongos Specs

Specification of mongos nodes, including the number of CPU cores, memory,and maximum number of connections.

Add Mongos NodeSelect the number of mongos nodes to be added. An instance can have up to 48
mongos nodes.

Total Fees

Fees after specification adjustment.
In pay-as-you-go billing mode, fees are charged hourly by the new specificationin three billing tiers.

CompareYou can compare the specification, number of nodes in the AZ, and maximum
numbers of connections before and after mongos nodes are added to assess©2013-2022 Tencent Cloud. All rights reserved.

Page 86 of 257

TencentDB for MongoDB

whether the new specification meets your needs.

8. After confirming that everything is correct, click OK.

©2013-2022 Tencent Cloud. All rights reserved.

Page 87 of 257

TencentDB for MongoDB

Enabling Mongos Access Address：

Last updated 2024-04-02 15:11:11

Overview
After enabling the mongos access address of a sharded cluster instance, you can access the instance using thisaddress. On the Instance Details page, you can see the mongos access connection string (for private network
access).

Instructions
Under the current VIP of the instance, different vports will be bound to different mongos nodes.
After a mongos node fails, the system will bind its vPort to a new mongos process. The VIP and vPort will remainunchanged.
Enabling mongos access address won't affect the original CLB access address.

Version description
TencentDB for MongoDB v4.0 and later support enabling the mongos access address.

Prerequisites
Instance type: Sharded cluster instance.
Instance status: Running.

Directions
1. Log in to the TencentDB for MongoDB console.
2. In the MongoDB drop-down list on the left sidebar, select Sharded Cluster Instance.
3. Above the Instance List on the right, select the region.
4. In the instance list, find the target instance.
5. Click the Instance ID to enter the Instance Details page and click the Node Management tab.
6. On the Node Management tab, click the Mongos Node tab.

©2013-2022 Tencent Cloud. All rights reserved.

Page 88 of 257

TencentDB for MongoDB

7. On the Mongos Node tab, click Enabling Mongos Access Address.
8. In the pop-up window, confirm the impact of enabling the access connection string and click OK.

9. On the left sidebar, select Task Management. In the task list, find the instance with the Task Type being
Enabling Node Access Address by ID and wait until the Task Status is marked as Completed.
10. On the left sidebar, select Sharded Cluster Instance. In the instance list, find the instance with the accessaddress enabled, click its ID to enter the Instance Details page. In Access Address in the Network Configuration
section, you can view the mongos access address. Hover over the connection string of the access address and click

to copy it for mongos node access.

©2013-2022 Tencent Cloud. All rights reserved.

Page 89 of 257

TencentDB for MongoDB

Promoting Secondary Node to Primary Node：

Last updated 2024-04-02 15:05:25

Overview
A TencentDB for MongoDB replica set instance can have one primary node and multiple secondary nodes. If you findthat the primary node is abnormal, you can actively promote a secondary node to primary node to ensure normal
business operations. In a sharded cluster instance, all shard nodes are grouped into one primary node group, and all
secondary nodes are grouped into multiple secondary node groups. If some shard nodes in the primary node groupare abnormal, you can actively promote all nodes in a secondary node group to the primary node group.

Version description
TencentDB for MongoDB v3.6 and later support promoting secondary node to primary node.

Notes
When a node is promoted to primary node, existing TCP connections to the database will be closed. Therefore, before
performing this operation, make sure that your business has an automatic reconnection mechanism; otherwise, youneed to manually reconnect to the database.

Prerequisites
The instance is in Running status.

Directions
1. Log in to the TencentDB for MongoDB console.
2. In the MongoDB drop-down list on the left sidebar, select Replica Set Instance or Sharded Cluster Instance.
The directions for the two types of instances are similar.
3. Above the Instance List on the right, select the region.
4. In the instance list, find the target instance.
5. Click the Instance ID to enter the Instance Details page and click the Node Management tab.

©2013-2022 Tencent Cloud. All rights reserved.

Page 90 of 257

TencentDB for MongoDB

6. On the Mongod Node tab on the Node Management tab, find the target secondary node in the node list.
Replica set instance: In the node list, find the target secondary node and click Promote to Primary Node in the
Operation column.

Sharded cluster instance: In the node list, find the target secondary node group and click Promote to Primary Nodein the top-right corner.

7. In the Promote to Primary Node window, select Confirm the risk of the promotion to primary node and click
OK.
Note:
When a node is promoted to primary node, existing TCP connections to the database will be closed. Therefore, before
performing this operation, make sure that your business has an automatic reconnection mechanism; otherwise, youneed to manually reconnect to the database.
8. Return to the Instance Details page, you can see that Instance Status is Promoting to Primary Node. After
this status disappears, the task is completed. On the Node Management tab, you can see that the Role of theoriginal secondary node becomes PRIMARY.

©2013-2022 Tencent Cloud. All rights reserved.

Page 91 of 257

TencentDB for MongoDB

Version Upgrade：

Last updated 2024-05-08 10:46:06

Overview
TencentDB for MongoDB allows you to upgrade both the major and minor database versions. You can enjoy morefeatures by upgrading the major version from v3.6 to v4.0 or from v4.0 to v4.2.

Version Description
TencentDB for MongoDB supports upgrades from older versions to higher versions, but does not support crossversion upgrades. You can only upgrade the MongoDB from v3.6 to v4.0, v4.0 to v4.2, v4.2 to v4.4, or v4.4 to v5.0. For
the feature differences between versions, see Storage Engine and Version.
You can also upgrade the minor version, for example, the minor version WT.40.3.34 of the major version 4.0.
During minor version upgrade, the system will automatically detect the minor version and upgrade to the latest version,and you cannot select a target version.
Note:
You can implement the upgrade of major version from v3.2 to v4.0 through data migration. For more information, see
Creating Migration Task.

Note
The upgrade process is completely automatic, and there will be several momentary interruptions during the process.
We recommend that you upgrade during off-peak hours.

Prerequisites
The instance is not a read-only or disaster recovery instance.
The instance to be upgraded is in Running status and is not executing any tasks.
The target version is confirmed.

Directions©2013-2022 Tencent Cloud. All rights reserved.

Page 92 of 257

TencentDB for MongoDB

1. Log in to the TencentDB for MongoDB console.
2. In the MongoDB drop-down list on the left sidebar, select Replica Set Instance or Sharded Cluster Instance.
The directions for replica set instances and sharded cluster instances are similar.
3. Above the Instance List on the right, select the region.
4. In the instance list, find the target instance.
5. In the Instance ID/Name column of the target instance, click the instance ID to enter the Instance Details page.
6. In the Specs Info section on the Instance Details page, upgrade the major or minor version of the instance.
If the major version of the instance is 3.6, click Upgrade to v4.0 after Version and Engine to upgrade the version
from v3.6 to v4.0.
If the major version of the instance is 4.0, click Upgrade to v4.2 after Version and Engine to upgrade the version
from v4.0 to v4.2.
Click Upgrade Minor Version to upgrade the minor version to the latest version by default. For more information, see
Version Upgrade.

7. In the Note pop-up window, read the prompt message carefully, confirm the upgrade, and click OK.

©2013-2022 Tencent Cloud. All rights reserved.

Page 93 of 257

TencentDB for MongoDB

Public Network Access
Enabling Public Network Access：

Last updated 2024-07-31 15:14:49
TencentDB for MongoDB supports both private and public network access. This document describes how to configurea public network access address in the console for you to access MongoDB database via the public network. By doingso, you can manage the database more flexibly and conveniently.

Implementation Scheme
TencentDB for MongoDB enables public network access through Cloud Load Balancer (CLB). After a CLB instancelistening port is configured in the TencentDB for MongoDB console, the CLB instance will forward requests to the real
server when its public IP address and port number are accessed over the public networks. The real server then maps
the private and public networks and automatically forwards requests from the public network to the private network
server of MongoDB. For more information about CLB and the real server, see CLB.
As is shown below, public network users access CLB via IP address 192.168.17.6 and port number 80. The real
server of CLB forwards the request to the actual operating environment of MongoDB database where the private
network IP address is 10.0.0.1 and the port number is 27017. In this way, public network users can access the
MongoDB database via CLB.

Use Limits
Before enabling the public network access of the MongoDB database, you need to understand the relevant restrictions
and requirements which involves MongoDB database, CLB, and network to ensure the security and stability of thedatabase. For more information, see the table below.
Category

FeatureDescription

TencentDB for
MongoDB

VersionOnly for MongoDB replica sets or sharded cluster v4.0, v4.4 and v5.0.

Sharded cluster

It only supports binding the default instance access address (CLB
address) to CLB.
Note:©2013-2022 Tencent Cloud. All rights reserved.

Page 94 of 257

TencentDB for MongoDB

The LB address of a MongoDB sharded cluster forwards client requests
to the appropriate Mongos process for processing. For more
information, see System Architecture. The CLB listener will listen to the
LB IP address and port number of the MongoDB sharded cluster.
When a node is added or deleted for the MongoDB replica set, you
Replica set

need to modify the public network IP address and specify the listening
rules for the new node.
Only TencentDB for MongoDB CLB instances under the same VPC can
be bound.

VPC

After enabling the public network access, you can’t modify the network
for the instance. To modify it, you need to disable the public network
access.

Network

You can’t enable the public network access for the MongoDB instance
Security group

unbound to a security group. We recommend that you configure asecurity group to restrict the visiting address. For detailed directions,see Configuring Security Group.

Password-free

Password-free

You can’t enable public network access for the MongoDB instances

authentication

accesswith password-free access enabled.

Instance type

MongoDB instances can’t be bound to the classic CLB instances. For
the differences between CLB (former Application Load Balancer) andclassic CLB, see Instance Types Comparison.
CLB instances fall into shared instances and LCU-supported instances.

CLB

Instance
specifications

A shared instance can support a maximum of 50,000 concurrent
connections per minute, but this may not be enough for some high-spec
MongoDB instances. Therefore, we recommend that you choose LCUsupported instances to meet your needs. For differences between these
two types of instances, see Instance Specifications Comparison.
MongoDB instances do not support binding with CLB instances under
traditional account types. They only support binding with CLB instances

Account Types

Operation
Limitsunder standard account types. To determine the account type and learn
about methods for upgrading account types, see Account Type
Description.
To disable public network access, it is crucial to perform any action

Disabling Public
Network Accessthrough the TencentDB for MongoDB console. Do not attempt tomanually delete listeners created by MongoDB within the CLB or
remove the entire CLB instance. Failure to follow this instruction may
lead to abnormal business connections.

©2013-2022 Tencent Cloud. All rights reserved.

Page 95 of 257

TencentDB for MongoDB

Network

Modifying the number of instance nodes may affect the public network

Changesfunctionality. Therefore, when making such changes, you must update
the public network configuration through the console to maintain
uninterrupted public network connectivity.

Note
After the public network access is disabled, MongoDB will only clear the bound listener and will not release or
repossess the CLB instance. You can purchase or delete a CLB instance in the CLB console.
We recommend that each MongoDB instance be bound to one dedicated CLB instance, after which MongoDB will
manage and maintain the listener. To share a CLB instance with other resources, you need to manage your listenerports well and reserve enough listeners. Otherwise, when a CLB is used by multiple services, the management chaos
may occur.

：

Note

If the public network feature indicates a health check exception in the backend services, please navigate to thecorresponding CLB console to ascertain whether there are any health check risks, or whether the health check source
IP range has been allowed.

Prerequisites
You have created a TencentDB for MongoDB instance on v4.0 or later, and the instance runs normally.
You have created CLB instances in the same VPC as that of the MongoDB instance. For more information, see
Creating CLB Instances.
For more information on downloading a Windows visual tool, see MongoDB Compass Download (GUI).

Directions
Step 1. Enable public network access
1. Log in to the TencentDB for MongoDB console.
2. In the MongoDB drop-down list on the left sidebar, select Replica Set Instance or Sharded Cluster Instance.
The directions for the two types of instances are similar.
3. Above the Instance List on the right, select the region.
4. In the instance list, find the target instance.
In the search box in the top-right corner, you can search for the target instance by instance ID, instance name, private
IP, or tag key.

©2013-2022 Tencent Cloud. All rights reserved.

Page 96 of 257

TencentDB for MongoDB

If you can't find the target instance in the instance list, select Recycle Bin on the left sidebar to check whether it isisolated there due to overdue payments. For more information, see Recycle Bin.
5. In the Instance ID/Name column of the target instance, click the Instance ID to enter the Instance Details page.
6. In the Network Configuration section on the Instance Details page, click Configure CLB Public Network
Access next to Public Network Access.
7. In the Service Authorization pop-up window, click Grant.

8. In the Configure CLB Public Network Access window, select CLB listening instances and configure listening
rules.
a. On the Bind CLB Instance tab, all CLB instances in the same VPC as the current MongoDB instance have been
listed. Select the CLB instance to be bound based on the required bandwidth cap specification. VIP refers to the public
IP address of the CLB instance.

©2013-2022 Tencent Cloud. All rights reserved.

Page 97 of 257

TencentDB for MongoDB

b. Click Next, on the Configure Listening Rules tab, bind the CLB instance and set the listening rules.
If it is a replica set, configure CLB listening port number for MongoDB primary node and secondary node.
If it is a sharded instance, configure a listening port for the private network address.

©2013-2022 Tencent Cloud. All rights reserved.

Page 98 of 257

TencentDB for MongoDB

9. Click OK,and wait for the task to complete. In the Network Configuration section on the Instance Details page,
you can view the connection string of the public network address.

Log in to the CLB console, find the CLB instance bound to MongoDB in the instance list of the instance management
page, click Instance ID to enter the Basic Info tab, select Listener Management tab to view the listener.

Step 2. Configure a security group
After enabling the public network access, you need to configure security group rules for the CLB and its MongoDB
instance timely. By doing so, you can control the access sources to ensure the security of the data access.
1. Log in to the CVM console > Security Group, create a security group, set the inbound rules, and open the client IP
address of mongo-driver and the listening port of your specified MongoDB instance. For detailed directions, see
Creating a Security Group.

©2013-2022 Tencent Cloud. All rights reserved.

Page 99 of 257

TencentDB for MongoDB

2. Log in to the CLB console, find the CLB instance bound to MongoDB in the instance list of the instancemanagement page, click Instance ID to enter the Basic Info tab, and select the Security Group tab.
Click Bind in the Bound Security Groups section, select a created security group in the Configure Security
Group pop-up window, and click OK. For detailed directions, see Configuring CLB Security Group.

3. Log in to the MongoDB console, find the target instance in the instance list, click the Instance ID, select the Data
Security tab, click Configure Security

Group to select the desired security group, and click OK. For detailed

directions, see Configuring Security Group.

Step 3. Connect to a database instance©2013-2022 Tencent Cloud. All rights reserved.

Page 100 of 257

TencentDB for MongoDB

1. Log in to the MongoDB console. In the Network Configuration section on the Instance Details page, In the
Access Address section, copy the connection string of Access Read/Write Primary Node or Only readsecondary node in the Public network access address (connection string) column in the Access Address.

2. Log in to the MongoDB Compass Download (GUI) client, paste the copied public network address connection string
into the URI input box. The password information in the connection string is hidden as *, and you need to manuallyreplace it with the access password of the instance, and click Connect .

3. You can manage the database after the connection is successful.

©2013-2022 Tencent Cloud. All rights reserved.

Page 101 of 257

TencentDB for MongoDB©2013-2022 Tencent Cloud. All rights reserved.

Page 102 of 257

TencentDB for MongoDB

FAQs：

Last updated 2024-04-07 15:11:09
Although TencentDB for MongoDB manages the configuration of public network access uniformly, the public network
access may be interrupted when you separately operate Cloud Load Balancer (CLB). To prevent this, the console willreport some common errors.

Problem 1: CLB instance is mistakenly deleted, leading to the public
network disconnection.
Issue description
The TencentDB for MongoDB console prompts that the CLB instance doesn’t exist, check the instance status in the
console.

Possible cause
After the public network access is enabled, the CLB instance bound to TencentDB for MongoDB was deleted.

Solutions
1. Log in to the CLB console, and create a CLB instance as needed.
2. Log in to the TencentDB for MongoDB console. In the Network Configuration section on the Instance Details
page, click Disable next to Public Network Access to disable the public network access.
3. When it is disabled, click Configure CLB Public Network Access, select the CLB instance, configure thelistening port for it, and enable the public network access again.

Problem 2: The listener doesn’t exist, leading to public network
disconnection.
Issue description
The TencentDB for MongoDB console prompts that the listener doesn’t exist, check the listener status in the console.

Possible cause
After enabling the public network access, you may delete the listener configuration in the CLB console.

Solutions©2013-2022 Tencent Cloud. All rights reserved.

Page 103 of 257

TencentDB for MongoDB

1. Log in to the CLB console. Click Instance ID to enter the details page, select the Listener Management tab tocheck whether the listener is deleted mistakenly.

2. Log in to the TencentDB for MongoDB console. In the Network Configuration section on the Instance Details
page, click Disable next to Public Network Access to disable the public network access.
3. When it is disabled, click Configure CLB Public Network Access, select the CLB instance, configure thelistening port for it again, and enable the public network access.

Problem 3: The number of the CLB listeners is not the same as thatof the MongoDB VIPs, causing the public network to disconnect.
Issue description
The TencentDB for MongoDB console prompts that the number of the CLB listeners is not the same as that of theinstance VIPs. To add nodes or delete the listeners for the current instance, click Modify to configure the rules of the
public network access.

Possible cause
Each CLB listening port has a private network address of the MongoDB instance. When you add nodes for MongoDB
instance as instructed in Adding Secondary Node, the newly added node cannot find the corresponding listener,
causing an access error.

©2013-2022 Tencent Cloud. All rights reserved.

Page 104 of 257

TencentDB for MongoDB

Solutions
Log in to the TencentDB for MongoDB console. In the Network Configuration section on the Instance Details
page, click Modify next to Public Network Access. In the Configure CLB Public Network Access window,
modify the configuration of the public network access.

©2013-2022 Tencent Cloud. All rights reserved.

Page 105 of 257

TencentDB for MongoDB

Problem 4: The CLB listening port is not the same as the one
configured. Check the listening rules of the CLB instance or modify
the public network access rules.
Issue description
The TencentDB for MongoDB console prompts that the CLB listening port is not the same as the one configured.
Check the listening rules of the CLB instance or modify the public network access rules.

Possible cause
You modified the IP port bound to a listener in the CLB console mistakenly, resulting in inconsistency between thelistening port and the one actually configured.

Solutions
Option 1: Log in to the MongoDB console. In the Network Configuration section on the Instance Details page,
click Modify next to Public Network Access. In the Configure CLB Public Network Access window, change theconfigured listening port of the public network to the same as that of the listener.

©2013-2022 Tencent Cloud. All rights reserved.

Page 106 of 257

TencentDB for MongoDB

Option 2: Log in to the MongoDB console. In the Network Configuration section on the Instance Details page,
click Disable next to Public Network Access to disable the public network access. When it is disabled, click
Configure CLB Public Network Access, select the CLB instance, configure the listening port for it again, andenable the public network access.

©2013-2022 Tencent Cloud. All rights reserved.

Page 107 of 257

TencentDB for MongoDB

Monitoring
Monitoring Feature：

Last updated 2023-08-15 17:00:31
The monitoring feature provided by TencentDB for MongoDB allows you to view the real-time monitoring metric dataof instance resources. It collects the monitoring statistics in various forms such as visual chart, table, and dashboard.
In addition, it supports setting alarms and pushing alarm notifications promptly, so that you can stay up to date with
database service exceptions and adjust your business in time to guarantee stable business operations.

Monitoring Granularity
TencentDB for MongoDB currently doesn't allow you to customize the monitoring data collection granularity. The
adaptive policy is as follows:
Time Span

Monitoring Granularity

Retention Period

0–1 day

5 seconds

1 day

0–1 day

1 minute

15 days

0–1 day

5 minutes

31 days

0–1 day

1 hour93 days

0–1 day

1 days

186 days

0–7 days

1 hour93 days

0–7 days

1 day

186 days

7–30 days

1 hour93 days

7–30 days

1 day

186 days

Instance Types for Monitoring
Instance: Primary, read-only, and disaster recovery instances can be monitored, and each instance is provided with aseparate monitoring view.
Node: All mongod and mongos nodes can be monitored, and each node is provided with a separate monitoring view.

©2013-2022 Tencent Cloud. All rights reserved.

Page 108 of 257

TencentDB for MongoDB

Monitoring Metrics
Instances
Dimension

Monitoring
MetricMax CPU
Utilization of

Parametermongod_max_mem_usage

Unit

Metric Description%

Maximum CPU utilization
among all mongod nodes in

Mongodthe cluster.

AverageCPU
Monitoring

Mongod CPU
Utilization

monogd_avg_cpu_usage%

Max CPU
Utilization ofMongosMaximum CPU utilization
monogs_max_cpu_usage%

AverageMongos CPU
Utilization
Max Memory
Utilization ofMemoryMonitoring

Average CPU utilization of all
mongod nodes in the cluster.

among all mongos nodes inthe sharded cluster.
Average CPU utilization of all

monogs_avg_cpu_usage

mongod_max_mem_usage%%

mongos nodes in the sharded
cluster.
Maximum memory utilization
among all mongod nodes in

Mongodthe cluster.

Average
MemoryAverage memory utilization of

Utilization ofMongodMax Memory
Utilization ofmongod_avg_mem_usage%

mongos_max_mem_usage%

all mongod nodes in thecluster.
Maximum memory utilization
among all mongos nodes in

Mongosthe sharded cluster.

Average
MemoryAverage memory utilization of

Utilization ofMongosDisk

Storage Space

Monitoring

Utilization

Network
Monitoring

Connections

mongos_avg_mem_usage%

all mongos nodes in thesharded cluster.

disk_usage%

space to the disk space
applied for.

cluster_conn

Pcs

Number of TCP connections
to the instance.

Proportion of the used disk©2013-2022 Tencent Cloud. All rights reserved.

Page 109 of 257

TencentDB for MongoDB

connper%

Inbound Trafficcluster_view

Bytes

cluster_netout

Bytes

avg_all_request_delayms

avg_update_delay

ms

Average
Insertion Delay

avg_insert_delay

ms

Average latency of insertion
requests in the cluster.

Average Read
Latency

avg_read_delay

ms

Average latency of readrequests in the cluster.

avg_aggregate_delay

ms

Average latency of aggregate
requests in the cluster.

avg_count_delayms

avg_getmore_delayms

avg_delete_delayms

OutboundTraffic
Latency
Monitoring

Proportion of current

Connection
Percentage

Average
Latency of All
Requests
AverageUpdate Delayconnections to the maximum
connections.
Number of bytes in the traffic
inbound to the cluster.
Number of bytes in the traffic
outbound from the cluster.
Average execution latency of
all requests in the cluster.
Average latency of update
requests in the cluster.

Average
Latency ofAggregate
Requests
Average Count
Delay
Average
getMore Delay
Average
Deletion Delay

Average latency of countrequests in the cluster.
Average latency of getMore
requests in the cluster.
Average latency of deletion
requests in the cluster.
Average latency of command

Average
Commandavg_command_delayms

Latency

requests in the cluster otherthan INSERT, UPDATE,
DELETE, and QUERY
requests.
Number of requests with an

10–50 ms

10 ms©2013-2022 Tencent Cloud. All rights reserved.

-

execution time between 10
and 50 ms.

Page 110 of 257

TencentDB for MongoDB

50–100 ms

50 ms

-

Number of requests with an
execution time between 50
and 100 ms.

100 ms

100 ms-Number of requests with an
execution time of more than
100 ms.

Total
Requests

InsertRequests

Read
Requests

UpdateRequests

Deletion
RequestMonitoring

Requests

Count
Requests

getMoreRequests

Aggregate
Requests

success_per_second

Counts/sec

Number of requests
successfully executed in thecluster per second.
Number of insertion requests

insert_per_second

Counts/sec

executed in the cluster per
second.
Number of read requests

read_per_second

Counts/sec

executed in the cluster per
second.
Number of update requests

update_per_second

delete_per_second

Counts/sec

Counts/sec

executed in the cluster per
second.
Number of deletion requests
executed in the cluster per
second.

count_per_second

Counts/sec

Number of count requests
received by the cluster per
second.
Number of getMore requests

getmore_per_second

Counts/sec

received by the cluster per
second.
Number of aggregate

aggregate_per_second

Counts/sec

requests in the cluster per
second.
Number of command

Command
Requests

RequestTotal requests

command_per_second

Counts/sec

requests received by thecluster per second other than
INSERT, UPDATE, DELETE,
and QUERY requests.

node_success©2013-2022 Tencent Cloud. All rights reserved.

-

Total number of requests inPage 111 of 257

TencentDB for MongoDB

Count

the cluster.
InsertNumber of insertion requests

node_inserts-

node_reads-

UpdateRequests

node_updates-

Number of update requests inthe cluster.

Deletion
Requests

node_deletes-

Number of deletion requests
in the cluster.

node_counts-

node_getmores-

node_aggregates-

Requests
Read
Requests

Count
Requests
getMoreRequests
Aggregate
Requests

received by the cluster.
Number of read requests
received by the cluster.

Number of count requests
received by the cluster.
Number of getMore requests
received by the cluster.
Number of aggregate
requests in the cluster.
Number of command

Command
Requests

node_commands

requests received by thecluster other than INSERT,-UPDATE, DELETE, andQUERY requests.

Mongod node
Dimension

Monitoring MetricParameter

Unit

CPU Utilization

cpuusage%

MemoryMonitoring

Memory Utilization

memusage%

Memory utilization of
the mongod node.

Disk
Monitoring

Used Disk Spacediskusage

MBytesDisk capacity usage ofthe mongod node.

CPU
Monitoring

Metric Description
CPU utilization of themongod node.

Number of writes on
Disk Reads

ioread©2013-2022 Tencent Cloud. All rights reserved.

Counts/sec

the mongod node persecond.

Page 112 of 257

TencentDB for MongoDB

Disk Writes

iowriteCounts/sec

Number of writes on
the mongod node persecond.

Inbound Traffic

netout

Bytes

Number of bytes in the
traffic inbound to themongod node.

Network
Monitoring

Number of bytes in the
Outbound Traffic

netin

Bytes

traffic outbound fromthe mongod node.

AverageRequestLatency

Average Latency of
All Requests

Average latency of all
node_avg_all_requests_delay

msrequests received by
the mongod node.

Monitoring
Average Update
Delay

Average Insertion
Delay

Average Read
Latency
Average Latency ofAggregate

Average latency of
node_avg_update_delay

node_avg_insert_delayms

ms

Average getMore
Delay

Average Deletion
Delay

Average Command
Latency

Average latency of
insertion requests on
the mongod node.

node_avg_read_delay

ms

Average latency ofread requests on themongod node.

node_avg_aggregate_delay

ms

Requests
Average Count
Delay

update requests on
the mongod node.

Average latency ofaggregate requests on
the mongod node.
Average latency of

node_avg_count_delay

mscount requests on themongod node.
Average latency of

node_avg_getmore_delay

node_avg_delete_delayms

ms

getMore requests on
the mongos node.
Average latency ofdeletion requests on
the mongod node.

node_avg_command_delay©2013-2022 Tencent Cloud. All rights reserved.

ms

Average latency ofcommand requests on
the mongod node.

Page 113 of 257

TencentDB for MongoDB

10-50 ms

10 ms-

Number of requests
with an execution time
between 10 and 50
ms.

50-100 ms

50 ms

-

Number of requests
with an execution time
between 50 and 100
ms.
Number of requests

100 ms

100 ms-RequestMonitoringwith an execution timeof more than 100 ms.
Total number of

Total Requests

node_success_per_second

Counts/sec

requests on themongod node persecond.
Number of insertion

Insert Requests

node_insert_per_second

Counts/sec

requests on themongod node persecond.

Read Requests

node_read_per_second

Counts/sec

Number of readrequests on themongod node persecond.
Number of update

Update Requests

node_update_per_second

Counts/sec

requests on themongod node persecond.
Number of deletion

Deletion Requests

node_delete_per_second

Counts/sec

Count Requests

node_count_per_second

Counts/sec

getMore Requests

node_getmore_per_second

Counts/sec

requests on themongod node persecond.
Number of countrequests received by
the mongod node persecond.
Number of getMore
requests received by©2013-2022 Tencent Cloud. All rights reserved.

Page 114 of 257

TencentDB for MongoDB

the mongod node persecond.

Aggregate
Requests

node_aggregate_per_second

Counts/sec

Number of aggregate
requests in themongod node persecond.
Number of command

Command
Requests

requests received by
the mongod node per
node_command_per_second

Counts/sec

second other than
INSERT, UPDATE,
DELETE, and QUERY
requests.

KernelMonitoring

Active Write
Requests

Active Read
Requests

Queuing Read
Requests

Queuing Write
Requests

Pieces of Data
Deleted via TTL

Number of active write
ar

aw

-

-

requests on themongod node.
Number of active readrequests on themongod node.

qr-

Length of the client
read request queue on
the mongod node.
Length of the client

qw-

write request queueon the mongod node.
Number of documents

ttl_deleted-deleted through TTL
on the mongod node.
Number of documents

TTL InitiationTimes

ttl_pass

Active Sessions

active_session-

node_oplog_reserved_time

hours

Oplog Retention
Period-deletions from the TTL
collection performedby the backend
process.

©2013-2022 Tencent Cloud. All rights reserved.

Number of active
sessions on the node.
Oplog retention
period.

Page 115 of 257

TencentDB for MongoDB

Primary/Secondary

node_slavedelay

seconds

Delay

Delay time between
the primary andsecondary nodes.

Cache Hit Rate

Cache Utilization(%)

replicaset_node

node_cache_used%%

Cache hit rate of thecurrent cluster.
Percentage of theused cache to the total
cache space.
Percentage of the size

Dirty Data (%) in
Cache

node_cache_dirty%of dirty data in thecache to the total
cache space.

RequestCount

Total requests

node_success-Total number ofrequests in the cluster.

Insert Requests

node_inserts-

Number of insertion
requests in the cluster.

Read Requests

node_reads-

Update Requests

replicaset_node-

Delete Requests

node_deletes-

Number of readrequests in the cluster.
Number of update
requests in the cluster.
Number of deletion
requests in the cluster.
Number of countCount Requests

getMore Requests

node_counts

node_getmores--

requests received by
the cluster.
Number of getMore
requests received by
the cluster.

Aggregate
Requests
Command
Requests

node_aggregates-node_commands-

Number of aggregate
requests in the cluster.
Number of command
requests received by
the cluster other than
INSERT, UPDATE,©2013-2022 Tencent Cloud. All rights reserved.

Page 116 of 257

TencentDB for MongoDB

DELETE, and QUERY
requests.

Mongos node (sharded cluster)Dimension

Monitoring
MetricCPU

CPU

Monitoring

Utilization

MemoryMonitoring

MemoryUtilization
PrivateInbound

Network
Monitoring

Monitoring MetricUnitcpuusage%memusage%

netoutBytes

Traffic
PrivateOutbound

netin

Bytes

Metric Description
CPU utilization of the mongos
node.
Memory utilization of themongos node.
Number of bytes in the traffic
inbound to the mongos node.
Number of bytes in the traffic
outbound from the mongos

Traffic

node.

Latency

Average

Average latency of all

Monitoring

Latency of

node_avg_all_request_delay

msrequests received by the

All Requests

mongos node.

Average

Average latency of update

UpdateDelaynode_avg_update_delay

ms

Average
Insertion
Delay
AverageReadrequests on the mongos
node.
Average latency of insertion

replicaset_node

node_avg_read_delayms

msrequests on the mongos
node.
Average latency of readrequests on the mongos

Latencynode.

Average
Latency of

Average latency of aggregate

Aggregate
Requests
Averagenode_avg_aggregate_delay

msrequests on the mongos
node.

node_avg_count_delay

ms

Average latency of countCount Delay©2013-2022 Tencent Cloud. All rights reserved.

requests on the mongos

Page 117 of 257

TencentDB for MongoDB

node.
Average
getMoreDelay

Average latency of getMore
node_avg_getmore_delay

ms

Average
Deletion
Delay

Average latency of deletion
node_avg_delete_delay

msrequests on the mongos
node.
Average latency of command
requests on the mongos node

Average
Command
Latency

requests on the mongos
node.

node_avg_command_delay

msother than INSERT,UPDATE, DELETE, andQUERY requests.

10-50 ms

10 ms-

Number of requests per
second with an execution
time between 10 and 50 ms.
Number of requests per

50-100 ms

50 ms

-

second with an execution
time between 50 and 100 ms.
Number of requests per

100 msRequestTotal

Monitoring

Requests
InsertRequests

100 ms-qps

Counts/sec

second with an execution
time of more than 100 ms.
Total number of requests on
the mongos node per second.
Number of insertion requests

inserts

Counts/sec

readsCounts/sec

UpdateRequests

updates

Counts/sec

Deletion
Requests

deletes

Counts/sec

on the mongos node persecond.

Count

countsCounts/sec

Number of count requests

Read
Requests

on the mongos node persecond.
Number of read requests on
the mongos node per second.
Number of update requests
on the mongos node persecond.
Number of deletion requests

Requests©2013-2022 Tencent Cloud. All rights reserved.

received by the mongos node

Page 118 of 257

TencentDB for MongoDB

per second.
getMoreRequests

Aggregate
Requests

getmores

Counts/sec

Number of getMore requests
received by the mongos node
per second.
Number of aggregate

aggregatesCounts/sec

requests in the mongos node
per second.
Number of command

Command
Requests

commands

Counts/sec

requests received by themongos node per second
other than INSERT,UPDATE, DELETE, andQUERY requests.

Request
Count

Total
requests

InsertRequests

Read
Requests

UpdateRequests

DeleteRequests

Count
Requests

node_success-Total number of requests
received by the mongos
node.
Number of insertion requests

node_inserts-

received by the mongos
node.
Number of read requests

node_reads-

received by the mongos
node.
Number of update requests

node_updates

node_deletes--received by the mongos
node.
Number of deletion requests
received by the mongos
node.

node_counts-

Number of count requests
received by the mongos
node.
Number of getMore requests

getMoreRequests

node_getmores-

received by the mongos
node.

Aggregate

node_aggregates-

Number of aggregate

Requests©2013-2022 Tencent Cloud. All rights reserved.

requests received by the

Page 119 of 257

TencentDB for MongoDB

mongos node.

Command
Requests

Number of command
requests received by thenode_commands©2013-2022 Tencent Cloud. All rights reserved.

-

mongos node other than
INSERT, UPDATE, DELETE,
and QUERY requests.

Page 120 of 257

TencentDB for MongoDB

Viewing Monitoring Data：

Last updated 2024-04-07 15:19:57
TencentDB for MongoDB allows you to view the change trend of each monitoring metric. This helps you stay up todate with the running status and performance of database resources, so that you can make prejudgments and prevent
risks.

Background
Tencent Cloud Observability Platform (TCOP) is a real-time monitoring and alarming service for Tencent Cloud
resources. It collects the data of various monitoring metrics of Tencent Cloud services and displays the data throughvisual charts, helping you intuitively understand the running status and performance of services.
Note:
Cloud Monitor (CM) was renamed TCOP on February 23, 2023.
In TencentDB for MongoDB, you can use TCOP to create dashboards and various types of charts to compare themetric data of multiple instances. In this way, you can efficiently analyze the changes of monitoring metrics. You canalso use TCOP to configure real-time alarms for exceptions during database operations, allowing you to remove risks
as soon as they arise.

Version description
Currently, all TencentDB for MongoDB versions support instance monitoring.

Billing Overview
Basic TCOP features such as alarming and monitoring data collection are free of charge.
Currently, only alarm SMS messages are billed.

Notes
The monitoring data is retained for 30 days.
After receiving the alarms reported by Tencent Cloud, you need to troubleshoot problems accordingly.

©2013-2022 Tencent Cloud. All rights reserved.

Page 121 of 257

TencentDB for MongoDB

Prerequisites
You have activated TCOP.
You have created a TencentDB for MongoDB instance. For more information, see Creating TencentDB for MongoDB
Instance.

Directions
Quickly viewing instance monitoring data
1. Log in to the TencentDB for MongoDB console.
2. In the MongoDB drop-down list on the left sidebar, select Replica Set Instance or Sharded Cluster Instance.
The directions for the two types of instances are similar.
3. Above the Instance List on the right, select the region.
4. In the instance list, find the target instance.
5. In the Monitoring/Status column of the target instance, click

to open the instance monitoring panel, where you can quickly view the instance monitoring data.
You can select Real-Time, Past 24 Hours, Past 7 Days, or any time period to view the corresponding monitoringdata.
On the Requests, Connections, Capacity and QPS, and Latency tabs, you can view the data of monitoring
metrics in different categories.
In the Time Granularity drop-down list, you can set the time granularity for monitoring data collection to get finergrained data.

©2013-2022 Tencent Cloud. All rights reserved.

Page 122 of 257

TencentDB for MongoDB

Select Compare Monitoring Data of Instances to enter the Dashboard List page in TCOP, create a dashboard,select the instances to be monitored, set the monitoring chart, and then you can compare the monitoring data ofmultiple instances in the same chart.

Click Configure Alarms to enter the Create Alarm Policy page in TCOP, set Policy Type to TencentDB for
MongoDB Instance, select an alarm recipient, set the trigger condition of the monitoring metric, and configure©2013-2022 Tencent Cloud. All rights reserved.

Page 123 of 257

TencentDB for MongoDB

the alarm notification method. In this way, you can stay on top of the business exceptions and prevent risks andfailures promptly. For detailed directions, see Creating Alarm Policy.

Viewing monitoring details
1. In the instance list, find the target instance.
2. Click the target instance ID to enter the Instance Details page.
3. Click the System Monitoring tab to view the change trend of each monitoring metric of the entire cluster as shown
below (with a replica set instance as an example):Viewing monitoring data by monitoring object
Replica set: On the left of the System Monitoring page, select the specific instance name, primary node, andsecondary node under the Cluster Overview to view the monitoring metric data of different monitoring objects.
Sharded instance: On the left of the System Monitoring page, select the specific shard name, primary node, andsecondary node under the Cluster Overview to view the monitoring metric data of different monitoring objects.
Viewing monitoring data for specified time period
In the top-right corner of the System Monitoring page, select Real-Time, Past 24 Hours, Past 7 Days, or any time
period to view the corresponding monitoring data.
Viewing monitoring data at different time granularities
In the top-right corner of the System Monitoring page, select 5 seconds, 1 minute, 5 minutes, or 1 day in thedrop-down list after Time Granularity to view the monitoring data at different time granularities.
Zooming in change trend chart of single metricIn the metric list on the right of the System Monitoring page, find the target metric and click

to zoom in its change trend chart. You can select a time period and set a time granularity to analyze the metric change
trend in a more refined manner.

©2013-2022 Tencent Cloud. All rights reserved.

Page 124 of 257

TencentDB for MongoDB

Exporting monitoring chart
Exporting one metric: In the metric list, select the target metric, click, and select Export as Image to export its change trend chart. You can also select Export Data to view and analyze
the monitoring data with Excel locally.
Batch exporting monitoring data: Click Export Data above the metric list, select the target metrics in the Export Data
window, click Export, and then you can view and analyze the monitoring data with Excel locally.
Setting alarm
In the top-right corner of the instance monitoring page, click Configure Alarms to enter the Create Alarm Policy
page in TCOP, set Policy Type to TencentDB for MongoDB Instance, select an alarm recipient, set the trigger
condition of the monitoring metric, and configure the alarm notification method. In this way, you can stay on top of themetric exceptions and prevent risks and failures promptly. For detailed directions, see Creating Alarm Policy.
Comparing data
In the top-right corner of the instance monitoring page, you can click Data Comparison and set the time period. By
default, the data within the past hour is obtained. The curves of the monitoring metric on today and yesterday within
the specified time range are displayed in different colors.

©2013-2022 Tencent Cloud. All rights reserved.

Page 125 of 257

TencentDB for MongoDB

Configuring Alarm Policy：

Last updated 2024-04-07 15:25:53

Overview
You can configure alarm rules for monitoring metrics to prevent your system operations from being disrupted whenthese metrics reach a certain value. When monitoring data meets the configured conditions, the system can check it
automatically and send alarm notifications to the admin. This allows you to stay on top of business exceptions andsolve them quickly.

Alarming and Monitoring Metrics
TencentDB for MongoDB provides alarm configurations in three dimensions: instance, replica set, and node. You can
set alarm rules for metrics of each dimension. The details are as follows:
Instance: The instance dimension is for the entire MongoDB cluster. It monitors the number of requests, disks,latency, and connections of the entire cluster.
Replica set: Each replica set of TencentDB for MongoDB adopts a one-primary-multiple-secondary architecture, andeach shard of the sharded cluster is also a replica set structure, so the database documents are stored in the replica
set. This dimension is for the architecture of the stored document. It monitors the cache dirty data, cache utilization,
request hit rate, disk utilization, oplog storage time, and primary-secondary delay.
Node: This dimension is for all nodes in the database cluster. It monitors the usage of Mongod and Mongos nodes,
including CPU, memory, disk, inbound and outbound traffic, number of read and write requests, waiting queues, andnumber of connections.

Instance dimension
Monitoring Metric

Unit

Description

Write Requests-

Number of write requests received by the instance.

Read Requests-

Number of read requests received by the instance.

Update Requests-

Number of update requests received by the instance.

Deletion Requests-

Number of deletion requests received by the instance.

Count Requests-

Number of total requests received by the instance.

Aggregate Requests-

Number of aggregate requests received by the instance.

©2013-2022 Tencent Cloud. All rights reserved.

Page 126 of 257

TencentDB for MongoDB

Successfully Executed
Requests-

Disk Utilization%

Requests Consuming 10-50-

ms
Requests Consuming 50-100-

ms
Requests Consuming More-Than 100 ms
Connection Utilization%

Requests per Second-

Command Requests-

Number of Connections-

Number of requests received by the instance that are executed
successfully.
The percentage of the used space to the total space of the current
disk.
Number of requests with an execution time between 10 and 50 ms.
Number of requests with an execution time between 50 and 100
ms.
Number of requests with an execution time of more than 100 ms.
The percentage of current connections to the maximum
connections of the cluster.
Number of requests received by the instance per second.
Number of command requests received by the cluster other than
INSERT, UPDATE, DELETE, and QUERY requests.
Number of TCP connections from cluster clients.

Replica set dimension
Monitoring Metric

Unit

Description

Dirty Data in Cache%

The percentage of data in the current cache that has been modified
but not yet written to disk to the total cache data.

Cache Utilization%

The percentage of the used space to the total space of the current
cache.

Disk Utilization%

The percentage of the used space to the total space of the current
disk.

Cache Hit Rate%

The percentage of requested data that already exists in the cachewhen the system uses the cache.

Oplog Retention Period

hours

Average primary-secondary
delay in Unit Times©2013-2022 Tencent Cloud. All rights reserved.

Oplog is used to record the operation log of the database, and thismetric counts its storage time.
In the replica set architecture, the secondary node periodically polls
the oplog (operation log) of the primary node to replicate the data

Page 127 of 257

TencentDB for MongoDB

from it. This metric counts the primary-secondary delay in data sync.

Node dimension
Monitoring Metric

Unit

Description

CPU Utilization%

The percentage of time the CPU is executing processes to the total
CPU time.

Memory Utilization%

The percentage of the used space in the current memory to the total
memory space.

Inbound Network Traffic

KB/s

Number of bytes per second in the traffic inbound to the node.

Outbound Network Traffic

KB/s

Number of bytes per second in the traffic outbound from the node.

Read Requests in Queue

Pcs

Number of read requests waiting in the queue.

Write Requests in Queue

Pcs

Number of write requests waiting in the queue.

Number of Connections

Pcs

Number of client connections.

Used Disk Space

MB

Used node disk capacity.

WiredTiger Active Reads

Pcs

Number of active read requests in the memory.

WiredTiger Active Writes

Pcs

Number of active write requests in the memory.

Data Entries Deleted via
TTL

Pcs

The number of data entries automatically deleted by the database
after the TTL expires.

TTL Run Times-

The number of times data is checked within the TTL time set in the
database.

Billing Overview
TCOP allows you to configure alarm policies to monitor the key metrics of instances and offers a free trial.
Currently, only alarm SMS messages are charged. For more information, see Purchase Guide.

Prerequisites
You have activated TCOP.
The database instance is in Running status.

©2013-2022 Tencent Cloud. All rights reserved.

Page 128 of 257

TencentDB for MongoDB

You have collected the information of the recipients of alarm notifications, such as email address.

Directions
1. Log in to the TencentDB for MongoDB console.
2. In the MongoDB drop-down list on the left sidebar, select Replica Set Instance or Sharded Cluster Instance.
The directions for replica set instances and sharded cluster instances are similar.
3. Above the Instance List on the right, select the region.
4. In the instance list, find the target instance.
5. In the row of the target instance, enter the Create Policy page of TCOP in any of the following ways:
Clickin the Monitoring/Status column and click Configure Alarms in the top-right corner of the instance monitoring
dashboard.

Click the instance ID in blue to enter the Instance Details page. Then, select the System Monitoring tab and click
Configure Alarms.

©2013-2022 Tencent Cloud. All rights reserved.

Page 129 of 257

TencentDB for MongoDB

6. On the Create alarm policy page, configure a new alarm policy as shown below. For more information on thebasic concepts of alarm policy, see Creating Alarm Policy.

Parameter

Description

PolicyName

Customize the alarm policy name for easier identification.

Remarks

Briefly describe the alarm policy for easier identification.

MonitoringType

Select Cloud Product Monitoring.

©2013-2022 Tencent Cloud. All rights reserved.

Page 130 of 257

TencentDB for MongoDB

PolicyType
Project

Alarm
ObjectTrigger
Condition

Set Policy Type to TencentDB/MongoDB/instance, TencentDB/MongoDB/node, orTencentDB/MongoDB/replica set.
Specify a project for the alarm policy. You can quickly locate all alarm policies of a project in thealarm policy list.
If you select Instance ID, the alarm policy will be bound to the specified database instance.
If you select Instance Group, the alarm policy will be bound to the specified database instancegroup. For more information on how to create an instance group, see Instance Group.
If you select All Objects, the alarm policy will be bound to all instances the current account has
permission on.
If you select Tag, the alarm policy will be bound to all instances associated with the current tag
key and tag value.
Select template: You can select a template file in the drop-down list, and alarms will bereported based on the trigger conditions preset in the template. For specific configurations, see
Configuring Trigger Condition Template.
Configure manually: You need to configure the threshold for triggering an alarm for each
metric in the Metric Alarm section below. Alarm threshold type has the following values:
If you select Static, you can manually set a fixed threshold, and alarms will be triggered when
the threshold is reached.
If you select Dynamic, exceptions will be determined based on the dynamic thresholdboundaries calculated by machine learning algorithms.
For more information, see Creating Alarm Policy.

Alarm
Notification

You can select a preset or custom notification template. Each alarm policy can be bound to
three notification templates at most. For more information, see Alarm Notification.

7. After confirming that the configuration is correct, click Complete. For more information on alarms, see Alarm
Overview.

Related APIs
API Name

Description

CreateAlarmPolicy

Creates an alarm policy in TCOP

©2013-2022 Tencent Cloud. All rights reserved.

Page 131 of 257

TencentDB for MongoDB

Configuring Event Alarms：

Last updated 2024-05-07 12:37:13

Overview
TencentDB for MongoDB has been integrated with Tencent Cloud Observability Platform, supporting the reporting ofTencent Cloud Observability Platform events. All Tencent Cloud Observability Platform events will be automaticallydelivered to Tencent Cloud's EventBridge in the Cloud Service Event Bus. Tencent Cloud Event Bridge (EventBridge)
is a secure, stable, and efficient serverless event management platform. An event is a data record of a status change.
Releasing an event from the event source to EventBridge needs to comply with CloudEvents specifications. For more
information about the specifications, see CloudEvents 1.0.

Event Target
An event rule can have multiple event targets. Before creating an event rule, first plan the event target types. Event
Bridge currently supports the following event targets:
Message Push (only supports rules in the cloud service event bus)
CLS Log﻿Serverless Cloud Function (SCF)﻿
Ckafka﻿TencentDB for MongoDB Event
Event
ChineseName
Insufficient
BackupOplog

Event English Name

oplogInsufficient©2013-2022 Tencent Cloud. All rights reserved.

Event
Type

Subordinate
Dimension

Exception
event

Instance
dimension

RecoveryConcept
Availability
No

Event
Description

Solutio
Sugge

During the
backupprocess ofTencentDB
for
MongoDB, it
is impossible
to read thecomplete
oplog fromthe last
backup tothe current
backup,

It is
recom
to adju
capacof theTence
for Mooplog
frequebacku
the Moconso
specifioperatPage 132 of 257

TencentDB for MongoDB

which will

see Adaffect yourOplogability torollback the

StoragCapacdatabase to
any point
within 7
days.
Increa
maxim
numbe
conne
or restinstanspecifioperatNumber of
Number ofConnections
ExceedingLimitconnectionOverlimit

Exception

Instance

event

dimension

Yes

instance
connections
exceeds the
maximum
limit.

see Sofor Exc
Conne
Limit.
For daperforoptimisee AnandResolu
Metho
Abnor
High
Conne
Usage

PrimaryReplica

primarywitch

SwitchException
event

Instance
dimension

Yes

Instance
primary node

Confirwheth

is abnormal,
andinstanstatusswitchingwith thesecondarynorma

node occurs.
This event
may betriggered incase ofphysical©2013-2022 Tencent Cloud. All rights reserved.

Page 133 of 257

TencentDB for MongoDB

serverfailure.

Disk Space
About toThe disk
space isabout to beinstanceDiskSpaceLow

Run out

Exception
event

Instance
dimension

Yes

filled, which
may causethe instanceto becomeread-only.

Clean
space
specifioperatsee Sofor Hig
Space

Instance
data
rollback.
When somedata on the
primary node
has not beentimelysynchronized
to theInstance
Rollback

instanceRollback

Exception
event

Instance
dimensionYessecondarynode, failureof theprimary nodeconcurrency
leads toConfirwheth
instanstatusnorma

primaryreplica
switch,which maytrigger thisevent.
If any node

Node CPU
Exception

NodeCPUAbnormal

Exception
event

Instance
dimensionYes

in the cluster
reaches 80%
CPU usage,an alarm is

For spoperatsee Sofor Hig

immediately
triggered.

Usage

Billing Overview©2013-2022 Tencent Cloud. All rights reserved.

Page 134 of 257

TencentDB for MongoDB

Tencent Cloud offers EventBridge as a pay-as-you-go service. For more information, see EventBridge > ProductPricing.
Type

Pay-as-You-Go

Payment
MethodSettlement is based on the number of events actually delivered to the event bus, calculated
hourly.

Billing Unit

CNY/Million Events

Usage
Scenario

For applications with low or high fluctuating message volumes, it can effectively avoid
resource waste.

Directions
1. Log in to the EventBridge console. In the left sidebar, choose Event Rule.
2. At the top of the page on the right, under the Region, select Guangzhou, then select Event Set from thedropdown list and select default .
Note:
The cloud service event bus collects Monitor and Audit events generated by Tencent Cloud services across all
regions. It is created by default in Guangzhou and cannot be deleted.
In the left sidebar, choose Event Set. In the Event Set list, click Default to view the default event bus which alreadyincludes TencentDB for MongoDB. For specific operations, see Tencent Cloud Service Event Source.
3. On the Event Rule page, click Create. On the Event Pattern navigation page, configure the page parameters
according to the parameter explanations shown in the following table.
Interface
Area

InterfaceParameter

Parameter Explanation

Basic
Information

RegionThe region where the event rule is created.

Event Bus

Information about the event bus to which the event rule belongs.

Rule Name

Set the name of the event rule. It can only contain letters, numbers,
underscores, hyphens, must start with a letter, and end with a number or
letter, between 2 and 60 characters.

Rule
Description

A brief description of the event rule.

Tag

Set the tag key and value for the event.

Data

Check if data conversion is needed.

Conversion©2013-2022 Tencent Cloud. All rights reserved.

Page 135 of 257

TencentDB for MongoDB

Event
ExampleEvent
Matching

Event
ExampleSelection

In the dropdown list, you can search for MongoDB and view the relevant
examples of MongoDB events.

Writing
Pattern

Form Pattern: This pattern allows you to select cloud service type andevent type, providing event matching rules.
Custom Event: Define event matching rules in the input box below. For rule
writing instructions, click Rule Writing Guidelines.

Cloud
ServiceType

When Writing Pattern is set to Form Pattern, this parameter is shown. In
the dropdown list, select TencentDB for MongoDB.

Event Type

When Writing Pattern is set to Form Pattern, this parameter is displayed. In
the dropdown list, select the supported event types.

Event
Matching
RulePreview

Preview the generated event matching rules.

4. click Test Matching Rules to test the defined event matching rules. After passing the test, click Next. If the test
fails, correct it according to the prompt information.
5. (Optional) If you need to convert the data format, the Event Transformation page is displayed as shown in thefollowing figure. Configure the format and fields for data transformation according to the parameter explanations in thetable below.
Note:
Data conversion offers a simple data processing feature. By the input data and configured items, it can carry out data
formatting, return the processed structured data, distribute to downstream targets, and create a bridge between data
sources and data processing systems.

©2013-2022 Tencent Cloud. All rights reserved.

Page 136 of 257

TencentDB for MongoDB

Interface
Area

InterfaceParameter

Parameter Explanation

Create New
Data
Conversion

Event
Pattern
Preview

By selecting Sample Event, you can use the event template;
By selecting Manually Input, you can define the event fields in the input box
below.

Event
Template

For Event Pattern Preview, select Sample Event to display the parameter.
In the dropdown list, you can search for MongoDB and select a template for
MongoDB events. In the input box below, the specific field information of theevent template will be displayed.
Complete Event: Routes the complete structure of event fields to the event

Conversion
Targettarget.
Partial Event: Event Bridge uses JSONPath configuration to extract event
fields and routes the specified event fields to the event target.

JSONPath

When you select partial events for the conversion target, this parameter isdisplayed. Enter the event fields you wish to convert in the input box.

Parsing

Select a parsing mode. Supports JSON, separators, and regular expression

Modeextraction.

Parsing

Click Confirm after the parsing mode to start parsing data, converting event

Resultrules into a Key-Value format.

©2013-2022 Tencent Cloud. All rights reserved.

Page 137 of 257

TencentDB for MongoDB

Filter
Data
Processing
Test
Results
Dead
LetterQueue
Delivery

Configure the filter to only output data that meets the filter rules.
For the current parsed data, select the data type in the TYPE column.
Click Testing to perform a validity check and output the final conversion
result.
Configure whether to deliver messages that fail to be processed properly to
CKafka's dead letter queue.

The delivery type for failed messages is set to CKafka.

FailureInformation

Type

Handling

CKafkaSelect the instance ID of the CKafka instance to which failed messages will be

Instance

delivered.

CKafkaChoose the topic within the selected CKafka instance to which failed
messages will be delivered. CKafka uses the concept of topics externally.

Topic

Producers write messages to a topic, and consumers read them from it.

6. Click Confirm after the parsing mode to begin data parsing. Wait until the completion of data parsing. Set filter rules
and data processing methods. For specific operations, see Configuring Data Conversion.
7. Click Next to select the event target bound to this rule. You can deliver the collected events to the specified delivery
target for completing processing and consuming. The following figure takes the Trigger Method as Message Push
as an example. To configure event alarm push, see Configuring Push Target.

©2013-2022 Tencent Cloud. All rights reserved.

Page 138 of 257

TencentDB for MongoDB

8. To immediately activate the event rule, check Enable Event Rule Immediately, and click Complete.

Event Rule Related Interface
Interface Name

Interface Feature

CheckRule

Validation Rules

CreateRule

Create Event Rule

DeleteRule

Delete Event Rule

GetRuleRetrieve Event Rule Details

ListRules

Retrieve Event Rule List

UpdateRule

Update Event Rules©2013-2022 Tencent Cloud. All rights reserved.

Page 139 of 257

TencentDB for MongoDB

Backup and Rollback
Data Backup：

Last updated 2024-01-15 14:40:06
To avoid data loss caused by system crashes or other problems, TencentDB for MongoDB supports data backup androllback after system recovery to ensure data integrity.

Overview
Backup types
Automatic backup: Data is automatically backed up as scheduled based on the system's default backup policy (suchas default backup interval and mode).
Manual backup: You can run a backup task at any time to meet your business Ops and troubleshooting requirements.
Backup modes
Physical backup: In this mode, physical database files in an instance are backed up, which is fast and easy to restore
with a high success rate. However, it has no portability, and the backup environment and restoration environment
must be completely the same.
Logical backup: In this mode, the database instance is connected to, and the mongodump tool is used to save theoperation logs to a logical backup file to back up the data, which can be restored by replaying the operation logs. Thismode is slow but has a high portability. You can restore the logical backup of a database to database on different
versions.

Use Limits
A backup can contain up to 7 days of continuous data; that is, you can roll back data to any time point in the last 7
days.

Note
Instance backup doesn't affect your business.
Backup files are stored in COS without using the storage space of TencentDB for MongoDB instances. For more
information on COS, see Cloud Object Storage (COS).

©2013-2022 Tencent Cloud. All rights reserved.

Page 140 of 257

TencentDB for MongoDB

Version Description
VersionInstance
Type

Automatic backup

Manual backup

Default backup mode: Logical backup

Default backup mode: Logical backup

Set

Supported backup modes: LogicalbackupSupported backup modes: Logicalbackup

ShardedDefault backup mode: Logical backup
Supported backup modes: LogicalDefault backup mode: Logical backup
Supported backup modes: LogicalbackupbackupDefault backup mode: Logical backup
Supported backup modes: LogicalDefault backup mode: Logical backup
Supported backup modes: LogicalbackupbackupDefault backup mode: Logical backup

Default backup mode: Logical backup

Supported backup modes: Logical

Supported backup modes: LogicalbackupbackupDefault backup mode: Logical backup

Default backup mode: Logical backup

Supported backup modes: Logicalbackup and physical backup

Supported backup modes: Logicalbackup and physical backup

Default backup mode: Logical backup

Default backup mode: Logical backup

Supported backup modes: Logicalbackup and physical backup

Supported backup modes: Logicalbackup and physical backup

Replicav3.2
cluster

ReplicaSet
v3.6
Shardedcluster

Replica
Set
v4.0 andlater
Shardedcluster

Billing Overview
Currently, backup is free of charge. We will notify you when billing for the backup space officially starts.

Prerequisites
You have created a TencentDB for MongoDB instance. For more information, see Creating TencentDB for MongoDB
Instance.
The TencentDB for MongoDB replica set or sharded cluster instance is in Running status.

Adjusting the automatic backup policy©2013-2022 Tencent Cloud. All rights reserved.

Page 141 of 257

TencentDB for MongoDB

1. Log in to the TencentDB for MongoDB console.
2. In the MongoDB drop-down list on the left sidebar, select Replica Set Instance or Sharded Cluster Instance.
The directions for replica set instances and sharded instances are similar.
3. Above the Instance List on the right, select the region.
4. In the instance list, find the target instance.
5. Click the target instance ID to enter the Instance Details page.
6. Select the Backup and Rollback > Backup Task List page.
7. Select the Auto-Backup Settings tab and click Edit.
8. Edit Backup Mode and Backup Start Time based on the parameter descriptions in the following table.
9. Click Save.
Parameter

Note

Data Backup
Retention

Data backup files can be retained for 7 days by default.

Backup modes(Optional) Select the backup mode.
TencentDB for MongoDB 3.6 replica set instances don't support this parameter.
The default start time is 10:00 PM–02:00 AM; that is, the system starts the backup task

Backup StartTime

between 10:00 PM and 02:00 AM every day.
You can select a different time period to start data backup as needed by your business.
The specific start time varies by the specific scheduling of the backup task.

Manual Backup
1. Log in to the TencentDB for MongoDB console.
2. In the MongoDB drop-down list on the left sidebar, select Replica Set Instance or Sharded Cluster Instance.
The directions for replica set instances and sharded instances are similar.
3. Above the Instance List on the right, select the region.
4. In the instance list, find the target instance.
5. Click the target instance ID to enter the Instance Details page.
6. In the top-right corner of the Instance Details page, click Manual Backup.
7. (Optional) Select the backup mode. TencentDB for MongoDB 3.6 replica set instances don't support thisparameter.
8. Add remarks and click OK.

Downloading a backup file

©2013-2022 Tencent Cloud. All rights reserved.

Page 142 of 257

TencentDB for MongoDB

1. Log in to the TencentDB for MongoDB console.
2. In the MongoDB drop-down list on the left sidebar, select Replica Set Instance or Sharded Cluster Instance.
The directions for replica set instances and sharded instances are similar.
3. Above the Instance List on the right, select the region.
4. In the instance list, find the target instance.
5. Click the target instance ID to enter the Instance Details page.
6. Select the Backup and Rollback > Backup Task List page.
7. In the Backup Task List, find the target file and click Download in the Operation column.
8. In the Generate Backup File pop-up window, read the backup note carefully and click OK.
9. Select the File Download List tab and view the backup task progress.
10. After the task execution is completed, you can back up the data to your local device and view it as follows:
Over public network: Click Download from Public Network in the Operation column and directly use the browser
to download the backup to your local device.
Over private network: Copy the private network address and run a wget command wget -c 'private
network address' -O backup.tar in a CVM instance to download the backup at a high speed over theprivate network. For detailed directions on how to log in to CVM, see Customizing Linux CVM Configurations.

Related APIs
API Name

Description

DescribeDBBackups

Queries the list of backups of an instance

CreateBackupDBInstanceBacks up an instanceDescribeBackupDownloadTask

Queries the information of a backup download task

CreateBackupDownloadTask

Creates a backup download task

©2013-2022 Tencent Cloud. All rights reserved.

Page 143 of 257

TencentDB for MongoDB

Data Rollback
Data Clone：

Last updated 2024-05-07 17:30:35

Operation scenarios
When the current instance data encounters severe issues and needs to be rolled back to a previously backed-up
state, you can directly clone a new instance from the current instance's backup file to quickly restore data. The data of
the cloned instance is consistent with the backup file, allowing you to use the cloned instance to analyze historical
data, or swap the IP of the cloned new instance with the original instance to achieve a rollback. This method avoids
the tedious process of manually restoring data one by one, improving the efficiency and accuracy of data recovery.

Prerequisites
You have applied for a TencentDB for MongoDB Instance.
The TencentDB for MongoDB Replica Set Instance or Sharded Instance is in Running status.
You have Data Backup.

Operation step
1. Sign in to the MongoDB Console.
2. In the MongoDB drop-down list on the left sidebar, select Replica Set Instance or Sharded Instance. The
directions for the two types of instances are similar.
3. Above the instance list on the right, select the region.
4. In the instance list, find the target instance.
5. Click target Instance ID to enter the Instance Details page.
6. Select the Backup and Rollback tab, and enter the Backup Task List page.
7. In the Backup Task List, find the backup file to be restored.
8. In the Operation column, click Clone.

9. On the Clone TencentDB for MongoDB Instance page, confirm the master instance information, in the timeframe of selecting Backup Time, choose the rollback point in time, select the new instance's billing model, configure©2013-2022 Tencent Cloud. All rights reserved.

Page 144 of 257

TencentDB for MongoDB

specifications, and purchase the new instance. For more information on how to configure additional parameters, see
Create MongoDB Instance.
Note:
Rollback time only supports selecting data from any time point within the last 7 days before the current time.

10. Confirm the cost, and click Buy Now.
11. Return to the Instance List page. Once the instance has been created and the data from the source instance has
been synchronized with the newly cloned instance, the new instance can be used. You may achieve the purpose ofrolling back data by swapping the IP of the cloned new instance with the original instance.
Note:
After the instance is cloned, the source instance can be retained or terminated based on your own needs.

More Entrances
1. In the Backup and Rollback tab's backup task list, find the backup file you need to restore.
2. In the Operation column, click Collection Rollback.
3. In the Batch Collection Rollback Configuration Wizard's Select rollback Instance tab, for Rollback Target
Instance select Rollback to New Instance, for Rollback Type choose Rollback of entire instance.

©2013-2022 Tencent Cloud. All rights reserved.

Page 145 of 257

TencentDB for MongoDB

4. In the instance list below, check an instance that is to be rolled back (you can search by Instance ID, InstanceName, or IP Address in the search box).

5. Click Purchase and Configure a Cloned Instance, enter the Clone TencentDB for MongoDB Instance page,confirm the primary instance information, choose the billing model, configuration specifications, and purchase the new
instance. For more information on how to configure additional parameters, see Creating TencentDB for MongoDB
Instance.
6. Confirm the cost, and click Buy Now.

©2013-2022 Tencent Cloud. All rights reserved.

Page 146 of 257

TencentDB for MongoDB

Database and Table Rollback：

Last updated 2024-05-07 09:58:01

Overview
When the business only requires restoration operations on multiple databases and tables, Database and Table
Rollback can be performed through the console, restoring the data to either the existing instance or a new one.
Compared to a rollback of entire instance, a database or table rollback involves less data and results in a quicker
process.

Version Description
Version

Rollback Method

3.2, 3.6

Rollback of entire instance (logical backup)
Collection rollback (logical backup)

4.0, 4.2, 4.4

Rollback of entire instance (logical backup, physical backup)
Collection rollback (logical backup, physical backup)
Rollback of entire instance (logical backup, physical backup)
Collection rollback (logical backup)

5.0

：

Note
Version 5.0 instances temporarily do not support a database or table rollback to a new
instance.
Flashback by Key (Logical Backup)

Use Limits
You can select up to 2,000 collections per instance to roll back.
You can roll back data to any time point in the last 7 days.
Note:
Pay close attention to the Oplog Time Lag monitoring metric found within the System Monitoring section of theinstance management page. In scenarios where your business experiences frequent write, update, and delete
operations, the smaller this metric becomes, the higher the likelihood that the oplog will be at risk of being overwritten.
If there are transaction operations on the client during the rollback process, you need to actively submit the transaction
or set a timeout period to prevent the transaction from occupying lock resources for a long time and causing the©2013-2022 Tencent Cloud. All rights reserved.

Page 147 of 257

TencentDB for MongoDB

rollback task to be abnormal.

Prerequisites
You have created a TencentDB for MongoDB instance. For more information, see Creating TencentDB for MongoDB
Instance.
The status of the TencentDB for MongoDB instance is Running .
You have backed up the data. For more information, see Data Backup.

Directions
1. Log in to the TencentDB for MongoDB console.
2. In the MongoDB drop-down list on the left sidebar, select Replica Set Instance or Sharded Cluster Instance.
The directions for replica set instances and sharded cluster instances are similar.
3. Above the Instance List on the right, select the region.
4. In the instance list, find the target instance.
5. On the Instance Details page, select the Backup and Rollback tab.
6. Navigate to the Backup and Rollback tab and access the Backup Task List page.
7. In the Backup Task List, find the backup file to be restored.
8. In the Operation column, click Database and Table Rollback .

9. In the Batch Rollback Database and Table Data configuration wizard, on the Select Archive Instance tab,after the Rollback Target Instance , select either Rollback to Current Instance or Rollback to New Instance. Within Select Rollback Type , select Database and Table Rollback .

：

Note

Rollback to the Current Instance eliminates the need to purchase a new instance by restoring databases andtables to the current instance. It supports the selection of multiple instances for batch rollback, allowing for database
and table rollback or key-based flashback according to the actual scenario. In the instance list below, check one ormore instances to be rolled back (you can search by instance ID, instance name, or IP address in the search box). For
detailed operations, see Database and Table Rollback to the Current Instance.
Rollback to a New Instance requires the purchase of a new instance and does not affect the source instance. It
does not support selecting multiple instances for batch rollback. Depending on the actual scenario, you can choose toperform a database and table rollback, a key-based flashback, or clone an instance. In the instance list below, check©2013-2022 Tencent Cloud. All rights reserved.

Page 148 of 257

TencentDB for MongoDB

only one instance to be rolled back (you can search by instance ID, instance name, or IP address in the search box).
For specific operations, see Rolling Back Databases and Tables to a New Instance.

Rolling Back Databases and Tables to Current Instance
1. Click Next: Select Databases and Tables to Roll Back . On the Select Rollback Database and Table tab,select the databases and tables to be rolled back. Confirm the database and table information in the right-side box
zone. As shown below.
Note:
In the right-side zone, you can confirm and modify the selected databases and tables.
click Clear Selection to clear the selected databases and tables if the wrong selection is made.
click

to delete the selected databases and tables one by one.

©2013-2022 Tencent Cloud. All rights reserved.

Page 149 of 257

TencentDB for MongoDB

2. Click Next: Select Rollback Time . On the Setting Rollback Time tab, select the specific time point for the
rollback from the time frame following Setting Rollback Time . Confirm the instance information and the database
and tablesinformation to be pre-rolled back.
Note:
Rollback time only supports selecting data from any time point within the last 7 days before the current time.
Rollback to the current instance does not rollback the original databases and tables directly but creates a new backup
file. For instance, if the source database or table is test, a new database or table test_bak will be created. As shown
below, Rollback Database and Table Names are the names of the newly created databases and tables.
After the rollback task is completed, you can batch modify database and table names as needed.
In versions of TencentDB for MongoDB below 5.0, sharded clusters rolling back to the current instance cannot modify
database and table names. Data must be manually replaced back into the original databases and tables.

3. Click Start Rollback . Return to Rollback Task tab of the Batch Rollback Database and Table Data . You
can see ongoing rollback tasks. Click the Operation column's Task Details to view the detailed information of the©2013-2022 Tencent Cloud. All rights reserved.

Page 150 of 257

TencentDB for MongoDB

task. Wait until the task is completed. Then you can connect to the instance to confirm the correctness of the rolledback data.

4. (Optional) Select the Batch Rename Databases and Tabled tab under Batch Rollback Database and Table
Data . Find the completed rollback task. In its Operation column, click Batch Modify Database and Table
Names to view information about the databases and tables to be modified on the right zone. The information includes
original database and table names, new original database and table names, rollback database and table names, andnew rollback database and table names.
Click

to download information of the databases and tables to be modified. Then you may view locally.
Confirm the changes. Click Batch Rename Databases and Tables at the bottom left to complete the modifications.
Note:
Batch Rename Databases and Tables can only modify all databases and tables under a single instance of a single
rollback task. If a user initiates a batch rollback task and rolls back databases and tables of multiple instances, thedatabase and table names need to be modified one by one. For specific operations, see Batch Rollback.
Batch Rename Databases and Tables includes changing the original database and table names and rollback
database and table names.
For original databases and tables, the mark _ori is added to their original names.
For rollback databases and tables, change the rollback database and table names to the original ones.

Rolling Back Databases and Tables to a New Instance
1. Click Next: Select databases and tables to roll back . On the Select Rollback Database and Table tab,choose the databases and tables of the source instance to be rolled back. In the search box, you can search for the
databases and tables to be rolled back based on the database and table names. And in the right box zone, you canview the selected database and table information. As shown below. In the right box zone, you can manage theselected databases and tables.
Click Clear Selection to clear the selected databases and tables if the wrong selection is made.

©2013-2022 Tencent Cloud. All rights reserved.

Page 151 of 257

TencentDB for MongoDB

Click

to delete the selected database and table one by one.

2. Click Next: Select Rollback Time . In the Setting Rollback Time tab, select the specific time point for the
rollback from the time frame provided under Setting Rollback Time . Confirm the instance information and the
database and table information to be pre-rolled back.
3. Click Proceed to Purchase and Configure the Replica Instance . Enter the TencentDB for MongoDB clone
instance page and select the billing mode, configuration specifications, etc., for the new instance. For more
information, see Create MongoDB Instance.
4. Confirm the cost, and click Purchase Now .
5. Return to the instance list page. Once the instance has been created, the source instance's databases and tables
have been synchronized to the newly purchased clone instance. Then you can connect to the new instance to confirm
the correctness of the rollback data.

©2013-2022 Tencent Cloud. All rights reserved.

Page 152 of 257

TencentDB for MongoDB

Batch Rollback：

Last updated 2024-05-07 10:55:52

Overview
Batch rollback refers to the process of rolling back the database and table data of multiple instances at once, restoring
the data of multiple instances to the source instance in a single batch operation. Database and table rollback or keybased flashback to the current instance supports batch operations, allowing multiple instances' databases and tables
to be rolled back at once. The newly rolled back databases and tables are named with the suffix _bak. After the
rollback is completed, the database and table name can be changed as needed to improve the efficiency andaccuracy of data recovery and avoid the cumbersome process of manual individual recovery. Moreover, MongoDB
supports viewing all batch rollback historical tasks under the current account. This helps you to quickly understandpast operation records for convenient and unified operation and management.

Initiating Batch Rollback Task
1. Log in to the MongoDB console.
2. In the MongoDB dropdown menu in the left sidebar, select Batch Rollback.
3. On the Rollback Task page, click Initiate Rollback to enter the Batch Rollback Database and Table Data
configuration wizard. Here, you can configure the batch rollback database and table task and initiate a rollback task.
For specific operations, see Database and Table Rollback.

Viewing Batch Rollback Tasks©2013-2022 Tencent Cloud. All rights reserved.

Page 153 of 257

TencentDB for MongoDB

1. Log in to the MongoDB console.
2. In the MongoDB dropdown menu on the left sidebar, select Batch Rollback.
3. On the Rollback Task page, you can find all batch rollback tasks under the current account. As shown in thefollowing figure. You can filter the tasks you want to view by selecting a time range in the time box.

Batch Modifying Rollback Database and Table Names
Database and table rollback does not directly roll back data to the original database and table, but instead creates a
backup file. For example, if the original database or table is named test, a new database or table named test_bak willbe created. As shown in the following figure, Rollback Database or Table Name is the name of the newly createddatabase or table. After the rollback task is completed, you can batch modify the database and table names asneeded.

1. Log in to the MongoDB console.
2. In the MongoDB dropdown menu on the left sidebar, select Batch Rollback.
3. On the Batch Rename Database and Table tab in Batch Rollback Database and Table Data, find the rolledback tasks and select the instances with database and table names to be modified. In their Operations column, click
Batch Modify Database and Table Names to see the information of the databases and tables to be modified on theright zone. The information includes original database and table names, new original database and table names,
rollback database and table names, and new rollback database and table names. Confirm the modifications, click the©2013-2022 Tencent Cloud. All rights reserved.

Page 154 of 257

TencentDB for MongoDB

Batch Rename Database and Table at the bottom left to complete the modifications. As shown in the following
figure.
Note:
Batch Rename databases and tables can only modify all of them under a single instance of a single rollback task. If auser initiates a batch rollback task and rolls back databases and tables of multiple instances, the database and tablenames need to be modified one by one.
Batch Rename Database and Table includes changing the original database and tables names and rollback database
and table names.
For original databases and tables, the mark _ori is added to their original names.
For rollback databases and tables, change their names to the original database and table names.

©2013-2022 Tencent Cloud. All rights reserved.

Page 155 of 257

TencentDB for MongoDB

Restoring to Self-built Database：

Last updated 2024-01-15 14:40:06

Restoring a Physical Backup to a Self-Built Database
A replica set instance has only one copy of data, while each shard of a sharded cluster has one copy of data. Restore
your data based on your business needs. This document describes how to restore a single copy of data.

Restoring data to a single node
1. Copy the data to an empty data directory in the self-built database, such as /data/27017/.

©2013-2022 Tencent Cloud. All rights reserved.

Page 156 of 257

TencentDB for MongoDB

cp -r * /data/27017/
2. Restart mongod and check the data. Below is a command sample:©2013-2022 Tencent Cloud. All rights reserved.

Page 157 of 257

TencentDB for MongoDB./mongod --dbpath /data/27017 --port 27017 --logpath /var/log/mongodb/27017.log --f

Restoring data to a replica set
As a physical backup retains the configuration of the original instance by default, the original configuration needs to be
removed first; otherwise, the data may become inaccessible.
1. Restore the data to a single-node self-built database and then restart the node in the form of replica set. Below is acommand sample:©2013-2022 Tencent Cloud. All rights reserved.

Page 158 of 257

TencentDB for MongoDB./mongod --replSet mymongo --dbpath /data/27017 --port 27017 --logpath /var/log/mon
2. Log in to the node and remove the replica set configuration of the original instance by running the following
command:©2013-2022 Tencent Cloud. All rights reserved.

Page 159 of 257

TencentDB for MongoDB

rs.slaveOk()
use local
db.system.replset.remove({})
3. Restart the node, add a node to the replica set, initialize it, and check the data. The node added to the replica set
should have been started with no data contained. Below is a command sample:©2013-2022 Tencent Cloud. All rights reserved.

Page 160 of 257

TencentDB for MongoDB

rs.initiate({"_id":"mymongo","members":[{"_id":0,"host":"127.0.0.1:27017"},{"_id":1
For more information on the rs.initiate() command, see rs.initiate().
Notes:
Data cannot be restored to a sharded cluster. As the route of physical backup is missing in a sharded cluster, mongos
can only read the data of the primary shard even if the data of each shard is restored to the self-built replica set (eachshard of the sharded cluster).

©2013-2022 Tencent Cloud. All rights reserved.

Page 161 of 257

TencentDB for MongoDB

Restoring a Logical Backup to a Self-Built Database
To avoid any impact on data check after the data is restored to a self-built database, the self-built database must be
empty.
For v3.6, you need to delete the config directory manually and then run the mongorestore command torestore the data of each shard.

For v3.2, you need to merge all the files in individual collections manually before restoring the data. Below is a filemerge operation sample:
The c_10 collection is in the ycsb directory in the database and contains data files fromc_10.bson.gz.chunk-64 to c_10.bson.gz.chunk-127 . The merge command is cat
c_10.bson.gz.chunk-* > ./c_10.bson.gz .
Notes:
Chunk distinction will appear in some scenarios on v3.2.
Run the mongorestore command to restore the data, where the -h parameter specifies the self-built databaseaddress, --dir specifies the directory of the data file, and --gzip must be specified to decompress the
backup file. The command is as follows:©2013-2022 Tencent Cloud. All rights reserved.

Page 162 of 257

TencentDB for MongoDB./mongorestore--gzip --drop -h127.0.0.1:27017 --dir ./1544517027220146694©2013-2022 Tencent Cloud. All rights reserved.

Page 163 of 257

TencentDB for MongoDB

Data Security
Configuring Security Group：

Last updated 2024-01-15 14:40:06
You can configure a security group in the TencentDB for MongoDB console to control the outbound/inbound traffic.

Overview
Security group serves as a stateful virtual firewall with filtering feature for configuring network access control for one ormore TencentDB instances. It is an important network security isolation tool provided by Tencent Cloud. Instanceswith the same network security isolation demands in one region can be put into the same security group, which is alogical group. TencentDB and CVM share the security group list and are matched with each other within the security
group based on rules. For specific rules and limitations, see Security Group Overview.
Note:
TencentDB security groups currently only support network access control for VPCs but not the classic network.
As TencentDB doesn't have any active outbound traffic, outbound rules don't apply to it.
TencentDB for MongoDB security groups support primary instances, read-only instances, and disaster recovery
instances.
TencentDB for MongoDB supports the security group feature which is implemented based on the allowlist. To use thisfeature, submit a ticket.

Directions
Step 1. Create a security group
1. Log in to the CVM console.
2. Select Security Group on the left sidebar, select a region above the instance list on the right, and click Create.
3. In the pop-up window, set the following configuration items, confirm that everything is correct, and click OK.
Template: Select a security group template in the drop-down list.
Open all ports: All ports are opened to the public and private networks. This may present security issues. Security
group rules are added by default. You can click a security group template below to view its Outbound Rules* andInbound Rules**.
Open ports 22, 80, 443, and 3389 and the ICMP protocol: Ports 22, 80, 443, and 3389 and the ICMP protocol are
opened to the internet. All ports are opened to the private network. Security group rules are added by default. The portof TencentDB for MongoDB is 27017 by default. You can ignore this template.

©2013-2022 Tencent Cloud. All rights reserved.

Page 164 of 257

TencentDB for MongoDB

Custom: You can create a security group and then add custom rules.
Name: Custom name of the security group.
Project: Select a project for easier management. By default, Default Project is selected.
Notes: A short description of the security group for easier management.
Advanced Configuration: You can add tags for the security group.
4. If you select Custom for Template, click Set Now in the Note window and perform the following steps.

Step 2. Set inbound rules in the security group
1. On the Inbound Rule tab of the Security Group Rules page, click Add Rules.
2. In the Add Inbound Rules pop-up window, set the rules.
Type: Select Custom as the default type.
Source: Set the source for database access, i.e., the inbound source. The following formats are supported:
SourceFormatFormat Description
A single IPv4 address or an IPv4 range is represented in CIDR notation, such as203.0.113.0 , 203.0.113.0/24 , or 0.0.0.0/0 , where 0.0.0.0/0 indicates all

CIDR

IPv4 addresses will be matched.

notation

A single IPv6 address or an IPv6 range is represented in CIDR notation, such as FF05::B5 ,FF05:B5::/60 , ::/0 , or 0::0/0 , where ::/0 or 0::0/0 indicates all IPv6
addresses will be matched.

Security

Reference a security group ID to match the IP address of the server associated with the security

group ID

group.

Parameter
template

Reference IP address object or IP address group object in a parameter template.

Protocol Port: Enter the protocol type and port for the client to access TencentDB for MongoDB. You can view theport information in the Private Network Address column in the instance list. The default port is 27017.
Policy: Allow or Reject. Allow is selected by default.
Allow: Traffic to this port is allowed.
Reject: Data packets will be discarded without any response.
Notes: A short description of the rule for easier management.
3. Click Complete.

Step 3. Bind the security group to an instance
Note:
Currently, security groups can be configured only for TencentDB for MongoDB instances in VPC.
1. Log in to the TencentDB for MongoDB console.

©2013-2022 Tencent Cloud. All rights reserved.

Page 165 of 257

TencentDB for MongoDB

2. In the MongoDB drop-down list on the left sidebar, select Replica Set Instance or Sharded Cluster Instance.
The directions for replica set instances and sharded cluster instances are similar.
3. Above the Instance List on the right, select the region.
4. In the instance list, find the target instance.
5. In the Operation column of the target instance, select More > Security Group.
You can also click the target instance name, select the Data Security tab, and click Configure Security Group.
6. In the Configure Security Group pop-up window, select the target security group and click OK.

More Operations
Adjusting the priority of a bound security group
1. Log in to the TencentDB for MongoDB console.

©2013-2022 Tencent Cloud. All rights reserved.

Page 166 of 257

TencentDB for MongoDB

2. In the MongoDB drop-down list on the left sidebar, select Replica Set Instance or Sharded Cluster Instance.
The directions for replica set instances and sharded cluster instances are similar.
3. Above the Instance List on the right, select the region.
4. In the instance list, find the target instance.
5. Click the target instance ID, select the Data Security tab, and view all security groups of the instance.
6. Click Edit. You can clickorin the Operation column to adjust the filtering priorities of security groups.
7. Click Save.

Adjusting an inbound/outbound rule
1. Log in to the TencentDB for MongoDB console.
2. In the MongoDB drop-down list on the left sidebar, select Replica Set Instance or Sharded Cluster Instance.
The directions for replica set instances and sharded cluster instances are similar.
3. Above the Instance List on the right, select the region.
4. In the instance list, find the target instance.
5. Click the target instance ID, select the Data Security tab, and view all security groups of the instance.
6. In the security group list, click the target security group ID or name to enter the Security Group page.
7. Find the security group rule to be modified and click Edit in the Operation column to edit it.

Importing a security group rule
1. On the Security Group page, click the ID/name of a security group.
2. On the Inbound Rule or Outbound Rule tab, click Import Rule.
3. In the pop-up window, select an edited inbound/outbound rule template file and click Import.
Note:
As existing rules will be overwritten after importing, we recommend that you export the existing rules before importing
new ones.
If there are no existing rules in the security group, download a template and edit it before importing it.

Cloning a security group
1. On the Security Group page, find the target security group and click More > Clone in the Operation column.
2. In the pop-up window, select the target region and project and click OK.
If the new security group needs to be associated with a CVM instance, do so by managing the CVM instances in the
security group.

©2013-2022 Tencent Cloud. All rights reserved.

Page 167 of 257

TencentDB for MongoDB

Deleting a security group
1. On the Security Group page, find the security group to be deleted and click More > Delete in the Operation
column.
2. In the pop-up window, click OK.
If the current security group is associated with a CVM instance, it must be disassociated first before being deleted.

References
For more information, see Security Group.

©2013-2022 Tencent Cloud. All rights reserved.

Page 168 of 257

TencentDB for MongoDB

SSL Authentication
Enabling SSL Authentication：

Last updated 2024-01-15 14:40:06

Overview
Secure Sockets Layer (SSL) authentication is a process that authenticates the connection from the user client to theTencentDB server. After SSL encryption is enabled, you can get a CA certificate and upload it to the server. Then,
when the client accesses the database, the SSL protocol will be activated to establish an SSL secure channel
between the client and the server. This implements encrypted data transfer, prevents data from being intercepted,
tampered with, and eavesdropped during transfer, and ultimately ensures the data security for both the client and theserver.
Note:
The SSL authentication is being gradually released in regions. To try it out, submit a ticket.

Billing Overview
SSL encryption is free of charge.

Notes
You need to restart the instance to enable SSL. Perform this operation during off-peak hours, or ensure that yourapplication has a reconnection feature.
Enabling SSL encryption ensures the security of data access and transfer but will significantly increase CPU
utilization. We recommend that you enable it only when encryption is required.
When SSL is enabled, you will receive an expiration alarm 30 days, 15 days, and 7 days before the expiration of yourcertificate and on its expiration date. Refresh the SSL certificate in time; otherwise, the access authentication through
SSL certificate will fail.

Version description
New instances of TencentDB for MongoDB 4.0 and later support SSL authentication.
Existing instances of TencentDB for MongoDB 3.6 need to be upgraded to v4.0 to support SSL authentication.

©2013-2022 Tencent Cloud. All rights reserved.

Page 169 of 257

TencentDB for MongoDB

Prerequisites
The database instance is in Running status, with no ongoing tasks.
The operation is performed in off-peak hours, or the client has an automatic reconnection mechanism.

Directions
1. Log in to the TencentDB for MongoDB console.
2. In the MongoDB drop-down list on the left sidebar, select Replica Set Instance or Sharded Cluster Instance.
The directions for the two types of instances are similar.
3. Above the Instance List on the right, select the region.
4. In the instance list, find the target instance.
5. In the Instance ID/Name column of the target instance, click the instance ID in blue font to enter the Instance
Details page.
6. Click the Data Security tab and select the Access Encryption tab.
7. Clickafter Enable SSL.
8. In the Enable SSL window, confirm the impact of enabling SSL and click OK.
9. Wait for the Enable SSL status to become Enabled and click Download Certificate.
If you receive a certificate expiration warning message, and the certificate has expired. Click Refresh Certificate to
update the certificate file.
10. In the bottom-left corner of the page, get the certificate MongoDB-CA.crt.
11. You can use Mongo Shell to connect to TencentDB for MongoDB. For detailed directions, see Using Mongo Shell
to Connect to Database by SSL Authentication.
You can use multi-language SDKs to connect to TencentDB for MongoDB. For detailed directions, see Using MultiLanguage SDKs to Connect to Database by SSL Authentication.

©2013-2022 Tencent Cloud. All rights reserved.

Page 170 of 257

TencentDB for MongoDB

Using Mongo Shell to Connect to Database by
SSL Authentication：

Last updated 2024-01-15 14:40:06

Overview
When using Mongo Shell to connect to database, you can enable Secure Sockets Layer (SSL) encryption feature to
improve the security of the data linkage. The network connection can be encrypted at the transport layer with the SSL
encryption feature to improve the communication data security and ensure data integrity.

Prerequisites
You have created a Linux CVM instance in the same VPC and region as the TencentDB for MongoDB instance.
You have obtained the username and password information for database instance access on the AccountManagement tab on the Database Management page. For detailed directions, see Account Management.
You have obtained the private IP and port for database instance access in the Instance List. For detailed directions,
see Viewing Instance Details.
You have enabled SSL encryption feature on the instance. For details, see Enabling SSL Authentication.

Directions
This document uses the Linux operating system as an example to demonstrate the specific operation process.
1. Download the SSL CA certificate. For detailed directions, see Enabling SSL Authentication.
2. Upload the certificate file MongoDB-CA.crt to the CVM instance with Mongo Shell installed.
3. On the CVM instance with Mongo Shell installed, run the following command to connect to the MongoDB database.
Note:
For MongoDB 4.2 and later, Transport Layer Security (TLS) is used to perform data authentication. TLS is the
security protocol of transport layer, an upgraded version of SSL. When you are not sure whether to use SSL
authentication or TLS authentication, you can execute ./mongo_ssl -h to confirm the authentication method.
SSL Authentication©2013-2022 Tencent Cloud. All rights reserved.

Page 171 of 257

TencentDB for MongoDB./bin/mongo -umongouser -plxh***** 172.xx.xx.xx:27017/admin --ssl --sslCAFile Mongo
Replace the following parameters as needed.
-u: Database connection username-p: Username password
172.xx.xx.xx and 27017 specify the IP (port number included) and port of the TencentDB for MongoDB
instance respectively. If you forgot the username and password, view and modify the account and password as
instructed in Account Management.
--sslCAFile: Certificate file path of SSL authentication©2013-2022 Tencent Cloud. All rights reserved.

Page 172 of 257

TencentDB for MongoDB

TLS Authentication./bin/mongo -umongouser -plxh***** 172.xx.xx.xx:27017/admin --tls --tlsCAFile /data--tlsCAFile: Certificate file path of TLS authentication
4. After a successful connection, the following information will be displayed:
The prompt information may vary by MongoDB shell version. The following takes v5.0.15 as an example.

©2013-2022 Tencent Cloud. All rights reserved.

Page 173 of 257

TencentDB for MongoDB

References
For SDK connection in other languages, see Using Multi-Language SDKs to Connect to Database by SSL
Authentication.

©2013-2022 Tencent Cloud. All rights reserved.

Page 174 of 257

TencentDB for MongoDB

Using Multi-Language SDKs to Connect toDatabase by SSL Authentication：

Last updated 2024-01-15 14:40:06

Java
Keytool is a native key and certificate management tool in Java, which is convenient for you to manage yourpublic/private keys and certificates for authentication services. Keytool stores keys and certificates in keystore.
Converting certificate format with keytool:©2013-2022 Tencent Cloud. All rights reserved.

Page 175 of 257

TencentDB for MongoDB

keytool -importcert -trustcacerts -file <certificate file> -keystore <trust store>-file <certificate file> : SSL certificate or TLS certificate file MongoDB-CA.crt-keystore <trust store> : Specified keystore name-storepass <password>: Specified keystore password.

To set the keystore of JVM system property, you need to change the value of trustStore and password as
required to refer to correct keystore. You also need to replace the URI combination with the user password informationthat is used to access the database.

©2013-2022 Tencent Cloud. All rights reserved.

Page 176 of 257

TencentDB for MongoDB

System.setProperty("javax.net.ssl.trustStore", trustStore);
System.setProperty("javax.net.ssl.trustStorePassword", password);
import com.mongodb.MongoClientURI;
import com.mongodb.MongoClientOptions;
String uri = "mongodb://mongouser:password@10.x.x.1:27017/admin";MongoClientOptions opt = MongoClientOptions.builder().sslEnabled(true).sslInvalidHo
MongoClient client = new MongoClient(uri, options);©2013-2022 Tencent Cloud. All rights reserved.

Page 177 of 257

TencentDB for MongoDB

Go
The following is a code example of using GO language to connect to database by SSL authentication. You need toreplace the path of the certificate file MongoDB-CA.crt, the account and password, IP information and port information
concatenated in the URI as needed.

package main
import ("context"©2013-2022 Tencent Cloud. All rights reserved.

Page 178 of 257

TencentDB for MongoDB"crypto/tls""crypto/x509""io/ioutil""go.mongodb.org/mongo-driver/mongo""go.mongodb.org/mongo-driver/mongo/options")func main() {ca, err := ioutil.ReadFile("MongoDB-CA.crt")
if err != nil {return}pool := x509.NewCertPool()
ok := pool.AppendCertsFromPEM([]byte(ca))
if !ok {return}tlsConfig := &tls.Config{
RootCAs:
pool,
InsecureSkipVerify: true,}
uri := "mongodb://mongouser:password@10.x.x.1:27017/admin?ssl=true"
clientOpt := options.Client().ApplyURI(uri)clientOpt.SetTLSConfig(tlsConfig)
client, err := mongo.Connect(context.TODO(), clientOpt)
if err != nil {return}client.Disconnect(context.TODO())}

PythonThe following is a code example of using Python language to connect database by SSL authentication. You need toreplace the path of the certificate file MongoDB-CA.crt, the account and password, IP information and port information
concatenated in the URI as needed.

©2013-2022 Tencent Cloud. All rights reserved.

Page 179 of 257

TencentDB for MongoDB

from pymongo import MongoClient
uri = "mongodb://mongouser:password@10.x.x.1:27017/admin"client = MongoClient(uri,
ssl=True,
ssl_ca_certs='MongoDB-CA.crt',
ssl_match_hostname=False)©2013-2022 Tencent Cloud. All rights reserved.

Page 180 of 257

TencentDB for MongoDB

Database Management
Account Management：

Last updated 2024-01-15 14:40:06
You can create an account, set account permissions, and change the account password in the TencentDB for
MongoDB console to manage database access permissions more easily.

Overview
TencentDB for MongoDB has two default users: rwuser and mongouser . TencentDB for MongoDB 3.2
supports both of them by default, while v3.6, v4.0, v4.2, and v4.4 only support the mongouser user by default.
Only rwuser is authenticated with MONGODB-CR.
Both mongouser and users created in the TencentDB for MongoDB console are authenticated with SCRAM-SHA-1.
You can set multiple accounts and grant each of them different database read/write permissions for database accessat a finer granularity and higher data security.

Version Description
All TencentDB for MongoDB versions support database account management.

Note
After you create an account and grant it the access permission, it will take effect in 2 minutes after the system
performs the backend configuration.
We recommend that you reset the database password periodically at least once every three months.

Prerequisites
You have created a TencentDB for MongoDB instance. For more information, see Creating TencentDB for MongoDB
Instance.
The TencentDB for MongoDB replica set or sharded cluster instance is in Running status.

©2013-2022 Tencent Cloud. All rights reserved.

Page 181 of 257

TencentDB for MongoDB

Directions
Viewing the account information
1. Log in to the TencentDB for MongoDB console.
2. In the MongoDB drop-down list on the left sidebar, select Replica Set Instance or Sharded Cluster Instance.
The directions for replica set instances and sharded cluster instances are similar.
3. Above the Instance List on the right, select the region.
4. In the instance list, find the target instance.
5. Click the target instance ID to enter the Instance Details page.
6. Select the Database Management > Account Management page to view the information of all accounts of thecurrent database.

Creating an account
1. On the Account Management page, click Create Account.
2. On the Create Account tab in the Create Account pop-up window, configure the account information according
to the table below and click OK.
Parameter

Account ID

Account
Password

RequiredYes

Yes

Description

Value Range/Valid Values

Set the name

The account name requirements are as follows:
It can contain 1–32 characters.

of the new
account.

Set thepassword of
the new
account.

Confirm theConfirm
PasswordYes

password of
the new
account.

It can contain letters, digits, underscores, andhyphens.

Exampletest

The password requirements are as follows:
It can contain 8–32 characters.
It must contain at least two of the following typesof characters: letters, digits, and special

test@123

symbols !@#%^*()_ .
The password requirements are as follows:
It can contain 8–32 characters.
It must contain at least two of the following types

test@123of characters: letters, digits, and special
symbols !@#%^*()_ .

Remarks

No

Remarks

Any characterstestmongouser
password

YesEnter thepassword of

The password of the mongouser user.

test@123

themongouser

It can contain 8–32 characters.
It can contain letters and digits.

user.

It can contain special symbols !@#%^*()_ .

©2013-2022 Tencent Cloud. All rights reserved.

Required password strength:

Page 182 of 257

TencentDB for MongoDB

It cannot all be letters or digits.

3. On the Set Permissions page, set the database access permissions for this account.
Parameter

Description

Value Range/Valid Values

Global

Set the global permission to access all

Permission

databases for this account.

No permission: No data read/write permission.
Read-Only: Only data read permission.
Read/Write: Data read/write permission.
Inherit global data: Global permission is inherited.

Instance

Set the permission to access a specificNo permission: No data read/write permission.

Details

database for this account.

Read-Only: Only data read permission.
Read/Write: Data read/write permission.

4. (Optional) Click Create Database, and a new database will be added to the database list. Enter the name of the
new database in the input box, click OK after the input box, and set the access permission of this database.
Note:
The created new database is not a real database but is only used to preset the access permission of this database.
5. Click OK, wait 2 minutes for the system configuration to take effect, and then you can use this account to accessdatabases.

Modifying the account permission
1. In the account list on the Account Management tab, find the target account.
2. Click View/Set in the Operation column.
3. In the Set Permissions pop-up window, modify the account permission.
4. Click OK.

Changing the account password
1. In the account list on the Account Management tab, find the target account.
2. Click Reset Password in the Operation column.
3. In the Reset Password pop-up window, enter the New Password and Confirm Password.
The password requirements are as follows:
It can contain 8–32 characters.
It must contain at least two of the following types of characters: letters, digits, and special symbols !@#%^*()_ .
4. Click OK.

Relevant Operations©2013-2022 Tencent Cloud. All rights reserved.

Page 183 of 257

TencentDB for MongoDB

Viewing the account URI
1. In the account list on the Account Management tab, find the target account.
2. Click Connection URI in the Operation column.
3. In the Connection help pop-up window, view the information of the connection URI of the account.
For more information on instance connection, see Connecting to TencentDB for MongoDB Instance.
4. Click OK.

Deleting an account
1. In the account list on the Account Management tab, find the target account.
2. Click Delete in the Operation column.
3. In the Delete User pop-up window, confirm the information of the account to be deleted.
4. Click OK.

Related APIs
API Name

Description

ResetDBInstancePassword

Changes the password of an instance user

©2013-2022 Tencent Cloud. All rights reserved.

Page 184 of 257

TencentDB for MongoDB

Slow Log Management：

Last updated 2024-01-15 14:40:06
You can view and analyze the slow logs generated during database operations in the TencentDB for MongoDB
console for targeted database performance optimization.

Overview
Slow logs are often used as the basis for optimizing business operations in MongoDB. For more information, seeDatabase Profiler.
The system provides two query methods as described below:
Query statistics: Slow logs for the specified time period are queried, and the query results are aggregated andanalyzed by command (operation) type.
Query details: A specific operation command is specified to query slow logs, and the query results are displayed in alist displaying the execution durations and log details.

Version Description
Currently, all TencentDB for MongoDB versions support slow log management.

Note
The system logs operations with an execution time of more than 100 ms.
The slow logs are retained for 7 days. The time span for a single query cannot exceed 1 day.
Only the first 10,000 slow logs can be queried. If the query is slow, you can narrow down the query time period.

Prerequisites
You have created a TencentDB for MongoDB instance. For more information, see Creating TencentDB for MongoDB
Instance.
The TencentDB for MongoDB replica set or sharded instance is in Running status.

Directions©2013-2022 Tencent Cloud. All rights reserved.

Page 185 of 257

TencentDB for MongoDB

Querying slow logs
1. Log in to the TencentDB for MongoDB console.
2. In the MongoDB drop-down list on the left sidebar, select Replica Set Instance or Sharded Cluster Instance.
The directions for replica set instances and sharded instances are similar.
3. Above the Instance List on the right, select the region.
4. In the instance list, find the target instance.
5. Click the target instance ID to enter the Instance Details page.
6. Select the Database Management > Slow Log Query tab.
7. On the Slow Log Query tab, select a query method to query slow logs.
Query statistics: Select a query time period, set the time consumed threshold, and click Query.
Query details: Select the specific executed command to be queried in Executed Command, select a query time
period, set the time consumed threshold, and click Query.
8. View and analyze the slow logs.
A statistics query result contains four fields:
Query Method: Statistics query.
Sample Command: Output statements aggregated in the command type dimension, which records the operation of
the slow log. You mainly need to refer to the command when troubleshooting problems.
Note:
Pay attention to keywords such as command , COLLSCAN , IXSCAN , keysExamined , anddocsExamined . For more log descriptions, see Log Messages.
- command indicates an operation request recorded in a slow log.
COLLSCAN indicates that a full-collection scan is performed. IXSCAN indicates that an index scan is performed.
keysExamined and docsExamined indicate the numbers of index entries and documents scanned
respectively. Larger keysExamined and docsExamined values indicate that no index is created or the created index
is less distinctive. For more information on how to optimize indexes, see Optimizing Indexes to Break ThroughRead/Write Performance Bottlenecks.
**Average Execution Time (ms)**: Average execution time (in ms) of operations aggregated in the command type
dimension.
Total: Total occurrences of operations aggregated in the command type dimension.

A details query result contains three fields:
Query Method: Details query.

©2013-2022 Tencent Cloud. All rights reserved.

Page 186 of 257

TencentDB for MongoDBTime Consumed: Execution time of the business command (in ms).
Log Details: Details of the business command.

Managing slow logs
Viewing a slow log request statement
1. On the Slow Query Management page, you can view the slow log request statements.
2. In the search box in the top-right corner, enter the information to be queried for search.
Parameter

Description

Query Command

Query statement

Op Type

Operation type

Node Location

Node of the executed operation

NamespaceNamespace of the database collection

Executed TimeTime consumed

Details

Details of the executed statement

Batch killing
1. On the Slow Query Management page, select the slow log request statements to be cleared.
2. Click Batch Kill above the list.
3. In the Note pop-up window, read the prompt carefully.
4. Click OK.

©2013-2022 Tencent Cloud. All rights reserved.

Page 187 of 257

TencentDB for MongoDB

Downloading the slow log file
1. On the Slow Log Download List page, you can view current slow log files.
2. Find the file to be downloaded and click Download in the Operation column.

Related APIs
API Name

Description

DescribeSlowLogs

Gets the slow log information

DescribeSlowLogPatterns

Gets the slow log statistics﻿

©2013-2022 Tencent Cloud. All rights reserved.

Page 188 of 257

TencentDB for MongoDB

Connection Management：

Last updated 2024-01-15 14:40:06

Overview
TencentDB for MongoDB records the IPs of clients connected to the current instance and the number of connections.
When there is a large number of concurrent application requests, if the configured upper limit of connections is
insufficient, the current database specification cannot sustain such requests. In this case, you can directly increase theupper limit in the console to sustain business peaks.

Version description
Replica set: All TencentDB for MongoDB versions support connection management.
Sharded cluster: TencentDB for MongoDB 3.2, 3.6, 4.0, 4.4, and 5.0 support connection management, while v4.2
doesn't.

Notes
The system records the IPs of clients connected to the current instance and the number of connections. You canchoose to manually release connection requests.
If the number of connections reaches or exceeds 80% of the upper limit and affects the establishment of newconnections, you can click Increase Connections in the console to increase the maximum number of connections to
150% of the original limit for the next 6 hours.
If the problem persists, contact the aftersales service or submit a ticket for assistance.

Prerequisites
You have created a TencentDB for MongoDB instance. For more information, see Creating TencentDB for MongoDB
Instance.
The TencentDB for MongoDB replica set or sharded cluster instance is in Running status.

Directions©2013-2022 Tencent Cloud. All rights reserved.

Page 189 of 257

TencentDB for MongoDB

Viewing the number of connections
1. Log in to the TencentDB for MongoDB console.
2. In the MongoDB drop-down list on the left sidebar, select Replica Set Instance or Sharded Cluster Instance.
The directions for the two types of instances are similar.
3. Above the Instance List on the right, select the region.
4. In the instance list, find the target instance.
5. Click the target instance ID to enter the Instance Details page.
6. Select the Database Management > Manage Connection tab.
7. View all client connection statistics of the current database.
Parameter
Real-timeconnections:

Description
Number of all connections to the current database.

Connection

Percentage of all client connections to the current database to the maximum number

percentage

of connections.

Maximum connections

Upper limit of the number of connections.

Remaining

The remaining usage duration of the increased upper limit.

Client IP

The client IP from which the database is connected.

Connections

Number of connections.

Increasing connections
1. On the Manage Connection tab, click Increase Connections.
2. In the Note window, confirm the notes and click OK.

Related APIsAPI

Description

DescribeClientConnections

Queries the client connection information of an instance©2013-2022 Tencent Cloud. All rights reserved.

Page 190 of 257

TencentDB for MongoDB

Multi-AZ Deployment：

Last updated 2024-01-15 14:40:06
Multi-AZ deployment refers to deployment of TencentDB for MongoDB replicas across multiple AZs in the same
region. Multi-AZ deployed instances have higher availability and better disaster recovery capability than single-AZ
deployed instances.

Creating a multi-AZ deployed instance
1. Log in to the TencentDB for MongoDB purchase page with a Tencent Cloud account.
2. On the purchase page, configure the multi-AZ deployment parameters.

In the Billing Mode field, select a billing mode as needed. Pay-as-you-go is supported. For more information, see
Billing Overview.
In the Region field, select the region of the multi-AZ deployed instance. We recommend that you select the region
closest to your end users to minimize the access latency.
In the AZ field, you can click Multi-AZ Deployment and select the AZ in the drop-down lists after Primary Node,
Secondary Node 1, and Secondary Node 2 respectively. To guarantee a smooth cross-AZ switch, multi-AZ
deployment does not support deploying most cluster nodes in the same AZ; that is, the primary and secondary nodes
can be deployed only in three different AZs separately.
For more information on how to configure other parameters, see Creating TencentDB for MongoDB Instance.
3. If you select Pay as You Go, you can click Billing Details to view product pricing and confirm the total fees.
4. Click Buy Now. After the purchase success message is displayed, click Go to Console to enter the instance list
page. After the instance status in the Monitoring/Status column becomes Running, the multiple AZs of the instance©2013-2022 Tencent Cloud. All rights reserved.

Page 191 of 257

TencentDB for MongoDB

will be displayed in the AZ column.

Accessing a multi-AZ deployed instance
You can use MongoDB Shell or a concatenated URI through the SDK client for multiple programming languages toaccess a multi-AZ deployed instance. For detailed directions, see Connecting to TencentDB for MongoDB Instance.

Upgrading from single-AZ deployment to multi-AZ deployment
You can upgrade a single-AZ deployed instance to a multi-AZ deployed instance. For detailed directions, see
Modifying Instance AZ.

©2013-2022 Tencent Cloud. All rights reserved.

Page 192 of 257

TencentDB for MongoDB

Disaster Recovery/Read-Only Instances
Overview：

Last updated 2024-01-15 14:40:06

Basic Concepts
Read-only instance
TencentDB for MongoDB allows you to create one or multiple read-only instances in the source instance AZ or another
AZ based on the cluster architecture and storage engine of the source instance. The data in the source instance will
be automatically synced to read-only instances, which are granted the read-only permission. In this way, the readrequests of the source instance can be distributed to read-only instances to increase the read/write performance andapplication throughput.

Disaster recovery instance
TencentDB for MongoDB allows you to create one or multiple disaster recovery instances in another region based on
the cluster architecture and storage engine of the source instance. The data in the source instance will be
automatically synced to disaster recovery instances, which are granted the read-only permission. When the region of
the source instance is disconnected due to a force majeure event such as power outage or network issue, a disasterrecovery instance can be promoted to primary instance to implement cross-region disaster recovery and quickly
sustain business needs. This helps you improve the business continuity at low costs and guarantee the data reliability.

Differences between read-only instance and disaster recovery instance
Both read-only and disaster recovery instances are built based on the cluster architecture and storage engine of thesource instance. They have the following differences:
Difference

Description

Read-Only InstanceDisaster Recovery InstanceArchitecturetype

The systemarchitecture of a readonly or disasterrecovery instancecluster, which can be
replica set or
sharded cluster but
not single-node.

Same as that of the source
instance.

Same as that of the source
instance.

No

Yes

Cross-region

Whether a read-onlyor disaster recovery©2013-2022 Tencent Cloud. All rights reserved.

Page 193 of 257

TencentDB for MongoDB

instance can becreated in anotherregion based on thesource instance.
Whether a read-onlyor disaster recovery
instance can be
Cross-AZ

created in another AZ

Yes

Yes

Same as that of the source
instance and cannot be

Same as that of the source
instance and cannot be

upgraded.

upgraded.

Same as that of the source

Same as that of the source

instance.

instance.

Cannot be lower than those of thesource instance.

Cannot be lower than thoseof the source instance.

No

No

No

No

account creation anddeletion.

No

No

Manualdisassociation

Whether you canmanually disassociate

No. Only after the source
instance is terminated can aYes. You can promote a
disaster recovery instance tofrom thea read-only or
disaster recovery

read-only instance bedisassociated from it

primary instance, and it will
become a general instancein the current region
based on the source
instance.
The compatible
Database

MongoDB version,
including v4.4, v4.2,

versionv4.0, v3.6, and v3.2.
v3.2 is no longer for
sale.

StorageengineThe storage engine,which is WiredTiger
by default.
The CPU, memory,

Instance
specifications

and disk capacity
requirements of aread-only or disasterrecovery instance toguarantee the service
capacity.
Data write andData write

database creationand deletion

Backup androllback

Data backup andrestoration.

Account
management

Database access©2013-2022 Tencent Cloud. All rights reserved.

Page 194 of 257

TencentDB for MongoDB

sourceinstance from theautomatically. Afterthat can be read/written

instance

source instance in the
console.

disassociation, the read-only
instance will be promoted togeneral instance and can benormally to quickly sustain
the business needs.

read/written normally.

AZ upgrade

Whether the singleAZ deployment of aread-only or disasterrecovery instance canbe upgraded to multi-

Yes

Yes

AZ deployment.

How It Works
Read-only and disaster recovery instances can be understood as a data sync service, which continuously syncs theexisting and incremental data (including databases, collections, indexes, and documents) of the source instance to thetarget read-only or disaster recovery instance and grants the target instance only the read-only permission to relieve
the pressure on the source cluster.
Once a read-only or disaster recovery instance is created, full data sync will be initiated, and data sync operations will
be logged as oplog. After full data sync is completed, the oplog can be replayed to keep incrementally syncingchanged or added data. This works similarly to primary-secondary sync in a replica set. The entire process has twostages:Full sync stage, where full data is synced. Before it starts, the latest oplog timestamp of the source cluster will berecorded. After it starts, the metadata, indexes, and data in all collections in the source cluster will be read andconcurrently inserted to collections with the same name in the target. The duration of full sync is proportional to thedata volume of the source cluster.
Incremental sync stage, which follows the full sync stage. During this stage, the oplog of the source cluster will bepulled based on the oplog timestamp recorded when the full sync stage starts and then replayed in the target.

©2013-2022 Tencent Cloud. All rights reserved.

Page 195 of 257

TencentDB for MongoDB

Latency description
Due to the delay in data sync, the real-timeness of data sync for read-only instances may not be guaranteed. If yourbusiness requires read/write separation and high real-timeness, we recommend that your business read thesecondary nodes of the primary instance. For more information, see Connecting to TencentDB for MongoDB Instance.
You can log in to the console and go to the RO/DR page to view the status and latency of sync from the primary
instance to the target instance.

Performance optimization
Similar to concurrent replay of MongoDB replica set oplogs, the read-only/disaster recovery data sync service pulls
the oplogs to the cache, parses them concurrently, hashes them by collection name to ensure that the oplogs aresequential at the collection level, linearly hashes each oplog segment by document ID to assign oplogs of the same
document to the same thread, and then concurrently sends the threads to the target instance. This guarantees theincremental data sync performance and keeps the sync latency within seconds.

Data security
During incremental sync, the sync service persistently stores the currently synced latest oplog timestamp, and thereplay process of the sync service is idempotent. Therefore, the sync service supports checkpoint restart during the©2013-2022 Tencent Cloud. All rights reserved.

Page 196 of 257

TencentDB for MongoDB

incremental sync stage. Even if a failure occurs in the source or target cluster, data security issues won't occur in thesync service.
During incremental data sync, if a primary/secondary switch occurs in the target cluster due to a disk failure or
network issue, data may get lost. To address this problem, TencentDB for MongoDB adds an oplog that records thesync progress. The data sync service regularly inserts a sync progress record into the oplog transactions of the target
cluster. After a new primary node takes effect, it will locate the latest record in its oplog transactions and sync the data
again to prevent data loss.

Sync stability
Each read-only or disaster recovery instance is sustained by a separate data sync service, and each data sync
service uses distributed locks and the lease mechanism to guarantee the service uniqueness and availability, monitors
the sync task in real time, and fine-tunes the instance regularly to guarantee the data sync stability and reliability.

Impact and Limits
Impact on the source cluster
The impact of the read-only and disaster recovery data sync service is only limited to secondary nodes, and data will
be pulled from a secondary node (hidden one preferably) in the source cluster.
During full data sync, the getMore request is used to continuously pull data.
During incremental data sync, the getMore request is used to continuously pull oplogs.
During both the full and incremental data sync stages, the sync service will create a cursor for sequential reads on thesecondary node to mark the read progress, which has little impact on the secondary node.

Use limits
Read-only and disaster recovery instances belong to the source instance and cannot exist independently.
Read-only and disaster recovery instances will be unwritable after being created.
After the source instance is terminated, the system will automatically disconnect the sync service and promote a readonly instance to general instance for normal read/write.
Database version: For sharded clusters, read-only and disaster recovery instances can be on versions 4.0, 4.2, and4.4. For replica sets, they can be on versions 3.2, 3.6, 4.0, 4.2, and 4.4. If the current instance has a read-only or
disaster recovery instance, the database versions of both the current instance and the read-only or disaster recovery
instance cannot be upgraded.
Quantity: You can create up to three read-only instances and up to three disaster recovery instances for an instance.
Cluster architecture and storage engine: The cluster architecture and storage engine of a read-only or disasterrecovery instance are always the same as those of the source instance and cannot be changed.
Account management: When a read-only or disaster recovery instance is created, the account information in thesource instance will be synced to it automatically. You cannot create or delete accounts in it. If the access account or©2013-2022 Tencent Cloud. All rights reserved.

Page 197 of 257

TencentDB for MongoDB

password in the source instance is changed, the account won't be automatically synced to it. You need to manually
modify the account information in it during connection; otherwise, an error will occur, and connection will fail.
Due to network isolation, you cannot create disaster recovery instances in finance zones for source instances ingeneral regions, and vice visa.
Backup and rollback: They are not supported for both read-only and disaster recovery instances.
Data migration: Migrating data to read-only or disaster recovery instances is not supported.

Sync limits
Read-only or disaster recovery instance sync in a replica set is implemented by parsing oplogs, and all DDL
operations are supported.
Read-only or disaster recovery instance sync in a sharded cluster is implemented by parsing change streams. Achange stream covers an oplog with a layer of application and provides an API to push data in real time. In addition tobasic CRUD operations, DDL operations related to database/collection structures and indexes are also supported forthe pushed data, including createIndexes , drop , rename , dropDatabase , create ,createIndexes , dropIndexes , collMod , and convertToCapped .

Billing Overview
The billing mode of a read-only or disaster recovery instance is the same as that of the source instance. You canselect a billing mode based on your business needs. The pay-as-you-go billing mode is supported, and billable items
include compute and storage resources. For more information, see Billing Overview.

©2013-2022 Tencent Cloud. All rights reserved.

Page 198 of 257

TencentDB for MongoDB

Creating Read-Only Instances：

Last updated 2024-05-07 12:52:26

Scenario Description
In application scenarios with a small amount of write requests but a large number of read requests, a single instance
may not withstand the reading pressure, and may even impact the core business. You can create one or more newread-only instances in the source instance's availability zone or other availability zones based on the current instance's
cluster architecture and storage engine. This shifts the read requests from the current instance to the read-only
instances, achieving elasticity in read capability, enhancing read/write performance, and increasing the application's
throughput.

Notes
Due to data synchronization delays, the real-time performance of data synchronization in read-only instances might
not be guaranteed. If the business requires read-write separation and has high real-time requirements, it isrecommended to read from the secondary node of the primary instance. The synchronization latency between eachread-only instance and the primary instance can be checked on the console.
The connection method for the read-only instance is the same as that of the primary instance. See Connecting to
MongoDB Instance.
During the lifecycle of a read-only instance, it can only perform read operations and cannot execute data write or
update operations.
Read-only instances do not support manual disconnection from the source instance. They are automaticallydisconnected from the source instance only when the source instance is terminated. The read-only instance thenbecomes a standard instance, capable of normal reading and writing.

Version Description
The current MongoDB versions 3.2, 3.6, 4.0, 4.2, 4.4, and 5.0 support the creation of read-only instances for replica
set instances. Sharded instances are supported only in versions 4.0 and above.

Prerequisites©2013-2022 Tencent Cloud. All rights reserved.

Page 199 of 257

TencentDB for MongoDB

The current instance is operating normally but with a high read request volume and significant latency, leading to slow
database performance. For more information, see Monitoring Overview.
The availability zone for the read-only instance and its associated network have been planned.
The storage specifications and purchase quantity for the read-only instance have been estimated.
The billing model has been selected based on the business scenario, and the costs associated with the read-only
instance have been budgeted.

Creating Read-Only Instance
1. Log in to the MongoDB console.
2. On the left sidebar, choose NoSQL > MongoDB.
3. In the MongoDB drop-down list, select Replica Set Instance or Sharded Cluster. The operations for replica sets
and sharded clusters are similar.
4. Above the instance list on the right, select the region.
5. In the instance list, find the target instance.
6. Click the target instance ID to enter the Instance Details page.
7. Select the Read-Only Disaster Recovery tab to access the Read-Only Instance page.
8. On the Read-Only Instance page, click Create.
9. On the TencentDB for MongoDB Read-Only Instance purchase page, confirm the Primary Instance
Information and select the required configuration.

©2013-2022 Tencent Cloud. All rights reserved.

Page 200 of 257

TencentDB for MongoDB

See the table below to configure the instance specifications based on your actual needs.
Parameter Name
Billing Mode

Parameter Description
Monthly subscription and pay-as-you-go billing are supported. For how to choose a billingmode, see Billing Overview.

RegionThe region of the read-only instance is fixed and matches that of the source instance. It
cannot be changed.

Availability Zone

Select whether to enable multiple availability zone deployment. Settings can be adjusted
based on actual highly available business requirements.

Database Version

Architecture TypeThe database version is fixed and matches that of the source instance. It cannot bechanged.
The architecture type is fixed and matches that of the source instance. It cannot bechanged. For specific information about the architecture type, see System Architecture.

Storage Engine

The default storage engine is WiredTiger.

MongodSpecification

Select the compute specifications for the database instance from the dropdown list. The
CPU core number and memory capacity of a read-only instance must be equal to or
greater than those of the source instance, with higher specifications resulting in higher
IOPS. For specific supported specifications, see Product Specification.
After creating an instance, you can adjust its compute specifications. For specificoperations, see Adjusting Instance Configuration.

©2013-2022 Tencent Cloud. All rights reserved.

Page 201 of 257

TencentDB for MongoDB

MongoDB Shard
Quantity

When the architecture type is set to Sharded Cluster, this parameter is displayed. It is
used for setting the number of shards in the sharded cluster, with a value range of [1,20].
The shard quantity of a read-only instance must be greater than or equal to that of thesource instance. Each shard is a replica set. Increasing the shards quantity can enhance
the cluster's storage capacity. Select as needed.
After creating an instance, you can adjust the MongoDB shard quantity. For specificoperations, see Adjusting Instance Configuration.
Select the database instance's storage capacity on the slider. The disk capacity of aread-only instance must be greater than or equal to that of the source instance. MongoDB

Disk Capacity

Primary/Secondary
Nodes Quantity

specifications differ, hence the range of disk capacities varies. See Product Specification.
The system by default allocates 10% of the selected storage capacity for Oplog's storage
space. The size of Oplog can be adjusted in the console instance list. For specificoperations, see Adjusting Oplog Storage Capacity.
After creating an instance, you can adjust the instance's disk capacity. For specificoperations, see Adjusting Instance Configuration.
When the architecture type is set to replica set, this parameter is displayed. The default is
3 nodes (1 primary, 2 secondaries), with three storage nodes forming a one-primary-twosecondary architecture. Custom replication numbers are not currently adjustable. You
may select from the dropdown list: 5 nodes (1 primary, 4 secondaries), or 7 nodes (1primary, 6 secondaries).
After creating a read-only instance, you can increase the number of secondary nodes. For
specific operations, see Adding Secondary Node.
When the architecture type is set to Sharded Cluster, this parameter is displayed. It is

Primary/Secondary
Nodes Quantity
per Shardused for setting the number of nodes in each shard of the sharded cluster, with the default
being 3 nodes (1 primary, 2 secondary nodes), meaning each shard follows a oneprimary-two-secondary, three-node architecture. You can select from the dropdown list: 5
nodes (1 primary, 4 secondary nodes), or 7 nodes (1 primary, 6 secondary nodes).
Custom node numbers are not currently supported. After creating the instance, you canincrease the number of secondary nodes per shard. For specific operations, see Adding
Secondary Node.

Read-Only Node
Quantity

Configuration
Instructions
MongosSpecifications

Setting the number of read-only nodes, supporting 0 to 5 read-only nodes. Only versions
4.0 and 4.2 support configuring the number of read-only nodes; version 3.6 does notsupport this.
After creating a read-only instance, you can increase the number of read-only nodes. For
specific operations, see Adding Read-Only Node.
Based on the configured MongoDB specification, calculate the maximum number ofconnections per instance to help you predict whether the current specification meets
expectations.
When the architecture type is set to Sharded Cluster, this parameter is displayed. It is
used for configuring Mongos specifications. After configuring the MongoDB specification,©2013-2022 Tencent Cloud. All rights reserved.

Page 202 of 257

TencentDB for MongoDB

Mongos will have default specification configurations. For example, if MongoDB is set to
2-core 4GB, Mongos is automatically configured for 1-core 2GB by default. Upgrading theMongos specification will incur charges. For pricing, see Product Pricing. The connection
limit for a sharded cluster will be determined by the Mongos specifications and quantities
you choose. You can view the maximum number of connections in the Configuration
Instructions.
After creating an instance, you can change the Mongos configuration. For specificoperations, see Changing Mongos Node Configuration Specifications.
When the architecture type is set to Sharded Cluster, this parameter is displayed. It is
used for configuring the number of Mongos. If the instance deployment is in the same

Mongos Quantity

availability zone, the range of Mongos numbers is [3, 32]. If the multi-availability zone
deployment is enabled and the instance deployment is across different availability zones,
then the range of Mongos numbers is [6, 32]. Increasing the number of Mongos will incurcharges. For pricing, see Product Pricing.
After creating an instance, you can adjust the number of Mongos. For specific operations,
see Add New Mongos Node.

Network Type

Only Virtual Private Cloud is supported.
Select a specific Virtual Private Cloud and its subnet. It is recommended to select the

IPv4 Network

same Virtual Private Cloud in the same region as the cloud server. A Virtual Private Cloudhas a region attribute (e.g., Guangzhou), while a subnet has an availability zone attribute(e.g., Guangzhou Zone 1). A Virtual Private Cloud can be divided into one or more
subnets. Subnets under the same Virtual Private Cloud are by default inter-connected
through intranet, whereas Virtual Private Clouds (whether in the same region or not) areby default isolated from each other.
After purchasing an instance, you can switch the Virtual Private Cloud. For specificoperations, see Switch Instance Network. You can also click Create a New Virtual
Private Cloud and Create a New Subnet to recreate the required network
environment. For specific operations, see Creating Virtual Private Cloud.

IPv6 Network

Security Group

Enable/disable IPv6 access. Currently not supported.
Set security group rules for the instance to control inbound traffic to the database. You
can select an existing security group from the dropdown menu, or click Custom Security
Group to set new inbound rules for the security group. For detailed information, see
Configuring Security Group.

Specify Project

Allocate the instance to the corresponding project. You can manage instances by project.

Tag

Set tags for your instance. You can classify and manage instances based on tags. Click
Add to select tag keys and values.

Instance Name

Set the instance name, with a default of 500. Set a recognizable name.
Supports Chinese, English, and numbers with a length less than 60, including hyphens "-"and underscores "_".

©2013-2022 Tencent Cloud. All rights reserved.

Page 203 of 257

TencentDB for MongoDB

Purchase Quantity

A single instance can support up to 3 read-only instances.

Purchase Period

When choosing monthly subscription, you need to select the purchase duration of theinstance. The longer the duration, the greater the discount. You can choose according to
your actual business needs.

Total Fees

Pay-as-you-go, displaying the hourly cost. Click Billing Details, and see Product Pricing.

10. Confirm that the configuration is correct, click Purchase Now. After the purchase is successful, click Go toConsole. In the instance list, once the instance status shows as Running, it can be used normally.

Viewing Read-Only InstanceView the source instance from the read-only disaster recovery page.
1. Log in to the MongoDB console.
2. In the MongoDB drop-down list on the left sidebar, select Replica Set Instance or Sharded Instance. The
operations for the two types of instances are similar.
3. Above the instance list on the right, select the region.
4. In the instance list, find the source instance of the read-only instance.
You can search for the target instance by entering the instance ID, instance name, private network IP or tag key in the
search box in the upper right corner of the instance list.
If the instance is not found in the instance list, select Recycle Bin from the left sidebar to confirm whether the instancehas been isolated in the recycle bin due to expiration of fees. For more information, see Recycle Bin.
5. In the Instance ID / Name column of the source instance, click the instance ID to enter the Instance Details
page.
6. Click the Read-Only Disaster Recovery tab and select the Read-Only Instance tab.

7. View all the read-only instances under the source instance.
Parameter
Instance ID
StatusParameter Description
Read-only instance ID and its name. Click the instance ID in blue font to jump to the read-only
instance details page. For more information, see Viewing Instance Details.
The current running status of the instance. When it is normal, it should be Running.

©2013-2022 Tencent Cloud. All rights reserved.

Page 204 of 257

TencentDB for MongoDB

Specification

Instance specification information. It includes memory and disk capacity.

Latency

The read-only instance is based on the synchronization status from the source instance, and its
latency.

Nodes
Quantity

The number of primary and secondary nodes in a read-only instance.

Network

The name of the Virtual Private Cloud to which the read-only instance belongs.

PrivateThe private IPv4 address assigned by the Virtual Private Cloud. When accessing the database,Network
Address

the private IP address and its port information need to be configured. For specific operations,see Connecting to MongoDB Instance.

RegionInformation about the region and availability zone.

Deadline

With monthly subscription, it displays the specific time point of the instance expiration. It is
empty for pay-as-you-go billing.
By clicking configuration changes, you can adjust the specifications of the read-only instance.

Operation

When adjusting the specifications of the source instance, be sure to synchronously upgrade thespecifications of the read-only instance; otherwise, data loss may occur.

©2013-2022 Tencent Cloud. All rights reserved.

Page 205 of 257

TencentDB for MongoDB

Creating Disaster Recovery Instance：

Last updated 2024-01-15 14:40:06
TencentDB for MongoDB allows to you create and manage disaster recovery instances in the console.

Background
TencentDB for MongoDB allows you to create one or more disaster recovery instances. For applications with highrequirements of service continuity, data reliability, and compliance, such instances help enhance your capability todeliver continued services at low costs and improve data reliability.
Note:
Due to the delay in data sync, the real-timeness of data sync for disaster recovery instances may not be guaranteed.
Sync latency between the disaster recovery instances and the primary instance can be viewed in the console.
A disaster recovery instance can only be read but not written during its lifecycle.
When a disaster recovery instance is disconnected from the primary instance during sync or is promoted to theprimary instance manually in the console, it will become a general instance that can be normally read/written.

Version Requirement
Currently, only TencentDB for MongoDB 3.2, 3.6, and 4.0 instances support disaster recovery instance creation.

Use Limits
Up to three disaster recovery instances can be created for a primary instance.
Backup and rollback: They are not supported.
Data migration: Migrating data to disaster recovery instances is not supported.
Database management: Database creation and deletion are not supported.
Account management: Account creation/deletion, password reset, and account authorization are not supported.
The engine of a disaster recovery instance must be the same as that of the primary instance.
Due to network isolation, you cannot create disaster recovery instances in finance zones for primary instances ingeneral regions, and vice visa.

Prerequisites©2013-2022 Tencent Cloud. All rights reserved.

Page 206 of 257

TencentDB for MongoDB

You have applied for a TencentDB for MongoDB instance.
The replica set instance is running normally.

Directions
You can view, create, and renew disaster recovery instances, adjust their configurations, and set auto-renewal forthem in the console.

Viewing disaster recovery instance
1. Log in to the TencentDB for MongoDB console.
2. On the left sidebar, select NoSQL > MongoDB.
3. In the MongoDB drop-down list, select Replica Set Instance or Sharded Cluster Instance. The operation steps
for both instance types are similar.
4. Above the instance list on the right, select the region.
5. In the instance list, find the target instance.
6. Click the target instance ID to enter the Instance Details page.
7. Select the RO/DR > DR Instance tab.
8. View the new disaster recovery instances under the current instance.

Creating disaster recovery instance
1. On the DR Instance tab, click Create.
2. On the TencentDB for MongoDB DR Instance purchase page, confirm the primary instance information andselect the required configuration.
3. Click Buy Now. After the purchase, you can return to the DR Instance tab to manage disaster recovery instances.

Adjusting disaster recovery instance configuration
1. On the DR Instance tab, find the target disaster recovery instance.
2. In the Operation column, click Adjust Configuration.
3. On the Adjust Configuration page, you can adjust the node specification, node capacity, and oplog capacity.
4. In the Switch Time option, select the specific time for instance specification switch.

©2013-2022 Tencent Cloud. All rights reserved.

Page 207 of 257

TencentDB for MongoDB

If you select Upon modification completion, the instance specification adjustment task will be executed
immediately.
If you select Maintenance time, the instance specification switch task will be executed during the maintenance time.
Note:
We recommend you set the maintenance time to be within off-peak hours of your business, and you need toregularly maintain your instance. If you select Upon modification completion, the instance configuration will be
adjusted immediately, which may involve node migration or primary-secondary switch. As the switch time point is
uncontrollable, we strongly recommend you make the instance configuration executed within the maintenance time.
For more information, see Setting Instance Maintenance Period.
5. You can click Billing Details to view billable items and billing formula and confirm the fees.
6. After confirming that everything is correct, click Submit.

Renewing disaster recovery instance
1. On the DR Instance tab, find the target disaster recovery instance.
2. Click Renew above the instance list and select the renewal period in the Renew Selected Instance window.
3. Confirm the total renewal fees and click OK.

Setting auto-renewal
1. On the DR Instance tab, find the target disaster recovery instance.
2. Click Set Auto-Renewal above the instance list and confirm the auto-renewal item and renewal expiration time in
the Set Auto-Renewal window.
3. Confirm the total renewal fees and click OK.

Disabling auto-renewal
1. On the DR Instance tab, find the target disaster recovery instance.
2. Click Disable Auto-Renewal above the instance list and confirm the instance information.
3. Click OK.

Related APIsAPI

Description

DescribeDBInstances

Queries TencentDB instance list

RenameInstance

Renames instanceRenewDBInstances

Renews TencentDB instance

ModifyDBInstanceSpec

Adjusts TencentDB instance configuration©2013-2022 Tencent Cloud. All rights reserved.

Page 208 of 257

TencentDB for MongoDB

Parameter Configuration：

Last updated 2024-01-15 14:40:06
TencentDB for MongoDB allows you to adjust certain database parameters, so that the database features can better
adapt to your business needs.

Overview
In the daily Ops process, quickly adjusting database parameters can optimize the query and management
performance of the database in a targeted manner for ever-changing business scenarios. In addition, the parameter
modification records can be viewed at any time for evidence-based problem locating.

Version Description
Currently, TencentDB for MongoDB 3.2 and later support database parameter modification. However, there aredifferences in the modifiable parameters on each version as displayed in the console.

Note
Currently, the parameter modification feature only supports parameters that can take effect without requiring a restart
after modification. It will support other parameters in future iterations. You can also restart the instance on the
MongoDB terminal, but the restart will cause a disconnection. Therefore, make business arrangements in advanceand proceed with caution.
When updating the cluster architecture or configuration, such as adjusting specifications, nodes, or shards, upgrading
nodes, and migrating nodes, you don't need to configure parameters repeatedly, as the system will automatically sync
the parameter configuration data.

Prerequisites
You have created a TencentDB for MongoDB instance. For more information, see Creating TencentDB for MongoDB
Instance.
The instance is running normally.

©2013-2022 Tencent Cloud. All rights reserved.

Page 209 of 257

TencentDB for MongoDB

Directions
Querying the parameter configuration
1. Log in to the TencentDB for MongoDB console.
2. On the left sidebar, select Replica Set Instance or Sharded Cluster Instance. The directions for the two typesof instances are similar.
3. In the instance list on the right, find the target instance.
4. Click the target instance ID to enter the Instance Details page.
5. Select the Parameter Settings tab to view the database parameter configuration.

Modifying the parameter configuration
1. On the Modifiable Parameters tab, click Modify Current Value.
2. In the input box in the Current Value column, set the desired parameter value as shown below:
Note:
You can modify multiple parameters at the same time.
When modifying parameters, be sure to set them according to the acceptable values.
In the Restart upon Modification column, check whether the instance will be restarted. The restart will cause a
disconnection. Therefore, make business arrangements in advance and proceed with caution.
The acceptable values of parameters depend on the instance version and architecture. The parameters that can be
modified on the current version are as listed below:

Parameter

RestartRequired

Default
Value

Acceptable
ValuesSupport
Versionoperation.profiling.slowOpThresholdMs

No

100

[0-65536]

4.0, 4.2
4.4

operationProfiling.mode

No

off

[off | slowOp| all]

4.0, 4.2
4.4©2013-2022 Tencent Cloud. All rights reserved.

Page 210 of 257

TencentDB for MongoDB

setParameter.cursorTimeoutMillis©2013-2022 Tencent Cloud. All rights reserved.

No

600000[12147483647]

3.2, 3.6
4.0, 4.2
4.4

Page 211 of 257

TencentDB for MongoDB

setParameter.intenalQueryExecMaxBlockingSortBytes©2013-2022 Tencent Cloud. All rights reserved.

No33554432[33554432268435456]

4.0, 4.2
4.4

Page 212 of 257

TencentDB for MongoDB

setParameter.maxTransactionLockRequestTimeoutMillis

No5[0-60]

setParameter.transactionLifetimeLimitSecondsNo60[5-300]©2013-2022 Tencent Cloud. All rights reserved.

4.0, 4.2
4.4

4.0, 4.2
4.4

Page 213 of 257

TencentDB for MongoDB

setParameter.failIndexKeyTooLong

No

true

[true | false]

3.2, 3.6
4.0©2013-2022 Tencent Cloud. All rights reserved.

Page 214 of 257

TencentDB for MongoDB

balance.window

No

NULL

openBalance.window

No

false

[00:00 |4.0, 4.2

23:00]

4.4[true | false]

4.0, 4.2
4.4

3. Click OK.

Querying the parameter modification record
1. On the Parameter Settings tab, click Modification Log.
2. View the parameter modification log, including values before and after modification, modification status, andmodification time.

©2013-2022 Tencent Cloud. All rights reserved.

Page 215 of 257

TencentDB for MongoDB

Recycle Bin：

Last updated 2024-01-15 14:40:06
Terminated instances will be put into the recycle bin and can be restored.

Overview
Tencent Cloud recycle bin offers a mechanism for repossessing cloud services. If your account balance is sufficient,
you can restore terminated instances that are still in the recycle bin.

Version Description
Currently, TencentDB for MongoDB 3.2, 3.6, 4.0, 4.2, 4.4, and 5.0 support instance repossession.

Note
The repossession of instances in different billing modes is as described below:
Monthly Subscribed Instances in the Recycle Bin
Pay-as-You-Go Instances in the Recycle Bin
Retention period: Instances will be retained in the recycle bin for 7 calendar days.
Expiration processing: Instances that are not renewed within 7 calendar days will be released and cannot be
restored.
Note:
The system will send you a renewal notification 7 days before the expiration of a TencentDB instance. On the 8th day
after expiration, the instance will become unavailable and be moved to the recycle bin.

Retention period: If your account has no overdue payments, terminated instances will be retained in the recycle binfor 3 days.
Expiration processing: Instances that are not renewed before the retention period ends will be released and cannot
be restored.
Note:
After the account balance becomes 0, instances will be automatically shut down and moved from the instance list to
the recycle bin, and the billing will stop in 24 hours.
You cannot restore pay-as-you-go instances from the recycle bin if your account has overdue payments. You need to
top up your account first.

©2013-2022 Tencent Cloud. All rights reserved.

Page 216 of 257

TencentDB for MongoDB

Pay-as-you-go instances are retained in the recycle bin for a maximum of 3 days. You need to top up your account intime to restore the instances.

Prerequisites
The TencentDB for MongoDB instance has been terminated.
Your Tencent Cloud account balance is sufficient.

Directions
Instances in the recycle bin can be renewed, restored, or eliminated.

Viewing an instance in the recycle bin
1. Log in to the TencentDB for MongoDB console.
2. On the left sidebar, select MongoDB > Recycle Bin.
3. Above the Instance List on the right, select the region.
4. On the Recycle Bin page on the right, you can see the list of instances in the recycle bin.

Restoring one instance
1. In the instance list in the recycle bin, find the target instance and click Restore in the Operation column.
2. In the Restore Instance window, confirm the instance information and click OK.
The instance will return to their original instance list from the recycle bin.

Batch restoring instances
1. In the instance list in the recycle bin, select the target instances.
2. Click Batch Restore above the list, confirm the instance information in the Restore Instance window, and click
OK.
The instance will return to their original instance list from the recycle bin.

Eliminating an instance
1. In the instance list in the recycle bin, find the target instance and click Eliminate Now in the Operation column.
2. In the Instance Elimination window, confirm the instance information and click OK.

©2013-2022 Tencent Cloud. All rights reserved.

Page 217 of 257

TencentDB for MongoDB

Note:
The instance will be completely eliminated, and its data will not be recoverable. Therefore, you need to back up thedata in advance.

©2013-2022 Tencent Cloud. All rights reserved.

Page 218 of 257

TencentDB for MongoDB

Task Management：

Last updated 2024-01-15 14:40:06
TencentDB for MongoDB allows you to intuitively and quickly track the task execution progress in the console.

Background
Daily OPS involves massive and diverse tasks. Task management can help you quickly and efficiently find tasks andstay up to date with their execution status.

Version Description
Currently, TencentDB for MongoDB 4.4, 4.2, 4.0, 3.6, and 3.2 support viewing task execution records.

Prerequisites
You have applied for a TencentDB for MongoDB instance.
The TencentDB for MongoDB replica set or sharded instance is in Running status.

Directions
You can view the task records and details in the console.

Viewing task record
1. Log in to the TencentDB for MongoDB console.
2. On the left sidebar, select MongoDB > Task Management.
3. Above the instance list on the right, select the region.
4. On the Task Management page on the right, you can see all task records.
Hover over the Task Progress progress bar to view the task execution process.

©2013-2022 Tencent Cloud. All rights reserved.

Page 219 of 257

TencentDB for MongoDB

Filtering task by time
1. Above the task list, you can select Today, Last 24 hours, Last 7 days, Last 30 days, or a time period to filter thetasks to be viewed.
2. In the task list, find the task record to be viewed.

Filtering task by instance name
1. In the search box in the top-right corner of the task list, you can filter the tasks to be viewed by instance name.
2. In the task list, find the task record to be viewed.

Viewing task details
1. In the task list, find the target task and click Task Details in the Operation column.
2. In the Task Details window, view the task execution details.
3. Then, click Close.

©2013-2022 Tencent Cloud. All rights reserved.

Page 220 of 257

TencentDB for MongoDB

Performance Optimization：

Last updated 2024-01-15 14:40:06
TencentDB for MongoDB is connected to the performance optimization feature of DBbrain. The feature monitors anddiagnoses database instance exceptions in real time, automatically generates health reports, and gives expert
optimization suggestions. This helps you stay on top of the running status of the current database, quickly locate andtroubleshoot issues, and promptly optimize the database performance.

Viewing the performance optimization
1. Log in to the TencentDB for MongoDB console.
2. On the left sidebar, select Performance Optimization.
3. At the top of the Performance Optimization page of DBbrain, select the target instance in the Instance ID dropdown list.

4. View and analyze the diagnosis data of the instance.
Monitoring Type

Description

Exception
diagnosis

Performs real-time performance monitoring and health inspections on the database andgives diagnosis prompts and optimization suggestions for failures.

PerformancetrendsMonitors performance metrics of instances and Mongod nodes, such as resources,
requests, and primary/secondary delay.

Real-time
sessionCollects the information of database client sessions in real time, such as the sources andnumber of sessions as well as the number of active sessions.

Slow log
analysisAnalyzes the number and duration of slow queries of instances and Mongod nodes in realtime.

Space analysis

Analyzes the database space utilization, including the sizes of data and logs, the daily
increase in space utilization, and the estimated number of available days.

MongoStatus

Collects and analyzes the number of requests, updates, deletions, and connections as wellas outbound/inbound traffic of the database.

MongoTop

Collects the top data of the database in terms of write operation, read operation, and total©2013-2022 Tencent Cloud. All rights reserved.

Page 221 of 257

TencentDB for MongoDB

request duration.
Controls scenarios where excessive CPU resources are consumed due to high traffic. You
SQL throttling

can create SQL throttling tasks to control the number of access requests and SQL
concurrency, thereby ensuring a high service availability.

Index

Collects the real-time information of slow queries, automatically analyzes it, andrecommendation

recommends the optimal global index.

Health report

Scores the instance health based on monitoring metrics and statistics.

©2013-2022 Tencent Cloud. All rights reserved.

Page 222 of 257

TencentDB for MongoDB

Data Migration Guide
Creating Migration Task：

Last updated 2024-05-07 10:08:50

Overview
DTS is a data transfer service with data migration, sync, and subscription features. DTS for MongoDB helps migrate
your database to the cloud without interrupting your business. In its full + incremental data migration mode, historical
data in the source database written before migration and incremental data written during migration can be migrated
together.

Use Cases
DTS supports data migration for the following source and target databases:
SourceTarget

Notes
Additionally, it facilitates the migration from

Self-built MongoDB
database in IDC and CVM

TencentDB for MongoDB

TencentDB for MongoDB to self-built
databases.

Third-party MongoDB
database

TencentDB for MongoDB-

TencentDB for MongoDB

Migration scenarios between TencentDB for
MongoDB instances include:
Migration between TencentDB instances in thesame or different regions.
Migration between TencentDB instances under
the same or different accounts.
Migration between TencentDB for MongoDB
instances on different versions.
Migration between TencentDB for MongoDB
replica set and sharded clusters.

TencentDB for MongoDB

Use Limits
During migration, do not perform the following operations; otherwise, the migration task will fail:©2013-2022 Tencent Cloud. All rights reserved.

Page 223 of 257

TencentDB for MongoDB

Do not modify or delete user information (including username, password, and permissions) in the source and target
databases and port numbers.
Do not clear oplogs in the source database.
Do not delete the target database TencetDTSData during data migration.
Manipulate data in the target database with caution during data migration; otherwise, data inconsistency may occur.
As DTS will filter out the DDL operations of the sharded cluster, do not perform DDL operations other thantransactions on the source database during shard migration; otherwise, data inconsistency may occur.
If you only perform full data migration, do not write new data into the source instance during migration; otherwise, thedata in the source and target databases will be inconsistent. In scenarios with data writes, to ensure the dataconsistency in real time, we recommend that you select full + incremental data migration.
If the source is a TencentDB for MongoDB 3.2 sharded cluster, all shard keys will be treated as hash shard keys
during migration by default. If you want to use range shard keys in the target, create them in the target first before data
migration.
We recommend that you clean up the orphaned documents in the source cluster in advance before migrating thesharded cluster. Otherwise, it may cause data inconsistency after migration. For more information on the operation,
see cleanupOrphaned.
During incremental migration of a shard, do not enable data sharding on the source database; otherwise data of thetarget and source database will be inconsistent; if data sharding is enabled, check the status of the shard on the target
database and re-enable it. For more information on enabling a shard, see Shard a Collection.
The DTS migration supports DDL operations on both source replica set and sharded cluster.
Operation
Type

Supported SQL Operations

DML

INSERT, UPDATE, DELETE

DDL

INDEX: createIndexes, createIndex, dropIndex, dropIndexes
COLLECTION: createCollection, drop, collMod, renameCollection
DATABASE: dropDatabase, copyDatabase

Notes
When DTS performs full data migration, it will occupy some resources in the source instance, which may increase theload of the source instance and the database pressure. If your database has low configurations, we recommend thatyou migrate the data during off-peak hours.
To migrate instances over the public network, make sure that the source instance is accessible from the public
network.
Incremental migration is not supported for self-built single-node instances as they have no oplogs.

©2013-2022 Tencent Cloud. All rights reserved.

Page 224 of 257

TencentDB for MongoDB

Preparations
Before migration with DTS, check the source and target environments as follows:
Type

Environment Requirements
The server where the source database resides must have enough outbound bandwidth;

Requirements
for the source

otherwise, the migration speed will be affected.
The user provided by the source database must have the permission to read the database.
The source database cannot have a database named TencetDTSData .

database

If the source database is in cluster mode, the balancer needs to be disabled before
incremental sync.
Oplogs can be obtained from the source database during full + incremental migration.
The target database space must be at least 1.3 times the space of the collections to be
migrated in the source database.
The user provided by the target database must have the root permission.
The target database cannot have a database named TencetDTSData .

Requirements
for the target
database

The target database cannot have collections with the same name as those in the source
database.
If the source database is a sharded database, you need to correctly enter the mongos,
ConfigServer, and mongod node information.
The target database cannot have active businesses; otherwise, an alarm will be reported.
The shard keys of the source and target databases must be the same; otherwise, an alarm will
be reported.

Check whether the source and target databases meet the version requirements as instructed in Databases Supported
by Data Migration.
Make sure that the access types of the source and target network environments are interoperable. For more
information, see Overview.
Get the accounts and passwords for accessing the source and target databases.
We recommend that you create a read-only account in the source instance for the migration in the following way:

©2013-2022 Tencent Cloud. All rights reserved.

Page 225 of 257

TencentDB for MongoDB

use admin
db.createUser({user: "username",
pwd: "password",roles:[{role: "readAnyDatabase", db: "admin"},{role: "read", db: "local"}]})©2013-2022 Tencent Cloud. All rights reserved.

Page 226 of 257

TencentDB for MongoDB

Directions
1. Log in to the DTS console, select Data Migration on the left sidebar, and click Create Migration Task to enter
the DTS page.
2. On the DTS page, select the types, regions, and specifications of the source and target instances as follows andclick Buy Now.

Parameter

Description

Parameter Configuration

Service

Select the service type that DTS needs toprovide, including data migration, data sync,

Select Data Migration.

Type

CreationModeand data subscription.
Select the mode for creating the task.
Create Task: Create a new task.
Create similar task: Quickly create a similar

Select an option as needed.

migration task based on an existing task.

Task ID

Billing Mode

This parameter will be displayed if Creation
Mode is Create similar task. It configures
the ID of the existing task.
Select the billing mode of the task. For pay-asyou-go billing details, see Billing Overview.

©2013-2022 Tencent Cloud. All rights reserved.

To create a similar task, enter the ID of theexisting task in the Task ID input box.
-

Page 227 of 257

TencentDB for MongoDB

SourceInstance
Type
SourceInstance

Select the source database type.

Select the source database region.

RegionSelect MongoDB, which cannot be
modified after purchase.

If the source database is a self-built one,select a region nearest to it.

TargetInstance
Type

Select the target database type.

Select MongoDB, which cannot be
modified after purchase.

TargetInstance
RegionSelect the target database region.

-

Specification

Select the specification of the migration link.

It is specified as Medium.

Tag

Set tags for the migration task to facilitate task
management.

Click Add and select specific tag keys andvalues in the Tag Key and Tag Valuedrop-down lists.
Select Name after Creation. The task
name is the same as the task ID by default.
After the migration task is created, you canrename the task.

Task Name

Set the task name.

Select Name Now and enter the task
name in the input box below.
Any special symbols other than hyphen are
not supported.
Letters and digits are supported.
The length limit is as displayed in the
console.
We recommend that you set an easily
recognizable name.

Terms ofService

Learn about the terms of service for data
migration.

Select I have read and agreed to
TENCENT CLOUD TERMS OFSERVICE.

3. You will be automatically redirected to the migration task list. Find the newly created migration task, view the task
status/progress, and wait for the task to be created. Then, click Configure in the Operation column to enter the
Modify Migration Task wizard. On the Set source and target databases tab, set the source and target
databases.

©2013-2022 Tencent Cloud. All rights reserved.

Page 228 of 257

TencentDB for MongoDB

Note:
We recommend that you create a read-only account in the source instance for the migration; otherwise, an alarm will
be reported during the pre-verification. You can ignore the alarm as needed.

Configuration
Type
Task
Configuration

Parameter

Description

Configuration Method

Task Name

Set the name of the data
migration task.

If you have already set the task namewhen creating the data migration task,©2013-2022 Tencent Cloud. All rights reserved.

Page 229 of 257

TencentDB for MongoDB

this parameter will be the specified
name by default.
If you haven't set the task name whencreating the data migration task, enteran easily recognizable task name in
the input box.
Any special symbols other thanhyphen are not supported.
Letters and digits are supported.
The length limit is as displayed in the
console.
Configure the running time ofthe data migration task.
Immediate execution: The

Running Modetask will be started
immediately after the task

Select an option as needed. If

verification passes.
Scheduled execution: You

Scheduled execution is selected,
select the specific time in the

can set a specific time to start

Execution Time input box below.

migration.
After the migration task is

After the migration task is configured,
you can modify the scheduled

configured, you can modify
the scheduled execution time

execution time before it comes.
After the scheduled execution time isbefore it comes.

set for the migration task, if you want

After the scheduled execution
time is set for the migration

to run the task immediately before thescheduled time, click Immediatetask, if you want to run thetask immediately before thestart in the Operation column in the
migration task list.

scheduled time, click
Immediate start in the
Operation column in the
migration task list.
SourceCheck whether the source database

Database

SourceSettings

Database
Type

The source database typeselected during purchase.

type is correct, which cannot be
modified. If you want to modify it, you
can only terminate the current task
and create another one.

RegionAccess TypeThe source database region
selected during purchase.

Check whether the source databaseregion is correct, which cannot be
modified.

Select the network type for

Select an option based on your actual

the source database to

network environment. Network©2013-2022 Tencent Cloud. All rights reserved.

Page 230 of 257

TencentDB for MongoDB

access the migration task.

parameters vary by access network

Public Network: The source
database can be accessedtype.

through a public IP.
Self-Build on CVM: The
source database is deployed
in a CVM instance.
Direct Connect: The source
database can beinterconnected with VPCs
through Direct Connect.
VPN Access: The source
database can beinterconnected with VPCs
through VPN Connections.
Database: The source
database is a TencentDB
instance.
CCN: The source databasecan be interconnected with
VPCs through CCN.
VPC: The source and target
databases can beinterconnected through VPC.
SourceDatabase
Network
Environment
ArchitectureThis parameter will be
displayed if Access Type isCCN. It configures whether
the source database is a

Select an option based on the source
database.

TencentDB database.
This parameter will be

Select an option based on the cluster

displayed if Access Type is
Public Network, Self-Buildarchitecture of the source database.
After the connectivity test is

on CVM, Direct Connect,

performed, the architecture type

VPN Access, or CCN. It
configures the architecture ofcannot be modified.

the source database.
Replica Set: It means thatthe source database is a
replica set, which consists of
one primary node and one ormore secondary nodes.
Cluster Migration: It meansthat the source database is asharded cluster, which©2013-2022 Tencent Cloud. All rights reserved.

Page 231 of 257

TencentDB for MongoDB

consists of mongos nodes,
ConfigServer nodes, shard
nodes, and othercomponents.
Single-Node: It means thatthe source database has asingle node for reads/writes.
VPC-based
DirectConnect
GatewayThis parameter will be
displayed if Access Type is

Select the VPC-based Direct Connect
gateway ID in the drop-down list. Only

Direct Connect. It sets the

VPC-based direct connect gateway is

Direct Connect gateway ID of
the VPC.

supported. Confirm the network typeassociated with the gateway.

This parameter will be
displayed if Access Type is
Direct Connect or VPN
VPCAccess. It configures theinformation of the VPC the

Select the VPC ID and subnet in thedrop-down lists.

source database accesses
through Direct Connect or
VPN.

VPN TypeThis parameter will be
displayed if Access Type is
VPN Access. It indicates the
VPN type.

It is specified as Cloud VPN Service.

This parameter will be
displayed if Access Type is
Public Network, Direct
Host Address

Connect, VPN Access, orCCN. It sets the host IP
address or domain name ofEnter the IP address or domain nameof the source database in the input
box, such as 10.20.3.21 .

the source database.
This parameter will be
displayed if Access Type isPortPublic Network, Direct
Connect, VPN Access, orCCN. It configures the
network port of the sourceEnter the port number in the input box,
such as 6379 .

database.
CVM InstanceThis parameter will be
displayed if Access Type is©2013-2022 Tencent Cloud. All rights reserved.

Select the CVM instance ID in thedrop-down list.

Page 232 of 257

TencentDB for MongoDB

Self-Build on CVM. It
configures the information of
the CVM instance.

Authentication
RequiredThis parameter will be

Select an option based on your data

displayed if Access Type is
Public Network, Self-Build

security requirement.
Yes: The source database requires

on CVM, Direct Connect,
VPN Access, or CCN. It

authentication. In this case, you needto configure both Authentication

configures whether to require

Database and Authentication

authentication for the accessaccount of the source

Mechanism.
No: The source database can bedatabase.

accessed without authentication.

This parameter will be
displayed if Authentication
Authentication
Database

Required is Yes. It
configures the name of theauthentication database foraccessing the sourceEnter the authentication databasename in the input box. By default, theadmin database is used as theauthentication database for login
authentication.

database.
This parameter will be
displayed if Authentication
Authentication
Mechanism

Required is Yes. It
configures the authentication

Currently, only SCRAM-SHA-1 is
supported.

method for the source
database.
This parameter will be
Cross-/IntraAccountdisplayed if Access Type is
Database. It configures
whether the source
TencentDB instance requires
cross-account access.

Database
Instance

This parameter will be
displayed if Access Type is
Database. It configures theinformation of the TencentDB

Cross-Account: The source
database and the current accountbelong to different Tencent Cloudaccounts.
Intra-Account: The source database
and the current account belong to thesame Tencent Cloud account.

Select the source TencentDB
instance ID in the drop-down list.

instance.
VPC-based
CCN InstanceThis parameter will be
displayed if Access Type is

Select the CCN instance ID in thedrop-down list.

CCN. It configures the©2013-2022 Tencent Cloud. All rights reserved.

Page 233 of 257

TencentDB for MongoDB

information of the CCN
instance.
This parameter will be
Node mongod

displayed if Architecture is
Cluster Migration. It
configures the mongod node
information of the sourceEnter the IP and port of the mongod
node in the input box and separate
multiple nodes by line break, such as
10.3.55.77:6379 .

MongoDB database.

Node mongos

This parameter will be
displayed if Architecture is
Cluster Migration. It
configures the mongos nodeEnter the IP and port of the mongos
node in the input box.

information.

Node ConfigServerThis parameter will be
displayed if Architecture is
Cluster Migration. It
configures the IP address andport of the ConfigServer
node.

Enter the IP and port of theConfigServer node in the input box.

Same account & password: The

Account &Password
Selection

This parameter will be
displayed if Architecture is
Cluster Migration andAuthentication Required isaccounts and passwords of themongod, mongos, and ConfigServer
nodes are the same.
Different accounts & passwords:

Yes. It configures whether theaccounts of the mongod,mongos, and ConfigServer

The accounts and passwords of themongod, mongos, and ConfigServer
nodes are different and need to be

nodes of the source database
are the same.

configured separately. Enter theiraccount and password information in
the input boxes below.

This parameter will be
displayed if Authentication
Account

Required is Yes. It
configures the accountinformation that needs to beEnter the account information foraccessing the source database.

authenticated.
Password

This parameter will beEnter the password corresponding todisplayed if Authentication
Required is Yes. It
configures the password

the account to access the source
database.

©2013-2022 Tencent Cloud. All rights reserved.

Page 234 of 257

TencentDB for MongoDB

corresponding to theauthentication account.
Check whether the target database
TargetDatabase
Type

The target database typeselected during purchase.

type is correct, which cannot be
modified. If you want to modify it, you
can only terminate the current task
and create another one.

TargetDatabase
Settings

Check whether the target database

RegionThe target database region
selected during purchase.

Access Type

Configure the network accesstype of the target database.

It is specified as Database, indicatingthat the target database is a
TencentDB instance.

Database

Select the instance ID of theSelect the instance ID of the target

Instance

target database.

database.

Account of the target

Enter the account information in the

database.

input box.

Password of the target
database.

Enter the password of the account in
the input box.

Account

Passwordregion is correct, which cannot be
modified.

4. After configuring the source and target databases, click Test Connectivity to test their network connectivity
respectively. If the connectivity test fails, fix the problem as instructed in Failed Connectivity Test.

5. After the connectivity test passes, click Save. On the Set migration options and select migration objects
page, configure the migration options and objects and click Save.

©2013-2022 Tencent Cloud. All rights reserved.

Page 235 of 257

TencentDB for MongoDB

Parameter

Description

Configuration Method

Select an option as needed.
Full migration: The entire database will
be migrated. The migrated data will only
be existing content of the source databasewhen the task is initiated but not include
MigrationTypethe incremental data written to the source
database after the task is initiated.
Full + Incremental migration: The
migrated data will include the existing

Select whether to migrate incremental data
based on the actual situation of the migrated
data.

content of the source database when thetask is initiated as well as the incremental
data written to the source database after
the task is initiated.
Data

Configure whether to perform data

If Migration Type is Full migration, Data

Consistency
Checkconsistency check after full migration iscompleted.
Full check: A detailed comparison of theConsistency Check is specified as No
check.
If Migration Type is Full + Incremental

data in the source and target databases
will be performed after migration. Whenthe migration task enters the "incremental

migration, you can select Full check or No
check.
Full check: A detailed comparison of the datasync" stage, the source-target databasedata gap is 0 MB, and the source-target
database time lag is 0 seconds, themigration task will automatically trigger ain the source and target databases will be
performed after migration. When the migration
task enters the "incremental sync" stage, thesource-target database data gap is 0 MB, anddata consistency check task.
No check: This indicates not to perform
data check. After the task is created, you

the source-target database time lag is 0
seconds, the migration task will automaticallytrigger a data consistency check task.

can manually trigger the consistency
check when the task enters the"incremental sync" stage. For more

No check: This indicates not to perform data
check. After the task is created, you canmanually trigger the consistency check when
the task enters the "incremental sync" stage.

©2013-2022 Tencent Cloud. All rights reserved.

Page 236 of 257

TencentDB for MongoDB

Data Check

information, see Creating Data
Consistency Check Task.

For more information, see Creating Data
Consistency Check Task.

It is specified as Content check, i.e.,
checking the data in the database.

-Configure the specific scope of the
migration task.

Migration
ObjectEntire instance: Migrate the entire
database instance, including the metadatadefinitions of roles and users but excluding

If Migration Object is Specify object, selectthe specific collections to be migrated in
Source Database Object below. Then,system databases such as system objects
in PostgreSQL.
Specified objects: Migrate specified
objects.

confirm the selected collections in Selected
Object.

6. On the Verify task tab, wait for the pre-verification to complete and click Start Task.
If the verification fails, fix the problem as instructed in Check Item Overview and initiate the verification again.
If the verification result is Failed, a check item fails and the task is blocked. Click View Details to view the cause of
the failure. You need to fix the problem and run the verification task again.
If the verification result is Alarm, a check item doesn't completely meet the requirements, and the task can becontinued, but the business will be affected. Click View Details to view the alarm. You need to assess whether toignore the alarm.

7. Return to the migration task list and wait for the task to complete.
If Full migration is selected for Migration Type, once completed, the task will be stopped automatically.

©2013-2022 Tencent Cloud. All rights reserved.

Page 237 of 257

TencentDB for MongoDB

If Full + Incremental migration is selected for Migration Type, after full migration is completed, the migration task
will automatically enter the incremental data sync stage, which will keep running and will not stop automatically. To
stop the task, make sure that the migration stage is incremental sync, the source-target database time lag is 0
seconds, and there is no delay, stop writing to the source database for a few minutes, and click Complete* in the
Operation** column of the migration task.

More Operations(Optional) If you want to view, delete, or perform other operations on a task, click the task and select the target
operation in the Operation column. For more information, see Viewing Task.
After the migration task status becomes Task successful, you can formally cut over the business. For more
information, see Cutover Description.

©2013-2022 Tencent Cloud. All rights reserved.

Page 238 of 257

TencentDB for MongoDB

Creating Data Consistency Check Task：

Last updated 2024-01-15 14:49:55

Overview
During data consistency check, DTS compares the collection data between the source and target databases andoutputs the comparison result and inconsistency details for you to determine the business cutover time. A dataconsistency check task is independent of the normal business in the source database or other DTS tasks.
Data consistency check tasks can be triggered automatically or created manually.
Automatic triggering: During migration task configuration, if Full check is selected for Data Consistency Check, adata consistency check task will be triggered automatically when the migration task enters the incremental sync
step.
Manual creation: When the DTS task enters the incremental sync step, you can manually create one or multiple dataconsistency check tasks.

Note
Data consistency check compares only the objects selected in the source database and objects migrated to the target
database. If you write data into the target database during migration, then the written data will not be included in theconsistency check.
A data consistency check task may increase the load in the source database instance. Therefore, you need to perform
such tasks during off-peak hours.
A data consistency check task can be executed repeatedly, but one DTS instance can initiate only one such task at
any time.
If you choose to complete or terminate a DTS task before a data consistency check task is completed, the checktask will fail.
As data consistency check requires creating a new database __tencentdb__ in the source database and writing
the checksum collection to the database, if the source database is read-only, data consistency check will be skipped.

Restrictions
Currently, check tasks are imperceptible to the DDL operations. If you perform DDL operations in the source databaseduring migration, the check result will be inconsistent with the actual data, and you need to initiate another check task
to get the accurate comparison result.

©2013-2022 Tencent Cloud. All rights reserved.

Page 239 of 257

TencentDB for MongoDB

Triggering a data consistency check task automaticallyOn the Set migration options and select migration objects page of a data migration task, select Full check for
Data Consistency Check. In this way, a data consistency check task will be triggered automatically when the
migration task enters the incremental sync step.
Note:
In this case, the full data and all the database information will be checked by default. If you need to filter check objects,
create a data consistency check task manually.

©2013-2022 Tencent Cloud. All rights reserved.

Page 240 of 257

TencentDB for MongoDB

Creating a data consistency check task manually
1. Log in to the DTS console.
2. On the Data Migration page, select the target migration task and click More > Create Data Consistency Check
Task in the Operation column.

©2013-2022 Tencent Cloud. All rights reserved.

Page 241 of 257

TencentDB for MongoDB

3. On the Database Consistency Check page, click Create Data Consistency Check Task.
Note:
A data consistency check task can be created only when the corresponding DTS task is in the incremental sync
step. If the button is grayed out, the DTS task status does not meet the requirement; for example, the task has notentered the incremental sync step, has failed, or is terminated.

4. In the Notes pop-up window, read the notes, confirm the check task to be initiated, and click OK.
5. Configure the following parameters in the Create Data Consistency Check Task window and click Create andStart Consistency Check Task.

Parameter

Description

Configuration Method

Task Name

Set the check task name.

You can enter any characters as the task

©2013-2022 Tencent Cloud. All rights reserved.

Page 242 of 257

TencentDB for MongoDB

name to facilitate task management.
Object Migration
Mode

Specify the database checkmode.

It is fixed at Entire instance.
All migration objects: All the migrated data

Check Object

Select the migrated object checkmethod.

Database
Information

Select the database information to
be checked, which can be Index,
Database and , or Shard key.

will be checked.
Custom: In the Source Database Object
area below, select the databases/collections
to be checked.
For sharded clusters, you can choose tocheck the shard key.

Select the data check method.

Data Check

Sampling

Row count check: It compares
the number of rows of data in thesource and target databases.
Content check: It compares thedata content in the source andtarget databases row by row.
If you select Content check andthe data volume is high, you cansample a proportion of data forcomparison.

If the data volume is high, we recommend thatyou select Row count check. If you selectContent check, extract a relatively low
proportion of data for check to improve thecheck efficiency.

Select this option as needed based on yourbusiness conditions.

Viewing the data consistency check result
1. In the data migration task list, view whether the check result is Consistent or Inconsistent in the Last Check
Result column. Click View More to enter the Data Consistency Check page.
2. In the data check task list, select a task and click View in the Operation column to view the check result.

If the data is consistent, the result is like this:©2013-2022 Tencent Cloud. All rights reserved.

Page 243 of 257

TencentDB for MongoDB

If the data is inconsistent, the result is like this:Note:
For inconsistent data, you need to manually confirm the corresponding data content of the source and target
databases as prompted.

References
For more information, see Technical Scheme and Common Problems of Data Consistency Check.

©2013-2022 Tencent Cloud. All rights reserved.

Page 244 of 257

TencentDB for MongoDB

Technical Scheme and Common Problems of
Data Consistency Check：

Last updated 2024-01-15 14:49:55
During data consistency check, DTS compares the collection data between the source and target databases andoutputs the comparison result and inconsistency details for you to perform a business cutover stably and reliably.

Check Scheme
DTS checks and compares all the data migrated during full migration and incremental migration from the source
database. A full data check compares the data in the source and target databases row by row. Once the thread of theincremental data check finds that the full data comparison is completed, it immediately starts the incremental data
check to get the start timestamp of the full data check, get the incremental oplog in the source database in a loop, andcompare the differences between the source and target databases. When the time lag of data in the source and target
databases is below 10 seconds, the comparison ends, and the check result is output.

©2013-2022 Tencent Cloud. All rights reserved.

Page 245 of 257

TencentDB for MongoDB

Common Issues
Time-consuming full data check task
Cause analysis
The DTS consistency check policy compares full data in the source and target TencentDB for MongoDB databases
row by row. If the data volume is large, the check task may take longer and use more system resources, thus affecting
the source service and migration task.
Solutions
If the data volume is large and the check task is very slow, we recommend that you stop the current task, manuallycreate another consistency check task, and select Row count check as the data check method for quickcomparison. Or, select Content check as the data check method and lower the proportion selected for Sampling,i.e., sampling a lower proportion of data for check. For detailed directions, see Creating Data Consistency Check
Task.
Data CheckRow count check: It compares the number of rows of data in the source and target databases.
Content check: It compares the data content in the source and target databases row by row.
Sampling Percentage: If you select Content check, you can sample a proportion of data for comparison.

©2013-2022 Tencent Cloud. All rights reserved.

Page 246 of 257

TencentDB for MongoDB

Data inconsistency
Data content inconsistency
Issue
Cause analysis
During a full data check, data is continuously written to the source database, and the oplog keeps being updated. The
incremental data check task continuously reads the oplog from the source database. If the new oplog generated in thesource database has not reached the timestamp in the target database, the data content may be inconsistent for ashort period of time, which is normal.
Solution
You can check the inconsistent data row by row. You can also initiate a new check task to perform another manual
check. When all the incremental data is migrated to the target database, the content will be consistent.
Data row count inconsistency
Issue
Cause 1
During a full data check, data is continuously written to the source database, and the oplog keeps being updated. The
incremental data check task continuously reads the oplog from the source database. If the new oplog generated in thesource database has not reached the timestamp in the target database, the number of data rows may be inconsistent
for a short period of time, which is normal.
Cause 2The TencentDB for MongoDB row count check collects the row count in metadata throughdb.collection.estimatedDocumentCount() or db.collection.stats() for comparison, which
may be inconsistent with the actual row count under specific circumstances such as unexpected instance shutdown or
the presence of orphaned documents.

©2013-2022 Tencent Cloud. All rights reserved.

Page 247 of 257

TencentDB for MongoDB

SolutionIn this case, you can use db.collection.countDocuments() to compare the row count. Note that thisrequires collection scanning, which may affect the performance. For more information, seedb.collection.countDocuments().

Index checkIssue
If you select Index for Database Info when creating a consistency check task, the indexes in the source and target
databases will be compared. You may find that the content of the v and background fields in the source andtarget databases are inconsistent, but the check result does not indicate any inconsistency.
Cause analysis
The TencentDB for MongoDB index check policy ignores the inconsistency in the v (version information) andbackground (creation in the background) fields, which will not be indicated in the check result.

©2013-2022 Tencent Cloud. All rights reserved.

Page 248 of 257

TencentDB for MongoDB

Creating MongoDB Data Subscription：

Last updated 2024-01-15 14:49:55
This document describes how to create a data subscription task in DTS for TencentDB for MongoDB.

Version description
Data subscription is supported for TencentDB for MongoDB 3.6, 4.0, 4.2, and 4.4.
TencentDB for MongoDB 3.6 only supports collection-level subscription.

Prerequisites
You have prepared a TencentDB instance to be subscribed to, and the database version meets the requirements. For
more information, see Databases Supported by Data Subscription.
We recommend that you create a read-only account in the source instance by referring to the following syntax. For
operations in the console, see Account Management.

©2013-2022 Tencent Cloud. All rights reserved.

Page 249 of 257

TencentDB for MongoDB# Create an instance-level read-only accountuse admin
db.createUser({user: "username",
pwd: "password",roles:[{role: "readAnyDatabase",db: "admin"}]})# Create a database-specific read-only account©2013-2022 Tencent Cloud. All rights reserved.

Page 250 of 257

TencentDB for MongoDB

use admin
db.createUser({user: "username",
pwd: "password",roles:[{role: "read",db: "Name of the specified database"}]})

Restrictions
Currently, the subscribed message content is retained for 1 day by default. Once expired, the data will be cleared.
Therefore, you need to consume the data promptly.
The region where the data is consumed should be the same as that of the subscribed instance.
The Kafka built in DTS has a certain upper limit for the size of processed individual messages. When a single row ofdata in the source database exceeds 10 MB, this row may be discarded in the consumer.
If the subscribed database or collection specified in the data subscription task is deleted from the source database,the subscription data (change stream) of the database or collection will be invalidated. Even if the database orcollection is rebuilt in the source database, the subscription data cannot be resubscribed. In this case, you need toreset the subscription task and select the subscription object again.

SQL operations for subscription
Operation
Type

Supported SQL Operations

DML

INSERT, UPDATE, DELETE

DDL

INDEX: createIndexes, createIndex, dropIndex, dropIndexes; COLLECTION: createCollection,
drop, collMod, renameCollection; DATABASE: dropDatabase, copyDatabase

Subscription configuration
1. Log in to the DTS console, select Data Subscription on the left sidebar, and click Create Subscription.
2. On the DTS page, configure parameters as follows and click Buy Now.
Parameter

Description©2013-2022 Tencent Cloud. All rights reserved.

Configuration Method

Page 251 of 257

TencentDB for MongoDB

Service

Select the service type. This document describes

Select Data Subscription.

Type

the Data Subscription service.

Billing
Mode

Select the billing mode of the service. For billing
details, see Billing Overview.

Pay-as-you-go is supported. For more
information, see
Billing Overview.

RegionSelect the region where the subscription service
resides.

It must be the same as that of thedatabase instance to be subscribed to.

Database

Select the type of the database for the datasubscription service.

Select MongoDB.

Version

Data can be directly consumed through the Kafka
client.

Select Kafka Edition.

Tag

Specify the tag for the data subscription service.

Click Add and select Tag Key and Tag
Value in the drop-down list.
Name after Creation: Set the nameSubscribedInstance
Name

Specify how to name the data subscription service.

after the data subscription service iscreated, which is name-subscription ID
by default. The subscription ID is
randomly assigned by the system.
Name Now: Enter the name of the datasubscription service directly in the input
box below.

Quantity

Select the number of tasks to be purchased.

You can purchase up to 10 tasks at atime.

3. After successful purchase, return to the data subscription list, select the purchased subscription task, and click
Configure Subscription in the Operation column.

4. On the Select Instance tab of the Configure data subscription wizard, configure the database information forthe data subscription task and perform the connectivity test.

©2013-2022 Tencent Cloud. All rights reserved.

Page 252 of 257

TencentDB for MongoDB

Parameter

Description

Configuration Method

Subscription
ID / Name

ID and name of the subscription task. The task
name is name-subscription ID by default.

Confirm the ID and name of the datasubscription task.

©2013-2022 Tencent Cloud. All rights reserved.

Page 253 of 257

TencentDB for MongoDB

Instance
Type
Region

It is MongoDB by default.

The region where the subscription service
resides.

-

Confirm the region.

Access Type

Select the type of source database access to thedata subscription service.

Currently, only Database issupported, i.e., a TencentDB instance.

Instance
Name

Select the specific MongoDB instance for thedata subscription service.

Select a specific instance ID in thedrop-down list.

Set the access account information of theEnter the prepared read-only accountMongoDB instance.

information in the input box.

Set the password of the access account of theMongoDB instance.

Enter the password of the read-only
account in the input box. Passwordfree access is not supported.

Account

Password

You can select 1, 4, or 8.
A single partition can guarantee theorder of messages, while multiple
partitions cannot. If you have strict

Kafka
Partition
Count

Select the number of Kafka partitions for the datasubscription task. In Kafka, a consumer can getdata by subscribing to one or more topics andthen consuming data from one or more partitionsof each topic.

requirements for the order ofmessages during consumption, set thisvalue to 1.
Increasing the number of partitions canimprove the throughput and parallelismof the Kafka cluster, because multiple
consumers can consume different
partitions at the same time. However,doing so will also increase themanagement and maintenance costsof the Kafka cluster and may cause
data imbalance or delays.
Click Test Connectivity and wait for

Test
Connectivity

Test the connectivity between the datasubscription service and the TencentDB for
MongoDB instance.

the test result.
If the test fails, troubleshoot as
prompted. Then, click Test Again totest the connectivity again. After thetest passes, proceed to the next step.

5. Click Next, configure the parameters as follows on the Subscription Type and Object page, and click Save.
Parameter

Description©2013-2022 Tencent Cloud. All rights reserved.

Configuration Method

Page 254 of 257

TencentDB for MongoDB

Subscription

ID and name of the subscription task.

ID / Name
SubscribedInstance
Data
Subscription
Type

Check whether the subscription task
information is correct.

Instance ID of the subscribed MongoDB database.
The type of data that the subscriber can choose to
subscribe to. MongoDB uses the change stream
feature to monitor data changes and implement
data subscription.

Check whether the instanceinformation is correct.

It is Change Stream by default andcannot be modified.

Level of the subscribed data, including Fullinstance, Database, and Collection.
Full instance: Subscribe to the data in the entire
Subscription

instance.
Database: Subscribe to the data in the specified

Select the level of data subscription
as needed. System databases

Object Level

database. After selecting this option, you can selectadmin , local , and config

only one database in Task Configuration.
Collection: Subscribe to the data in the specified

cannot be selected.

collection. After selecting this option, you can select
only one collection in Task Configuration.
In the Select databases and tables
Task
Configuration

When Subscription Level is Database or
Collection, this parameter will be displayed for you
to specify the database or collection.

section, select the database orcollection to be subscribed.
In the Selected section, check
whether the selected database orcollection is correct.
Enable: Clickto enable aggregation. Click Add,
select an operator in the
Aggregation Operator drop-down
OutputThis parameter configures whether to enable

Aggregation
Settings

aggregation for the subscribed data before sending
it to the subscriber.

list, and enter an expression in the
Aggregation Expression input box.
Click Add to add multiple
aggregation expressions. The
aggregation pipeline will be executed
based on the order of added
aggregation operations. For more
information, see Modify Change
Stream Output.

Kafka

If Kafka Partition Count is not 1 in the previous©2013-2022 Tencent Cloud. All rights reserved.

Select Custom Partitioning Policy,

Page 255 of 257

TencentDB for MongoDB

Partitioning
PolicyCustomPartitioning
PolicyPolicyCombo
Resultstep, you need to set the partition policy.
By Collection Name: Partitions the subscribedclick Add in Custom Partitioning
Policy below, set the matching mode

data from the source database by collection name.
With this policy, data with the same collectionof database name or collection namein the form of regular expression inname is written to the same Kafka partition.

the Database Name Match or

Custom Partitioning Policy: Database andcollection names of the subscribed data are

Table Name Match input box below,
and select By Collection Name ormatched through a regex first. Then, matched datais partitioned by collection name or collection nameBy Collection Name + ObjectId in
the Partitioning Policy drop-down+ objectid .

list.
When you enable the custom

This parameter will be displayed if Custom
Partitioning Policy is selected in Kafka
Partitioning Policy. It sets the custom partitioning
policy.
This parameter will be displayed if Custom
Partitioning Policy is selected in Kafka
Partitioning Policy. It indicates the combo resultof the custom partitioning policy.

partitioning policy option, yourcustom partitioning policies will beapplied first, followed by the Kafka
partitioning policies.
The data in a collection that cannot
be partitioned using the custom
partitioning policies will be routed to
Kafka partitions by default policy By
Collection Name.

6. On the Pre-verification page, a pre-verification task will run for 2–3 minutes. After the pre-verification is passed,
click Start to complete data subscription task configuration.
Note:
If the verification fails, fix the problem as instructed in Database Connection Check and initiate the verification again.

©2013-2022 Tencent Cloud. All rights reserved.

Page 256 of 257

TencentDB for MongoDB

7. The subscription task will be initialized, which will take 3–4 minutes. After successful initialization, the task will enter
the Running status, and data consumption will start.

Subsequent operations
1. Adding Consumer Group.
The consumption in data subscription (Kafka Edition) depends on the consumer groups of Kafka; therefore, you must
create a consumer group first before data can be consumed. Data subscription (Kafka Edition) allows you to create
multiple consumer groups for multi-point consumption.
2. Consuming Subscribed Data with Kafka Client (ProtoBuf).
After the subscription task enters the Running status, you can start consuming data. For consumption in Kafka, youneed to verify the password. For code samples in different programming languages, see the demo in Consuming
Subscribed Data with Kafka Client (ProtoBuf).

©2013-2022 Tencent Cloud. All rights reserved.

Page 257 of 257