Updating MongoDB cluster settings
After creating a cluster, you can:
- Change the host class.
- Change the disk type and increase the 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 CLI yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder through the --folder-name
or --folder-id
parameter.
To change the host class for the cluster:
-
View the description of the CLI command to update the cluster:
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
}
}
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Use the Cluster.Update method and send the following request, e.g., via cURL
: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.curl \ --request PATCH \ --header "Authorization: Bearer $IAM_TOKEN" \ --header "Content-Type: application/json" \ --url 'https://mdb.api.cloud.yandex.net/managed-mongodb/v1/clusters/<cluster_ID>' \ --data '{ "updateMask": "configSpec.mongodb.<MongoDB_host_type>.resources.resourcePresetId", "configSpec": { "mongodb": { "<MongoDB_host_type>": { "resources": { "resourcePresetId": "<host_class>" } } } } }'
Where:
-
updateMask
: List of parameters to update as a single string, separated by commas.Only one parameter is provided in this case.
-
configSpec.mongodb.<MongoDB_host_type>.resources.resourcePresetId
: New host class.MongoDB host type depends on the sharding type. Possible values:
mongod
,mongocfg
,mongos
, andmongoinfra
. For a non-sharded cluster, usemongod
.
You can request the cluster ID with the list of clusters in the folder.
-
-
View the server response to make sure the request was successful.
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
Below, we assume the repository contents are stored in the
~/cloudapi/
directory. -
Use the ClusterService.Update call and send the following request, e.g., via gRPCurl
: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
update_mask
parameter as an array ofpaths[]
strings.Format for listing settings
"update_mask": { "paths": [ "<setting_1>", "<setting_2>", ... "<setting_N>" ] }
grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/mongodb/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>", "update_mask": { "paths": [ "config_spec.mongodb.<MongoDB_host_type>.resources.resource_preset_id" ] }, "config_spec": { "mongodb": { "<MongoDB_host_type>": { "resources": { "resource_preset_id": "<host_class>" } } } } }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.mongodb.v1.ClusterService.Update
Where:
-
update_mask
: List of parameters to update as an array ofpaths[]
strings.Only one parameter is provided in this case.
-
config_spec.mongodb.<MongoDB_host_type>.resources.resourcepresetid
: New host class.MongoDB host type depends on the sharding type. Possible values:
mongod
,mongocfg
,mongos
, andmongoinfra
. For a non-sharded cluster, usemongod
.
You can request the cluster ID with the list of clusters in the folder.
-
-
View the server response to make sure the request was successful.
Change the disk type and increase the storage size
Make sure the cloud has enough quota to increase the storage size. Open the cloud's Quotas
To change the disk type and increase the storage size for a cluster:
-
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:
- Select the disk type.
- Specify the required disk size.
-
Click Save changes.
If you do not have the Yandex Cloud CLI yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder through the --folder-name
or --folder-id
parameter.
To change the disk type and increase the storage size for a cluster:
-
View the description of the CLI command to update the cluster:
yc managed-mongodb cluster update --help
-
Specify the disk type and required storage size in the cluster update command (at least as large as
disk_size
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-type <disk_type> \ --mongod-disk-size <storage_size_in_GB>
-
For
MONGOINFRA
hosts:yc managed-mongodb cluster update <cluster_name_or_ID> \ --mongoinfra-disk-type <disk_type> \ --mongoinfra-disk-size <storage_size_in_GB>
-
For
MONGOS
hosts:yc managed-mongodb cluster update <cluster_name_or_ID> \ --mongos-disk-type <disk_type> \ --mongos-disk-size <storage_size_in_GB>
-
For
MONGOCFG
hosts:yc managed-mongodb cluster update <cluster_name_or_ID> \ --mongocfg-disk-type <disk_type> \ --mongocfg-disk-size <storage_size_in_GB>
If all the conditions are met, Managed Service for MongoDB will start the storage reconfiguration operation.
-
To change the disk type and increase the storage size for a 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 values of the
disk_type_id
anddisk_size
parameters for the following resources:resources_mongod
,resources_mongoinfra
,resources_mongos
, andresources_mongocfg
. The resource type depends on the sharding type.Example:
resource "yandex_mdb_mongodb_cluster" "<cluster_name>" { ... resources_mongod { disk_type_id = "<disk_type>" 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
}
}
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Use the Cluster.Update method and send the following request, e.g., via cURL
: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.curl \ --request PATCH \ --header "Authorization: Bearer $IAM_TOKEN" \ --header "Content-Type: application/json" \ --url 'https://mdb.api.cloud.yandex.net/managed-mongodb/v1/clusters/<cluster_ID>' \ --data '{ "updateMask": "configSpec.mongodb.<MongoDB_host_type>.resources.diskTypeId,configSpec.mongodb.<MongoDB_host_type>.resources.diskSize", "configSpec": { "mongodb": { "<MongoDB_host_type>": { "resources": { "diskTypeId": "<disk_type>", "diskSize": "<storage_size_in_bytes>" } } } } }'
Where:
-
updateMask
: List of parameters to update as a single string, separated by commas. -
configSpec.mongodb.<MongoDB_host_type>.resources
: Storage parameters:diskTypeId
: Disk type.diskSize
: New storage size in bytes.
MongoDB host type depends on the sharding type. Possible values:
mongod
,mongocfg
,mongos
, andmongoinfra
. For a non-sharded cluster, usemongod
.
You can request the cluster ID with the list of clusters in the folder.
-
-
View the server response to make sure the request was successful.
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
Below, we assume the repository contents are stored in the
~/cloudapi/
directory. -
Use the ClusterService.Update call and send the following request, e.g., via gRPCurl
: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
update_mask
parameter as an array ofpaths[]
strings.Format for listing settings
"update_mask": { "paths": [ "<setting_1>", "<setting_2>", ... "<setting_N>" ] }
grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/mongodb/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>", "update_mask": { "paths": [ "config_spec.mongodb.<MongoDB_host_type>.resources.disk_type_id", "config_spec.mongodb.<MongoDB_host_type>.resources.disk_size" ] }, "config_spec": { "mongodb": { "<MongoDB_host_type>": { "resources": { "disk_type_id": "<disk_type>", "disk_size": "<storage_size_in_bytes>" } } } } }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.mongodb.v1.ClusterService.Update
Where:
-
update_mask
: List of parameters to update as an array ofpaths[]
strings. -
config_spec.mongodb.<MongoDB_host_type>.resources.disk_size
: Storage parameters:disk_type_id
: Disk type.disk_size
: New storage size in bytes.
The MongoDB host type depends on the sharding type. Possible values:
mongod
,mongocfg
,mongos
, andmongoinfra
. For a non-sharded cluster, usemongod
.
You can request the cluster ID with the list of clusters in the folder.
-
-
View the server response to make sure the request was successful.
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 CLI yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder through 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.
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Use the Cluster.Update method and send the following request, e.g., via cURL
: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.curl \ --request PATCH \ --header "Authorization: Bearer $IAM_TOKEN" \ --header "Content-Type: application/json" \ --url 'https://mdb.api.cloud.yandex.net/managed-mongodb/v1/clusters/<cluster_ID>' \ --data '{ "updateMask": "configSpec.mongodb.<MongoDB_host_type>.config.<setting_1>,configSpec.mongodb.<MongoDB_host_type>.config.<setting_2>,...,configSpec.mongodb.<MongoDB_host_type>.config.<setting_N>", "configSpec": { "mongodb": { "<MongoDB_host_type>": { "config": { "<setting_1>": "<value_1>", "<setting_2>": "<value_2>", ... "<setting_N>": "<value_N>" } } } } }'
Where:
-
updateMask
: List of parameters to update as a single string, separated by commas. -
configSpec.mongodb.<MongoDB_host_type>.config
: Set of MongoDB settings. Use a separate line for each setting; separate them by commas. All supported settings are described in the API reference and in MongoDB settings.MongoDB host type depends on the sharding type. Possible values:
mongod
,mongocfg
,mongos
, andmongoinfra
. For a non-sharded cluster, usemongod
.
You can request the cluster ID with the list of clusters in the folder.
-
-
View the server response to make sure the request was successful.
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
Below, we assume the repository contents are stored in the
~/cloudapi/
directory. -
Use the ClusterService.Update call and send the following request, e.g., via gRPCurl
: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
update_mask
parameter as an array ofpaths[]
strings.Format for listing settings
"update_mask": { "paths": [ "<setting_1>", "<setting_2>", ... "<setting_N>" ] }
grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/mongodb/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>", "update_mask": { "paths": [ "config_spec.mongodb.<MongoDB_host_type>.config.<setting_1>", "config_spec.mongodb.<MongoDB_host_type>.config.<setting_2>", ... "config_spec.mongodb.<MongoDB_host_type>.config.<setting_N>" ] }, "config_spec": { "mongodb": { "<MongoDB_host_type>": { "config": { "<setting_1>": "<value_1>", "<setting_2>": "<value_2>", ... "<setting_N>": "<value_N>" } } } } }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.mongodb.v1.ClusterService.Update
Where:
-
update_mask
: List of parameters to update as an array ofpaths[]
strings. -
config_spec.mongodb.<MongoDB_host_type>.config
: Set of MongoDB settings. Use a separate line for each setting; separate them by commas. All supported settings are described in the API reference and in MongoDB settings.MongoDB host type depends on the sharding type. Possible values:
mongod
,mongocfg
,mongos
, andmongoinfra
. For a non-sharded cluster, usemongod
.
You can request the cluster ID with the list of clusters in the folder.
-
-
View the server response to make sure the request was successful.
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 CLI yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder through the --folder-name
or --folder-id
parameter.
To change additional cluster settings:
-
View the description of the CLI command to update the cluster:
yc managed-mongodb cluster update --help
-
Run the following command with the 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 the 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 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
}
}
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Create a file named
body.json
and add the following contents to it: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.{ "updateMask": "configSpec.backupWindowStart,configSpec.backupRetainPeriodDays,configSpec.performanceDiagnostics,maintenanceWindow,deletionProtection", "configSpec": { "backupWindowStart": { "hours": "<hours>", "minutes": "<minutes>", "seconds": "<seconds>", "nanos": "<nanoseconds>" }, "backupRetainPeriodDays": "<backup_storage_time_in_days>", "performanceDiagnostics": { "profilingEnabled": <enable_profiler:_true_or_false> } } "maintenanceWindow": { "weeklyMaintenanceWindow": { "day": "<day_of_week>", "hour": "<hour>" } }, "deletionProtection": <deletion_protection:_true_or_false> }
Where:
-
updateMask
: List of parameters to update as a single string, separated by commas. -
configSpec
: Cluster settings:-
backupWindowStart
: Backup window settings.In this parameter, specify the backup start time:
hours
: Between0
and23
hours.minutes
: Between0
and59
minutes.seconds
: Between0
and59
seconds.nanos
: Between0
and999999999
nanoseconds.
-
backupRetainPeriodDays
: Backup storage time in days. -
performanceDiagnostics
: Statistics collection settings:profilingEnabled
: Enable profiler.
-
-
maintenanceWindow
: Maintenance window settings (including for disabled clusters). InmaintenanceWindow
, provide one of the two parameters:-
anytime
: Maintenance can take place at any time. -
weeklyMaintenanceWindow
: Maintenance takes place once a week at the specified time:day
: Day of week, inDDD
format.hour
: Hour, inHH
format. The values range from1
to24
hours.
-
-
deletionProtection
: Protection of the cluster, its databases, and users against accidental deletion. Even if enabled, one can still connect manually and delete the database content.
-
-
Use the Cluster.Update method and send the following request, e.g., via cURL
:curl \ --request PATCH \ --header "Authorization: Bearer $IAM_TOKEN" \ --header "Content-Type: application/json" \ --url 'https://mdb.api.cloud.yandex.net/managed-mongodb/v1/clusters/<cluster_ID>' \ --data "@body.json"
You can request the cluster ID with the list of clusters in the folder.
-
View the server response to make sure the request was successful.
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
Below, we assume the repository contents are stored in the
~/cloudapi/
directory. -
Create a file named
body.json
and add the following contents to it: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
update_mask
parameter as an array ofpaths[]
strings.Format for listing settings
"update_mask": { "paths": [ "<setting_1>", "<setting_2>", ... "<setting_N>" ] }
{ "cluster_id": "<cluster_ID>", "update_mask": { "paths": [ "config_spec.backup_window_start", "config_spec.backup_retain_period_days", "config_spec.performance_diagnostics", "maintenance_window", "deletion_protection" ] }, "config_spec": { "backup_window_start": { "hours": "<hours>", "minutes": "<minutes>", "seconds": "<seconds>", "nanos": "<nanoseconds>" }, "backup_retain_period_days": "<backup_storage_time_in_days>", "performance_diagnostics": { "profiling_enabled": <enable_profiler:_true_or_false> } }, "maintenance_window": { "weekly_maintenance_window": { "day": "<day_of_week>", "hour": "<hour>" } }, "deletion_protection": <deletion_protection:_true_or_false> }
Where:
-
update_mask
: List of parameters to update as an array ofpaths[]
strings. -
config_spec
: Cluster settings:-
backup_window_start
: Backup window settings.In this parameter, specify the backup start time:
hours
: Between0
and23
hours.minutes
: Between0
and59
minutes.seconds
: Between0
and59
seconds.nanos
: Between0
and999999999
nanoseconds.
-
backup_retain_period_days
: Backup retention in days. -
performance_diagnostics
: Statistics collection settings:profiling_enabled
: Enable profiler.
-
-
maintenance_window
: Maintenance window settings (including for disabled clusters). Inmaintenance_window
, provide one of the two parameters:-
anytime
: Maintenance can take place at any time. -
weekly_maintenance_window
: Maintenance takes place once a week at the specified time:day
: Day of week, inDDD
format.hour
: Hour, inHH
format. The values range from1
to24
hours.
-
-
deletion_protection
: Protection of the cluster, its databases, and users against accidental deletion. Even if enabled, one can still connect manually and delete the database content.
-
-
Use the ClusterService.Update call and send the following request, e.g., via gRPCurl
:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/mongodb/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d @ \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.mongodb.v1.ClusterService.Update \ < body.json
-
View the server response to make sure the request was successful.
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 CLI yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder through 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 the list of clusters in the folder.
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Use the Cluster.Move method and send the following request, e.g., via cURL
:curl \ --request POST \ --header "Authorization: Bearer $IAM_TOKEN" \ --header "Content-Type: application/json" \ --url 'https://mdb.api.cloud.yandex.net/managed-mongodb/v1/clusters/<cluster_ID>:move' \ --data '{ "destinationFolderId": "<folder_ID>" }'
Where
destinationFolderId
is the ID of the folder you want to move your cluster to. You can fetch this ID together with the list of folders in the cloud.You can request the cluster ID with the list of clusters in the folder.
-
View the server response to make sure the request was successful.
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
Below, we assume the repository contents are stored in the
~/cloudapi/
directory. -
Use the ClusterService.Move call and send the following request, e.g., via gRPCurl
:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/mongodb/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>", "destination_folder_id": "<folder_ID>" }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.mongodb.v1.ClusterService.Move
Where
destination_folder_id
is the ID of the folder you want to move your cluster to. You can fetch this ID together with the list of folders in the cloud.You can request the cluster ID with the list of clusters in the folder.
-
View the server response to make sure the request was successful.
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 CLI yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder through the --folder-name
or --folder-id
parameter.
To edit the list of security groups for your cluster:
-
View the description of the CLI command to update the cluster:
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
}
}
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Use the Cluster.Update method and send the following request, e.g., via cURL
: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.curl \ --request PATCH \ --header "Authorization: Bearer $IAM_TOKEN" \ --header "Content-Type: application/json" \ --url 'https://mdb.api.cloud.yandex.net/managed-mongodb/v1/clusters/<cluster_ID>' \ --data '{ "updateMask": "securityGroupIds", "securityGroupIds": [ "<security_group_1_ID>", "<security_group_2_ID>", ... "<security_group_N_ID>" ] }'
Where:
-
updateMask
: List of parameters to update as a single string, separated by commas.Only one parameter is provided in this case.
-
securityGroupIds
: List of security group IDs.
You can request the cluster ID with the list of clusters in the folder.
-
-
View the server response to make sure the request was successful.
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
Below, we assume the repository contents are stored in the
~/cloudapi/
directory. -
Use the ClusterService.Update call and send the following request, e.g., via gRPCurl
: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
update_mask
parameter as an array ofpaths[]
strings.Format for listing settings
"update_mask": { "paths": [ "<setting_1>", "<setting_2>", ... "<setting_N>" ] }
grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/mongodb/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>", "update_mask": { "paths": [ "security_group_ids" ] }, "security_group_ids": [ "<security_group_1_ID>", "<security_group_2_ID>", ... "<security_group_N_ID>" ] }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.mongodb.v1.ClusterService.Update
Where:
-
update_mask
: List of parameters to update as an array ofpaths[]
strings.Only one parameter is provided in this case.
-
security_group_ids
: List of security group IDs.
You can request the cluster ID with the list of clusters in the folder.
-
-
View the server response to make sure the request was successful.
Warning
You may need to additionally set up security groups to connect to the cluster.