Yandex.Cloud
  • Services
  • Why Yandex.Cloud
  • Solutions
  • Pricing
  • Documentation
  • Contact us
Get started
Yandex Managed Service for MongoDB
  • Getting started
  • Step-by-step instructions
    • All instructions
    • Information about existing clusters
    • Creating clusters
    • Database migration to Yandex.Cloud
    • Connecting to databases
    • Stopping and starting clusters
    • Changing cluster and database settings
    • MongoDB version upgrade
    • Database management
    • Managing hosts in a cluster
    • Managing database users
    • Managing backups
    • Managing shards
    • Deleting clusters
  • Solutions
    • Sharding collections
  • Concepts
    • Relationship between service resources
    • Host classes
      • Active host classes
      • Archive
        • Before June 1, 2020
      • Using deprecated host classes
    • Network in Yandex Managed Service for MongoDB
    • Quotas and limits
    • Storage types
    • Backups
    • Replication
    • Sharding
    • Users and roles
    • Supported clients
  • Access management
  • Pricing policy
    • Current pricing policy
    • Archive
      • Before January 1, 2019
      • From January 1 to March 1, 2019
      • From March 1, 2019 to February 1, 2020
  • API reference
    • Authentication in the API
    • gRPC
      • Обзор
      • BackupService
      • ClusterService
      • DatabaseService
      • ResourcePresetService
      • UserService
      • OperationService
    • REST
      • Overview
      • Backup
        • Overview
        • get
        • list
      • Cluster
        • Overview
        • addHosts
        • addShard
        • backup
        • create
        • delete
        • deleteHosts
        • deleteShard
        • enableSharding
        • get
        • getShard
        • list
        • listBackups
        • listHosts
        • listLogs
        • listOperations
        • listShards
        • move
        • rescheduleMaintenance
        • resetupHosts
        • restartHosts
        • restore
        • start
        • stop
        • streamLogs
        • update
      • Database
        • Overview
        • create
        • delete
        • get
        • list
      • ResourcePreset
        • Overview
        • get
        • list
      • User
        • Overview
        • create
        • delete
        • get
        • grantPermission
        • list
        • revokePermission
        • update
      • Operation
        • Overview
        • get
  • Questions and answers
    • General questions
    • Questions about MongoDB
    • All questions on the same page
  1. Step-by-step instructions
  2. Managing hosts in a cluster

Managing hosts in a cluster

  • Getting a list of cluster hosts
  • Adding a host
  • Deleting a host
  • Starting host resync

You can add and remove cluster hosts, resync the hosts, and manage settings MongoDB for individual clusters.

Getting a list of cluster hosts

Management console
CLI
API
  1. Go to the folder page and select Managed Service for MongoDB.

  2. Click on the name of the cluster you need and select the Hosts tab.

If you don't 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 get a list of cluster hosts, run the command:

$ yc managed-mongodb host list
     --cluster-name <cluster name>

+----------------------------+--------------+--------+------------+--------------+----------+---------------+-----------+
|            NAME            |  CLUSTER ID  |  TYPE  | SHARD NAME |     ROLE     |  HEALTH  |    ZONE ID    | PUBLIC IP |
+----------------------------+--------------+--------+------------+--------------+----------+---------------+-----------+
| rc1b...mdb.yandexcloud.net | c9qp71dk1... | MONGOD | rs01       | PRIMARY      | ALIVE    | ru-central1-b | false     |
| rc1c...mdb.yandexcloud.net | c9qp71dk1... | MONGOD | rs01       | SECONDARY    | ALIVE    | ru-central1-c | false     |
+----------------------------+--------------+--------+------------+--------------+----------+---------------+-----------+

You can query the cluster name with the list of clusters in the folder.

To get a list of cluster hosts, use the listHosts method.

Adding a host

The number of hosts in Managed Service for MongoDB clusters is limited by the CPU and RAM quotas available to DB clusters in your cloud. To check the resources in use, open the Quotas page and find the Yandex Managed Service for MongoDB block.

You can add different types of hosts to a cluster. Their number depends on the sharding type:

Shard type MONGOD MONGOINFRA MONGOS MONGOCFG
No sharding ⩾ 1 — — —
Standard ⩾ 1 ⩾ 3 — —
Advanced ⩾ 1 — ⩾ 2 ⩾ 3
Management console
CLI
API
  1. Go to the folder page and select Managed Service for MongoDB.

  2. Click on the name of the cluster you need and go to the Hosts tab.

  3. Click Add host.

  4. Specify the host parameters:

    • Availability zone.

    • Subnet (if the necessary subnet is not in the list, create it).

    • Select the Public access option if the host must be accessible from outside Yandex.Cloud.

    • Host type and shard name, if sharding is enabled for the cluster.

If you don't 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 add a host to the cluster:

  1. Request a list of cluster subnets to select one for the new host:

    $ yc vpc subnet list
    
    +-----------+-----------+------------+---------------+------------------+
    |     ID    |   NAME    | NETWORK ID |     ZONE      |      RANGE       |
    +-----------+-----------+------------+---------------+------------------+
    | b0cl69... | default-c | enp6rq7... | ru-central1-c | [172.16.0.0/20]  |
    | e2lkj9... | default-b | enp6rq7... | ru-central1-b | [10.10.0.0/16]   |
    | e9b0ph... | a-2       | enp6rq7... | ru-central1-a | [172.16.32.0/20] |
    | e9b9v2... | default-a | enp6rq7... | ru-central1-a | [172.16.16.0/20] |
    +-----------+-----------+------------+---------------+------------------+
    

    If the necessary subnet is not in the list, create it.

  2. See the description of the CLI command for adding a host:

    $ yc managed-mongodb host add --help
    
  3. Run the add host command:

    $ yc managed-mongodb host add
         --cluster-name <cluster name>
         --host zone-id=<availability zone>,subnet-id=<subnet ID>
    

    Managed Service for MongoDB will run the add host operation.

    The subnet ID should be specified if the availability zone contains multiple subnets, otherwise Managed Service for MongoDB automatically selects a single subnet. You can retrieve the cluster name with the list of clusters in the folder.

To add a host to the cluster, use the addHosts method.

Deleting a host

You can remove a MONGOD host from a MongoDB cluster if it is not the only host in it. To replace a single host, first create a new host and then remove the old one.

If the host is a primary one at the time of removal, Managed Service for MongoDB automatically selects a new primary replica.

From a sharded cluster, you may remove the MONGOS, MONGOCFG, or MONGOINFRA hosts that exceed the minimum number needed for sharding.

Management console
CLI
API
  1. Go to the folder page and select Managed Service for MongoDB.

  2. Click on the name of the cluster you want and select the Hosts tab.

  3. Click in the line of the necessary host and select Delete.

If you don't 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 remove a host from the cluster, run:

$ yc managed-mongodb host delete <host name>
     --cluster-name <cluster name>

The host name can be requested with a list of cluster hosts, and the cluster name can be requested with a list of clusters in the folder.

To remove a host, use the deleteHosts method.

Starting host resync

To resync a host with other replicas in the Managed Service for MongoDB cluster or shard, run forced resync. The operation can be applied to only one MONGOD host at a time and only for clusters with more than two replicas, regardless of the host class and type. Resync also lets you remove the collections and documents that were marked as deleted from the host's storage.

During this operation:

  1. The host stops accepting write requests. If the host was a PRIMARY replica, Managed Service for MongoDB will try to make it a SECONDARY replica. If the operation fails, it is aborted.

  2. The MongoDB instance on the host stops and all data is deleted.

  3. The MongoDB instance restarts and downloads data from replica hosts again.

  4. After the host has synced with other replicas in the cluster, it becomes a secondary replica.

    Note

    • During syncing, the host can't fully respond to any request, because it has only part of the Managed Service for MongoDB cluster data.
    • Estimated sync rate: 300 GB per day or more.
CLI

If you don't 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 forcibly resync a host, run the following command:

$ yc managed-mongodb hosts resetup <host_name>
   --cluster-name <cluster name>

You can obtain the host name with a list of hosts in the folder. The cluster name can be requested with a list of clusters in the folder.

In this article:
  • Getting a list of cluster hosts
  • Adding a host
  • Deleting a host
  • Starting host resync
Language / Region
Careers
Privacy policy
Terms of use
Brandbook
© 2021 Yandex.Cloud LLC