Updating MongoDB cluster settings
After creating a cluster, you can:
- Change the host class.
- Increase storage size.
- Configure MongoDB servers as described in the MongoDB documentation
. - Change additional cluster settings.
- Move a cluster to another folder.
- Change security groups.
To move a cluster to a different availability zone, follow this guide. You will thus move the cluster hosts.
Changing the host class
Note
Some MongoDB settings depend on the selected host class.
When changing the host class:
- Your single-host cluster will be unavailable for a few minutes with database connections terminated.
- A multi-host cluster will get a new primary replica. Its hosts will be stopped and updated one by one. Once stopped, a host will be unavailable for a few minutes.
We recommend changing the host class only when the cluster has no active workload.
-
Go to the folder page
and select Managed Service for MongoDB. -
Select the cluster and click Edit in the top panel.
-
Under Host class, select:
- One of the available platforms.
- Configuration type: memory-optimized, cpu-optimized, standard, or burstable.
- Host class: Defines the technical specifications of the VMs where the DB hosts will be deployed. When you change the host class for the cluster, the characteristics of all existing hosts change, too.
-
Click Save changes.
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To change the host class for the cluster:
-
View the description of the update cluster CLI command:
yc managed-mongodb cluster update --help
-
Request a list of available host classes (the
ZONE IDS
column specifies the availability zones where you can select the appropriate class):yc managed-mongodb resource-preset list +-----------+--------------------------------+-------+----------+ | ID | ZONE IDS | CORES | MEMORY | +-----------+--------------------------------+-------+----------+ | s1.micro | ru-central1-a, ru-central1-b, | 2 | 8.0 GB | | | ru-central1-d | | | | ... | +-----------+--------------------------------+-------+----------+
-
Specify the class in the update cluster command. When changing the class, keep in mind the host role: it depends on the sharding type. You can use parameters for hosts with different roles in a single command.
-
For
MONGOD
hosts:yc managed-mongodb cluster update <cluster_name_or_ID> \ --mongod-resource-preset <class_ID>
-
For
MONGOINFRA
hosts:yc managed-mongodb cluster update <cluster_name_or_ID> \ --mongoinfra-resource-preset <class_ID>
-
For
MONGOS
hosts:yc managed-mongodb cluster update <cluster_name_or_ID> \ --mongos-resource-preset <class_ID>
-
For
MONGOCFG
hosts:yc managed-mongodb cluster update <cluster_name_or_ID> \ --mongocfg-resource-preset <class_ID>
Managed Service for MongoDB will run the update host class command for the cluster.
-
-
Open the current Terraform configuration file with an infrastructure plan.
For more information about creating this file, see Creating clusters.
-
In the Managed Service for MongoDB cluster description, change the
resource_preset_id
parameter value forresources_mongod
,resources_mongoinfra
,resources_mongos
, orresources_mongocfg
. The resource type depends on the sharding type.Example:
resource "yandex_mdb_mongodb_cluster" "<cluster_name>" { ... resources_mongod { resource_preset_id = "<host_class>" ... } }
-
Make sure the settings are correct.
-
Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.
-
Run the command:
terraform validate
If there are errors in the configuration files, Terraform will point to them.
-
-
Confirm updating the resources.
-
Run the command to view planned changes:
terraform plan
If the resource configuration descriptions are correct, the terminal will display a list of the resources to modify and their parameters. This is a test step. No resources are updated.
-
If you are happy with the planned changes, apply them:
-
Run the command:
terraform apply
-
Confirm the update of resources.
-
Wait for the operation to complete.
-
-
For more information, see the Terraform provider documentation
Timeouts
The Terraform provider sets the following timeouts for Managed Service for MongoDB cluster operations:
- Creating a cluster, including by restoring one from a backup: 30 minutes.
- Editing a cluster: 60 minutes.
Operations exceeding the set timeout are interrupted.
How do I change these limits?
Add the timeouts
block to the cluster description, for example:
resource "yandex_mdb_mongodb_cluster" "<cluster_name>" {
...
timeouts {
create = "1h30m" # An hour and a half
update = "2h" # Two hours
}
}
To change the host class, use the update REST API method for the Cluster resource or the ClusterService/Update gRPC API call and provide the following in the request:
-
Cluster ID in the
clusterId
parameter. To find out the cluster ID, get a list of clusters in the folder. -
Host class in the
configSpec.mongodbSpec_<MongoDB_version>.mongod.resources.resourcePresetId
parameter.To retrieve a list of supported values, use the list method for the
ResourcePreset
resources. -
List of settings to update in the
updateMask
parameter.
Warning
The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the updateMask
parameter as a single comma-separated string.
Increasing storage size
Make sure the cloud has enough quota to increase the storage size. Open the cloud's Quotas
To increase the cluster storage size:
- Go to the folder page
and select Managed Service for MongoDB. - Select the cluster and click Edit in the top panel.
- Under Size of storage, specify the required value.
- Click Save changes.
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To increase the cluster storage size:
-
View the description of the update cluster CLI command:
yc managed-mongodb cluster update --help
-
Specify the required storage size in the update cluster command. It must be at least as large as the current
disk_size
value in the cluster properties.When increasing the storage size, keep in mind the host role: it depends on the sharding type. You can use parameters for hosts with different roles in a single command.
-
For
MONGOD
hosts:yc managed-mongodb cluster update <cluster_name_or_ID> \ --mongod-disk-size <storage_size_in_GB>
-
For
MONGOINFRA
hosts:yc managed-mongodb cluster update <cluster_name_or_ID> \ --mongoinfra-disk-size <storage_size_in_GB>
-
For
MONGOS
hosts:yc managed-mongodb cluster update <cluster_name_or_ID> \ --mongos-disk-size <storage_size_in_GB>
-
For
MONGOCFG
hosts:yc managed-mongodb cluster update <cluster_name_or_ID> \ --mongocfg-disk-size <storage_size_in_GB>
If all these conditions are met, Managed Service for MongoDB will launch the operation to increase the storage size.
-
To increase the cluster storage size:
-
Open the current Terraform configuration file with an infrastructure plan.
For more information about creating this file, see Creating clusters.
-
In the Managed Service for MongoDB cluster description, change the
disk_size
parameter value forresources_mongod
,resources_mongoinfra
,resources_mongos
, orresources_mongocfg
. The resource type depends on the sharding type.Example:
resource "yandex_mdb_mongodb_cluster" "<cluster_name>" { ... resources_mongod { disk_size = <storage_size_in_GB> ... } }
-
Make sure the settings are correct.
-
Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.
-
Run the command:
terraform validate
If there are errors in the configuration files, Terraform will point to them.
-
-
Confirm updating the resources.
-
Run the command to view planned changes:
terraform plan
If the resource configuration descriptions are correct, the terminal will display a list of the resources to modify and their parameters. This is a test step. No resources are updated.
-
If you are happy with the planned changes, apply them:
-
Run the command:
terraform apply
-
Confirm the update of resources.
-
Wait for the operation to complete.
-
-
For more information, see the Terraform provider documentation
Timeouts
The Terraform provider sets the following timeouts for Managed Service for MongoDB cluster operations:
- Creating a cluster, including by restoring one from a backup: 30 minutes.
- Editing a cluster: 60 minutes.
Operations exceeding the set timeout are interrupted.
How do I change these limits?
Add the timeouts
block to the cluster description, for example:
resource "yandex_mdb_mongodb_cluster" "<cluster_name>" {
...
timeouts {
create = "1h30m" # An hour and a half
update = "2h" # Two hours
}
}
To increase the cluster storage size, use the update REST API method for the Cluster resource or the ClusterService/Update gRPC API call and provide the following in the request:
- Cluster ID in the
clusterId
parameter. To find out the cluster ID, get a list of clusters in the folder. - New storage size in the
configSpec.mongodbSpec_<MongoDB_version>.mongod.resources.diskSize
parameter. - List of settings to update in the
updateMask
parameter.
Warning
The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the updateMask
parameter as a single comma-separated string.
Changing MongoDB settings
You can change the DBMS settings of the hosts in your cluster.
Note
Some MongoDB settings depend on the selected host class.
- Go to the folder page
and select Managed Service for MongoDB. - Select the cluster and click Edit in the top panel.
- To change the MongoDB settings, click Settings under DBMS settings.
- Click Save changes.
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To update the MongoDB settings for a cluster, run the command:
yc managed-mongodb cluster update-config
For example, to set net.maxIncomingConnections4096
, run the following command:
yc managed-mongodb cluster update-config <cluster_name> \
--set net.max_incoming_connections=4096
Managed Service for MongoDB will run the update DBMS settings command for the cluster. If the setting being changed is only applied when the database is restarted, Managed Service for MongoDB will restart the database instances on all cluster hosts, one by one.
To change MongoDB settings, use the update REST API method for the Cluster resource or the ClusterService/Update gRPC API call and provide the following in the request:
-
Cluster ID in the
clusterId
parameter. To find out the cluster ID, get a list of clusters in the folder. -
Target MongoDB setting values in the
configSpec.mongodbSpec_<MongoDB_version>.mongod.config
parameter.All supported settings are described in the API reference and in MongoDB settings.
-
List of cluster settings to update in the
updateMask
parameter.
Warning
The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the updateMask
parameter as a single comma-separated string.
Changing additional cluster settings
-
Go to the folder page
and select Managed Service for MongoDB. -
Select the cluster and click Edit in the top panel.
-
Change additional cluster settings:
-
Backup start time (UTC): Time interval during which the cluster backup starts. Time is specified in 24-hour UTC format. The default time is
22:00 - 23:00
UTC. -
Retention period for automatic backups, days
Retention period for automatic backups. If an automatic backup expires, it is deleted. The default is 7 days. This feature is at the Preview stage. For more information, see Backups.
Changing the retention period affects both new automatic backups and existing backups. For example, if the initial retention period was 7 days, and the remaining lifetime of a separate automatic backup is 1 day, increasing the retention period to 9 days will change the remaining lifetime of this backup to 3 days.
For an existing cluster, automatic backups are stored for a specified number of days whereas manually created ones are stored indefinitely. After a cluster is deleted, all backups persist for 7 days.
-
Maintenance window: Maintenance window settings:
- To enable maintenance at any time, select arbitrary (default).
- To specify the preferred maintenance start time, select by schedule and specify the desired day of the week and UTC hour. For example, you can choose a time when the cluster is least loaded.
Maintenance operations are carried out both on enabled and disabled clusters. They may include updating the DBMS, applying patches, and so on.
-
Statistics sampling: Enable this option to use the built-in performance diagnostics tool in the cluster. This feature is at the Preview stage.
-
Deletion protection: Manages protection of the cluster, its databases, and users against accidental deletion.
Enabled deletion protection will not prevent a manual connection with the purpose to delete database contents.
-
-
Click Save changes.
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To change additional cluster settings:
-
View the description of the update cluster CLI command:
yc managed-mongodb cluster update --help
-
Run the following command with a list of settings to update:
yc managed-mongodb cluster update <cluster_ID_or_name> \ --backup-retain-period-days=<retention_period> \ --backup-window-start <backup_start_time> \ --maintenance-window type=<maintenance_type>,` `day=<day_of_week>,` `hour=<hour> \ --performance-diagnostics=<enable_diagnostics> \ --deletion-protection
You can change the following settings:
-
--backup-retain-period
: Automatic backup retention period, in days.The
<retention_period>
parameter value must be in the range from 7 to 35 (the default value is 7). This feature is at the Preview stage. For more information, see Backups.Changing the retention period affects both new automatic backups and existing backups.
For example, if the original retention period was 7 days, and the remaining lifetime of a separate automatic backup is 1 day, then increasing the retention period to 9 days will change the remaining lifetime of this backup to 3 days.
--backup-window-start
: The cluster backup start time, set in UTC formatHH:MM:SS
. If the time is not set, the backup will start at 22:00 UTC.
-
--maintenance-window
: Maintenance window settings (including for disabled clusters), wheretype
is the maintenance type:anytime
(default): Any time.weekly
: On a schedule. If setting this value, specify the day of week and the hour:day
: Day of week inDDD
format:MON
,TUE
,WED
,THU
,FRI
,SAT
, orSUN
.hour
: Hour (UTC) inHH
format:1
to24
.
-
--performance-diagnostics
: Specify this parameter to use the Performance diagnostics tool in the cluster. This feature is at the Preview stage. -
--deletion-protection
: Protection of the cluster, its databases, and users against accidental deletion.Enabled deletion protection will not prevent a manual connection with the purpose to delete database contents.
You can get the cluster ID and name with a list of clusters in the folder.
-
Open the current Terraform configuration file with an infrastructure plan.
For more information about creating this file, see Creating clusters.
-
To change the backup start time, add a
backup_window_start
section to the Managed Service for MongoDB cluster description undercluster_config
:resource "yandex_mdb_mongodb_cluster" "<cluster_name>" { ... cluster_config { backup_window_start { hours = <hour> minutes = <minute> } ... } ... }
Where
hours
andminutes
are the backup start hour and minute. -
To enable access from Yandex DataLens, add the
access
section to the Managed Service for MongoDB cluster description undercluster_config
:resource "yandex_mdb_mongodb_cluster" "<cluster_name>" { ... cluster_config { ... access { data_lens = <access_from_DataLens> } ... }
Where
data_lens
enables access from DataLens,true
orfalse
. -
To set up the maintenance window (for disabled clusters as well), add the
maintenance_window
block to the cluster description:resource "yandex_mdb_mongodb_cluster" "<cluster_name>" { ... maintenance_window { type = <maintenance_type> day = <day_of_week> hour = <hour> } ... }
Where:
type
: Maintenance type. The possible values include:anytime
: Anytime.weekly
: By schedule.
day
: Day of the week for theweekly
type inDDD
format, e.g.,MON
.hour
: Hour of the day for theweekly
type in theHH
format, e.g.,21
.
-
To enable cluster protection against accidental deletion by a user of your cloud, add the
deletion_protection
field set totrue
to your cluster description:resource "yandex_mdb_mongodb_cluster" "<cluster_name>" { ... deletion_protection = <deletion_protection> }
Where
deletion_protection
is the cluster deletion protection,true
orfalse
.Enabled deletion protection will not prevent a manual connection with the purpose to delete database contents.
-
Make sure the settings are correct.
-
Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.
-
Run the command:
terraform validate
If there are errors in the configuration files, Terraform will point to them.
-
-
Confirm updating the resources.
-
Run the command to view planned changes:
terraform plan
If the resource configuration descriptions are correct, the terminal will display a list of the resources to modify and their parameters. This is a test step. No resources are updated.
-
If you are happy with the planned changes, apply them:
-
Run the command:
terraform apply
-
Confirm the update of resources.
-
Wait for the operation to complete.
-
-
For more information, see the Terraform provider documentation
Timeouts
The Terraform provider sets the following timeouts for Managed Service for MongoDB cluster operations:
- Creating a cluster, including by restoring one from a backup: 30 minutes.
- Editing a cluster: 60 minutes.
Operations exceeding the set timeout are interrupted.
How do I change these limits?
Add the timeouts
block to the cluster description, for example:
resource "yandex_mdb_mongodb_cluster" "<cluster_name>" {
...
timeouts {
create = "1h30m" # An hour and a half
update = "2h" # Two hours
}
}
To change additional cluster settings, use the update REST API method for the Cluster resource or the ClusterService/Update gRPC API call and provide the following in the request:
-
Cluster ID in the
clusterId
parameter. To find out the cluster ID, get a list of clusters in the folder. -
New backup start time in the
configSpec.backupWindowStart
parameter. -
Settings for access from other services in the
configSpec.access
parameter. -
Maintenance window settings (including for disabled clusters) in the
maintenanceWindow
parameter. -
Permission to collect statistics for cluster performance diagnostics in the
performanceDiagnostics.profilingEnabled
parameter. -
Cluster deletion protection settings in the
deletionProtection
parameter.Enabled deletion protection will not prevent a manual connection with the purpose to delete database contents.
-
List of cluster configuration fields to update in the
updateMask
parameter.
Warning
The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the updateMask
parameter as a single comma-separated string.
Moving a cluster
- Go to the folder page and select Managed Service for MongoDB.
- Click
to the right of the cluster you want to move. - Select Move.
- Select a folder you want to move the cluster to.
- Click Move.
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To move a cluster:
-
View the description of the CLI move cluster command:
yc managed-mongodb cluster move --help
-
Specify the destination folder in the move cluster command:
yc managed-mongodb cluster move <cluster_name_or_ID> \ --destination-folder-name=<destination_folder_name>
You can get the cluster ID with a list of clusters in the folder.
To move a cluster, use the move REST API method for the Cluster resource or the ClusterService/Move gRPC API call and provide the following in the request:
- Cluster ID in the
clusterId
parameter. To find out the cluster ID, get a list of clusters in the folder. - ID of the destination folder in the
destinationFolderId
parameter.
Changing security groups
- Go to the folder page
and select Managed Service for MongoDB. - Select the cluster and click Edit in the top panel.
- Under Network settings, select security groups for cluster network traffic.
- Click Save changes.
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To edit the list of security groups for your cluster:
-
View the description of the update cluster CLI command:
yc managed-mongodb cluster update --help
-
Specify the security groups in the update cluster command:
yc managed-mongodb cluster update <cluster_name_or_ID> \ --security-group-ids <list_of_security_group_IDs>
-
Open the current Terraform configuration file with an infrastructure plan.
For more information about creating this file, see Creating clusters.
-
In the Managed Service for MongoDB cluster description, change the
security_group_ids
parameter value:resource "yandex_mdb_mongodb_cluster" "<cluster_name>" { ... security_group_ids = [ <list_of_security_group_IDs> ] ... }
-
Make sure the settings are correct.
-
Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.
-
Run the command:
terraform validate
If there are errors in the configuration files, Terraform will point to them.
-
-
Confirm updating the resources.
-
Run the command to view planned changes:
terraform plan
If the resource configuration descriptions are correct, the terminal will display a list of the resources to modify and their parameters. This is a test step. No resources are updated.
-
If you are happy with the planned changes, apply them:
-
Run the command:
terraform apply
-
Confirm the update of resources.
-
Wait for the operation to complete.
-
-
For more information, see the Terraform provider documentation
Timeouts
The Terraform provider sets the following timeouts for Managed Service for MongoDB cluster operations:
- Creating a cluster, including by restoring one from a backup: 30 minutes.
- Editing a cluster: 60 minutes.
Operations exceeding the set timeout are interrupted.
How do I change these limits?
Add the timeouts
block to the cluster description, for example:
resource "yandex_mdb_mongodb_cluster" "<cluster_name>" {
...
timeouts {
create = "1h30m" # An hour and a half
update = "2h" # Two hours
}
}
To update security groups, use the update REST API method for the Cluster resource or the ClusterService/Update gRPC API call and provide the following in the request:
- Cluster ID in the
clusterId
parameter. To find out the cluster ID, get a list of clusters in the folder. - List of security group IDs in the
securityGroupIds
parameter. - List of cluster configuration fields to update in the
updateMask
parameter.
Warning
The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the updateMask
parameter as a single comma-separated string.
Warning
You may need to additionally set up security groups to connect to the cluster.