Managing Yandex StoreDoc cluster hosts
You can add or remove cluster hosts, restart host synchronization, and manage Yandex StoreDoc cluster settings. To learn how to migrate your cluster hosts to a different availability zone, see this guide.
Getting a list of cluster hosts
- Open the folder dashboard
. - Navigate to the Yandex StoreDoc service.
- Click the name of the Yandex StoreDoc cluster.
- Select the Hosts tab.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
To get the list of Yandex StoreDoc cluster hosts, run this command:
yc managed-mongodb host list \
--cluster-name <cluster_name>
Result:
+----------------------------+----------------------+--------+------------+--------------+----------+---------------+-----------+
| NAME | CLUSTER ID | TYPE | SHARD NAME | ROLE | HEALTH | ZONE ID | PUBLIC IP |
+----------------------------+----------------------+--------+------------+--------------+----------+---------------+-----------+
| rc1b...mdb.yandexcloud.net | c9qp71dk1q1w******** | MONGOD | rs01 | PRIMARY | ALIVE | ru-central1-b | false |
| rc1a...mdb.yandexcloud.net | c9qp71dk1q1w******** | MONGOD | rs01 | SECONDARY | ALIVE | ru-central1-a | false |
+----------------------------+----------------------+--------+------------+--------------+----------+---------------+-----------+
You can get the Yandex StoreDoc cluster name from the list of clusters in your folder.
-
Get an IAM token for API authentication and place it in an environment variable:
export IAM_TOKEN="<IAM_token>" -
Call the Cluster.ListHosts method, e.g., via the following cURL
request:curl \ --request GET \ --header "Authorization: Bearer $IAM_TOKEN" \ --url 'https://mdb.api.cloud.yandex.net/managed-mongodb/v1/clusters/<cluster_ID>/hosts'You can get the cluster ID from the list of clusters in your folder.
-
Check the server response to make sure your request was successful.
-
Get an IAM token for API authentication and place it in an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, we assume that the repository contents reside in the
~/cloudapi/directory. -
Call the ClusterService.ListHosts method, e.g., via the following gRPCurl
request: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>" }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.mongodb.v1.ClusterService.ListHostsYou can get the cluster ID from the list of clusters in your folder.
-
Check the server response to make sure your request was successful.
Adding a host
The number of hosts in Yandex StoreDoc clusters is limited by the CPU and memory quotas allocated to the database clusters in yourcloud. To review current resource usage, open the Quotas
You can add hosts of different types to your Yandex StoreDoc cluster. Their number depends on the sharding type:
| Sharding type | MONGOD | MONGOINFRA | MONGOS | MONGOCFG |
|---|---|---|---|---|
| No sharding | ⩾ 1 | — | — | — |
| Standard | ⩾ 1 | ⩾ 3 | — | — |
| Advanced | ⩾ 1 | — | ⩾ 2 | ⩾ 3 |
To add a host to your Yandex StoreDoc cluster:
- Open the folder dashboard
. - Navigate to the Yandex StoreDoc service.
- Click the name of your Yandex StoreDoc cluster and open the Hosts tab.
- Click Create host.
- Specify the following host settings:
-
Subnet (if the required subnet is not on the list, create it).
-
To make the host accessible from outside Yandex Cloud, select Public access.
-
Host type and shard name, if sharding is enabled for the Yandex StoreDoc cluster.
- Click Save.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
To add a host to your Yandex StoreDoc cluster:
-
To choose a subnet for your new host, first get the list of subnets in the Yandex StoreDoc cluster:
yc vpc subnet listResult:
+----------------------+-----------+-----------------------+---------------+------------------+ | ID | NAME | NETWORK ID | ZONE | RANGE | +----------------------+-----------+-----------------------+---------------+------------------+ | b0cl69a2b4c6******** | default-d | enp6rq72rndgr******** | ru-central1-d | [172.16.0.0/20] | | e2lkj9qwe762******** | default-b | enp6rq72rndgr******** | ru-central1-b | [10.10.0.0/16] | | e9b0ph42bn96******** | a-2 | enp6rq72rndgr******** | ru-central1-a | [172.16.32.0/20] | | e9b9v22r88io******** | default-a | enp6rq72rndgr******** | ru-central1-a | [172.16.16.0/20] | +----------------------+-----------+-----------------------+---------------+------------------+If the required subnet is not on the list, create it.
-
See the description of the CLI command for adding new hosts:
yc managed-mongodb host add --help -
Run this command to add a host:
yc managed-mongodb host add \ --cluster-name <cluster_name> \ --host zone-id=<availability_zone>,` `subnet-id=<subnet_ID>,` `assign-public-ip=<public_access>,` `hidden=<hide_host>,` `secondary-delay-secs=<replica_lag_in_seconds>,` `priority=<host_priority>Where:
--cluster-name: Cluster name. You can get it from the list of clusters in your folder.--host: Host settings:zone-id: Availability zone.subnet-id: Subnet ID. If your availability zone contains multiple subnets, make sure to specify the subnet ID. If only one exists, Yandex StoreDoc will auto-select it.assign-public-ip: Controls whether the host is accessible via a public IP address,trueorfalse.hidden: Determines whether the host is hidden,trueorfalse. A hidden host is still accessible for read operations, but only through direct connections. This can be useful, for example, for making backups without adding extra load to the cluster.secondary-delay-secs: Replica's lag behind the master in seconds. This setting can be useful for data recovery after operational errors.priority: Host priority for master promotion.
Yandex StoreDoc will start the host addition process.
To add a host to your Yandex StoreDoc cluster:
-
Open the current Terraform configuration file describing your infrastructure.
To learn how to create this file, see Creating a cluster.
-
Add the following to the Yandex StoreDoc cluster description:
- Required resources, based on sharding type, if you are adding a host to a sharded cluster:
resources_mongoinfrafor standard sharding.resources_mongosandresources_mongocfgfor advanced sharding.
hostblock.
resource "yandex_mdb_mongodb_cluster" "<cluster_name>" { ... resources_mongod { resource_preset_id = "<host_class>" disk_type_id = "<disk_type>" disk_size = <storage_size_in_GB> } resources_mongoinfra { # Add for standard sharding. resource_preset_id = "<host_class>" disk_type_id = "<disk_type>" disk_size = <storage_size_in_GB> } resources_mongos { # Add for advanced sharding. resource_preset_id = "<host_class>" disk_type_id = "<disk_type>" disk_size = <storage_size_in_GB> } resources_mongocfg { # Add for advanced sharding. resource_preset_id = "<host_class>" disk_type_id = "<disk_type>" disk_size = <storage_size_in_GB> } host { role = "<replica_type>" zone_id = "<availability_zone>" subnet_id = "<subnet_ID>" assign_public_ip = <public_access> shard_name = "<shard_name>" type = "<host_type>" host_parameters { hidden = <hide_host> secondary_delay_secs = <replica_lag_in_seconds> priority = <host_priority> } ... } }Where:
host: Host settings:role: Replica type,PRIMARYorSECONDARY.zone_id: Availability zone.subnet_id: ID of the subnet in the selected availability zone.assign_public_ip: Public access to the host,trueorfalse.shard_name: Shard name in a sharded cluster.type: Host type in a sharded cluster,MONGOD,MONGOINFRA,MONGOS, orMONGOCFG.host_parameters: Additional host settings:hidden: Determines whether the host is hidden,trueorfalse. A hidden host is still accessible for read operations, but only through direct connections. This can be useful, for example, for making backups without adding extra load to the cluster.secondary_delay_secs: Replica's lag behind the master in seconds. This setting can be useful for data recovery after operational errors.priority: Host priority for master promotion.
- Required resources, based on sharding type, if you are adding a host to a sharded cluster:
-
Validate your configuration.
-
In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
-
Run this command:
terraform validateTerraform will show any errors found in your configuration files.
-
-
Confirm resource changes.
-
Run this command to view the planned changes:
terraform planIf you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.
-
If everything looks correct, apply the changes:
-
Run this command:
terraform apply -
Confirm updating the resources.
-
Wait for the operation to complete.
-
-
For more information, see this Terraform provider guide.
Timeouts
The Terraform provider sets the following timeouts for Yandex StoreDoc 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 place it in an environment variable:
export IAM_TOKEN="<IAM_token>" -
Call the Cluster.AddHosts method, e.g., via the following cURL
request: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>/hosts:batchCreate' \ --data '{ "hostSpecs": [ { "zoneId": "<availability_zone>", "subnetId": "<subnet_ID>", "assignPublicIp": <public_access_to_host>, "type": "<host_type>", "shardName": "<shard_name>", "hidden": <hide_host>, "secondaryDelaySecs": "<replica_lag_in_seconds>", "priority": "<host_priority>", "tags": "<host_tags>" } ] }'Where
hostSpecsare the host settings:zoneId: Availability zone.subnetId: Subnet ID.assignPublicIp: Controls whether the host is accessible via a public IP address,trueorfalse.type: Host type in a sharded cluster,MONGOD,MONGOINFRA,MONGOS, orMONGOCFG. For a non-sharded cluster, useMONGOD.shardName: Shard name in a sharded cluster.hidden: Determines whether the host is hidden,trueorfalse. A hidden host is still accessible for read operations, but only through direct connections. This can be useful, for example, for making backups without adding extra load to the cluster.secondaryDelaySecs: Replica's lag behind the master in seconds. This setting can be useful for data recovery after operational errors.priority: Determines whether the host is hidden,trueorfalse. A hidden host is still accessible for read operations, but only through direct connections. This can be useful, for example, for making backups without adding extra load to the cluster.secondaryDelaySecs: Replica's lag behind the master in seconds. This setting can be useful for data recovery after operational errors.priority: Host priority for master promotion.tags: Host tags.
You can get the cluster ID from the list of clusters in your folder.
-
Check the server response to make sure your request was successful.
-
Get an IAM token for API authentication and place it in an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, we assume that the repository contents reside in the
~/cloudapi/directory. -
Call the ClusterService.AddHosts method, e.g., via the following gRPCurl
request: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>", "host_specs": [ { "zone_id": "<availability_zone>", "subnet_id": "<subnet_ID>", "assign_public_ip": <public_access_to_host>, "type": "<host_type>", "shard_name": "<shard_name>", "hidden": <hide_host>, "secondary_delay_secs": "<replica_lag_in_seconds>", "priority": "<host_priority>", "tags": "<host_tags>" } ] }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.mongodb.v1.ClusterService.AddHostsWhere
host_specsare the host settings:zone_id: Availability zone.subnet_id: Subnet ID.assign_public_ip: Controls whether the host is accessible via a public IP address,trueorfalse.type: Host type in a sharded cluster,MONGOD,MONGOINFRA,MONGOS, orMONGOCFG. For a non-sharded cluster, useMONGOD.shard_name: Shard name in a sharded cluster.hidden: Determines whether the host is hidden,trueorfalse. A hidden host is still accessible for read operations, but only through direct connections. This can be useful, for example, for making backups without adding extra load to the cluster.secondaryDelaySecs: Replica's lag behind the master in seconds. This setting can be useful for data recovery after operational errors.priority: Host priority for master promotion.tags: Host tags.
You can get the cluster ID from the list of clusters in your folder.
-
Check the server response to make sure your request was successful.
Warning
If you cannot connect to the new host, check the Yandex StoreDoc cluster‘s security group settings for its subnet.
Updating a host
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
To update the cluster host’s settings, run the following command:
yc managed-mongodb host update \
--cluster-name <cluster_name> \
--host hostname=<host_name>,`
`assign-public-ip=<public_access_to_host>,`
`hidden=<hide_host>,`
`secondary-delay-secs=<replica_lag_in_seconds>,`
`priority=<host_priority>
Where:
--cluster-name: Cluster name. You can get it from the list of clusters in your folder.--host: Host settings:hostname: Target host name. You can get it from the list of your cluster hosts.assign-public-ip: Controls whether the host is accessible via a public IP address,trueorfalse.hidden: Determines whether the host is hidden,trueorfalse. A hidden host is still accessible for read operations, but only through direct connections. This can be useful, for example, for making backups without adding extra load to the cluster.secondary-delay-secs: Replica's lag behind the master in seconds. This setting can be useful for data recovery after operational errors.priority: Host priority for master promotion.
To change the cluster host settings:
-
Open the current Terraform configuration file describing your infrastructure.
To learn how to create this file, see Creating a cluster.
For a complete list of configurable Managed Service for PostgreSQL cluster fields, refer to the Terraform provider guides.
-
In the Managed Service for PostgreSQL cluster description, change the attributes of the
hostsection referring to the host you want to update.resource "yandex_mdb_mongodb_cluster" "<cluster_name>" { ... host { assign_public_ip = <public_access_to_host> host_parameters { hidden = <hide_host> secondary_delay_secs = <replica_lag_in_seconds> priority = <host_priority> } } }
Where:
assign_public_ip: Controls whether the host is accessible via a public IP address,trueorfalse.host_parameters: Additional host settings:hidden: Determines whether the host is hidden,trueorfalse. A hidden host is still accessible for read operations, but only through direct connections. This can be useful, for example, for making backups without adding extra load to the cluster.secondary_delay_secs: Replica's lag behind the master in seconds. This setting can be useful for data recovery after operational errors.priority: Host priority for master promotion.
-
Validate your configuration.
-
In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
-
Run this command:
terraform validateTerraform will show any errors found in your configuration files.
-
-
Confirm resource changes.
-
Run this command to view the planned changes:
terraform planIf you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.
-
If everything looks correct, apply the changes:
-
Run this command:
terraform apply -
Confirm updating the resources.
-
Wait for the operation to complete.
-
Timeouts
The Terraform provider sets the following timeouts for Yandex StoreDoc 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
timeoutsblock 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 place it in an environment variable:
export IAM_TOKEN="<IAM_token>" -
Call the Cluster.updateHosts method, e.g., via the following cURL
request: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
updateMaskparameter as a single comma-separated string.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>/hosts:batchUpdate' \ --data '{ "updateHostSpecs": [ { "updateMask": "hostName,assignPublicIp,hidden,secondaryDelaySecs,priority", "hostName": "<host_name>", "assignPublicIp": <public_access_to_host>, "hidden": <hide_host>, "secondaryDelaySecs": "<replica_lag_in_seconds>", "priority": "<host_priority>" } ] }'Where
updateHostSpecsare the host settings:updateMask: Comma-separated list of settings you want to update.hostName: Target host name. You can get it from the list of your cluster hosts.assignPublicIp: Controls whether the host is accessible via a public IP address,trueorfalse.hidden: Determines whether the host is hidden,trueorfalse. A hidden host is still accessible for read operations, but only through direct connections. This can be useful, for example, for making backups without adding extra load to the cluster.secondaryDelaySecs: Replica's lag behind the master in seconds. This setting can be useful for data recovery after operational errors.priority: Host priority for master promotion.
You can get the cluster ID from the list of clusters in your folder.
-
Check the server response to make sure your request was successful.
-
Get an IAM token for API authentication and place it in an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, we assume that the repository contents reside in the
~/cloudapi/directory. -
Call the ClusterService/UpdateHosts method, e.g., via the following gRPCurl
request: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_maskparameter 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_host_specs": [ { "update_mask": { "paths": [ "assign_public_ip", "hidden", "secondary_delay_secs", "priority" ] }, "host_name": "<host_name>", "assign_public_ip": <public_access_to_host>, "hidden": <hide_host>, "secondary_delay_secs": "<replica_lag_in_seconds>", "priority": "<host_priority>" } ] }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.mongodb.v1.ClusterService.UpdateHostsWhere
update_host_specsare the host settings:update_mask: Comma-separated list of settings you want to update.host_name: Target host name. You can get it from the list of your cluster hosts.assign_public_ip: Controls whether the host is accessible via a public IP address,trueorfalse.hidden: Determines whether the host is hidden,trueorfalse. A hidden host is still accessible for read operations, but only through direct connections. This can be useful, for example, for making backups without adding extra load to the cluster.secondary_delay_secs: Replica's lag behind the master in seconds. This setting can be useful for data recovery after operational errors.priority: Host priority for master promotion.
You can get the cluster ID from the list of clusters in your folder.
-
Check the server response to make sure your request was successful.
Deleting a host
You can remove a MONGOD host from a Yandex StoreDoc cluster unless it is the cluster’s sole host. In order to replace a sole host, you must first create a new host and then delete the old one.
If the host being removed is the primary replica, Yandex StoreDoc will automatically elect a new primary replica.
In a sharded Yandex StoreDoc cluster, you can remove the MONGOS, MONGOCFG, or MONGOINFRA hosts, provided you keep the minimum number required for sharding.
To remove a host from a Yandex StoreDoc cluster:
- Open the folder dashboard
. - Navigate to the Yandex StoreDoc service.
- Locate the Yandex StoreDoc cluster you need in the list, click its name, and select the Hosts tab.
- Find the host you need in the list, click
in its row, and select Delete. - In the window that opens, check Delete host and click Confirm.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
To delete a host from a Yandex StoreDoc cluster, run this command:
yc managed-mongodb host delete <host_name>
--cluster-name <cluster_name>
You can get the host name from the list of Yandex StoreDoc cluster hosts and the cluster name from the list list of clusters in your folder.
To remove a host from a Yandex StoreDoc cluster:
-
Open the current Terraform configuration file describing your infrastructure.
To learn how to create this file, see Creating a cluster.
-
Delete the relevant
hostsection from the Yandex StoreDoc cluster description. -
Validate your configuration.
-
In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
-
Run this command:
terraform validateTerraform will show any errors found in your configuration files.
-
-
Type
yesand press Enter.-
Run this command to view the planned changes:
terraform planIf you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.
-
If everything looks correct, apply the changes:
-
Run this command:
terraform apply -
Confirm updating the resources.
-
Wait for the operation to complete.
-
-
For more information, see this Terraform provider guide.
Timeouts
The Terraform provider sets the following timeouts for Yandex StoreDoc 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 place it in an environment variable:
export IAM_TOKEN="<IAM_token>" -
Call the Cluster.DeleteHosts method, e.g., via the following cURL
request: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>/hosts:batchDelete' \ --data '{ "hostNames": [ "<host_name>" ] }'Where
hostNamesis an array containing the host names you want to delete. You can get the host name from the list of hosts in your cluster.You can get the cluster ID from the list of clusters in your folder.
-
Check the server response to make sure your request was successful.
-
Get an IAM token for API authentication and place it in an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, we assume that the repository contents reside in the
~/cloudapi/directory. -
Call the ClusterService.DeleteHosts method, e.g., via the following gRPCurl
request: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>", "host_names": [ "<host_name>" ] }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.mongodb.v1.ClusterService.DeleteHostsWhere
host_namesis an array containing the host names you want to delete. You can get the host name from the list of hosts in your cluster.You can get the cluster ID from the list of clusters in your folder.
-
Check the server response to make sure your request was successful.
Starting host resync
To resync a host with other replicas in the Yandex StoreDoc cluster or shard, run a forced resync. This operation can be applied to a single MONGOD host at a time and is restricted to Yandex StoreDoc clusters containing more than two replicas. The restriction applies irrespective of host class and type. Resync also frees up the host’s storage by removing collections and documents marked as deleted.
During this operation:
-
The host stops accepting write requests. If the host was a
PRIMARYreplica, Yandex StoreDoc will attempt to demote it to aSECONDARYreplica. In the event of failure, the operation is aborted. -
The Yandex StoreDoc instance on the host is stopped, and all its data is deleted.
-
The Yandex StoreDoc instance restarts and re-downloads data from the replicas.
-
Once the host has synced with the other replicas in the Yandex StoreDoc cluster, it is demoted to a secondary replica.
Note
- During synchronization, the host cannot process requests properly, as it holds only a subset of the Yandex StoreDoc cluster’s data.
- Estimated sync speed is 300 GB per day or more.
To force a host resync:
- Open the folder dashboard
. - Navigate to the Yandex StoreDoc service.
- Locate the Yandex StoreDoc cluster you need in the list, click its name, and select the Hosts tab.
- Find the host you need in the list, click
in its row, and select Resynchronize.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
To force a host resync, run this command:
yc managed-mongodb hosts resetup <host_name>
--cluster-name <cluster_name>
You can get the host name from the list of hosts in your folder. You can get the Yandex StoreDoc cluster name from the list of clusters in your folder.
-
Get an IAM token for API authentication and place it in an environment variable:
export IAM_TOKEN="<IAM_token>" -
Call the Cluster.ResetupHosts method, e.g., via the following cURL
request: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>:resetupHosts' \ --data '{ "hostNames": [ "<host_name>" ] }'Where
hostNamesis an array with the names of hosts you want to re-sync. You can get the host name from the list of hosts in your cluster.You can get the cluster ID from the list of clusters in your folder.
-
Check the server response to make sure your request was successful.
-
Get an IAM token for API authentication and place it in an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, we assume that the repository contents reside in the
~/cloudapi/directory. -
Call the ClusterService.ResetupHosts method, e.g., via the following gRPCurl
request: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>", "host_names": [ "<host_name>" ] }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.mongodb.v1.ClusterService.ResetupHostsWhere
host_namesis an array with the names of hosts you want to re-sync. You can get the host name from the list of hosts in your cluster.You can get the cluster ID from the list of clusters in your folder.
-
Check the server response to make sure your request was successful.
Restarting a host
You can manually restart Yandex StoreDoc cluster hosts.
A host restart may result in temporary downtime for the Yandex StoreDoc cluster or shard:
- If your cluster consists of a single host.
- If the host being rebooted is the primary replica.
A primary replica restart does not trigger an automatic failover. To prevent Yandex StoreDoc cluster downtime, switch its primary replica before restarting the host.
Note
You can only restart one host at a time.
To restart a host:
- Open the folder dashboard
. - Navigate to the Yandex StoreDoc service.
- Locate the Yandex StoreDoc cluster you need in the list, click its name, and select the Hosts tab.
- Find the host you need in the list, click
in its row, and select Restart. - Confirm host reboot.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
To restart a host, run this command:
yc managed-mongodb hosts restart <host_name> \
--cluster-name <cluster_name>
-
Get an IAM token for API authentication and place it in an environment variable:
export IAM_TOKEN="<IAM_token>" -
Call the Cluster.RestartHosts method, e.g., via the following cURL
request: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>:restartHosts' \ --data '{ "hostNames": [ "<host_name>" ] }'Where
hostNamesis an array with the names of hosts you want to restart. You can get the host name from the list of hosts in your cluster.You can get the cluster ID from the list of clusters in your folder.
-
Check the server response to make sure your request was successful.
-
Get an IAM token for API authentication and place it in an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, we assume that the repository contents reside in the
~/cloudapi/directory. -
Call the ClusterService.RestartHosts method, e.g., via the following gRPCurl
request: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>", "host_names": [ "<host_name>" ] }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.mongodb.v1.ClusterService.RestartHostsWhere
host_namesis an array with the names of hosts you want to restart. You can get the host name from the list of hosts in your cluster.You can get the cluster ID from the list of clusters in your folder.
-
Check the server response to make sure your request was successful.