Managing hosts in a cluster

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

Getting a list of cluster hosts

  1. Go to the folder page and click 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 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 flag.

To get a list of cluster databases, run the command:

$ yc managed-mongodb host list
     --cluster-name=<cluster name>
     
+----------------------------+--------------+---------+--------+---------------+
|            NAME            |  CLUSTER ID  |  ROLE   | HEALTH |    ZONE ID    |
+----------------------------+--------------+---------+--------+---------------+
| rc1b...mdb.yandexcloud.net | c9qp71dk1... | MASTER  | ALIVE  | ru-central1-b |
| rc1c...mdb.yandexcloud.net | c9qp71dk1... | REPLICA | ALIVE  | ru-central1-c |
+----------------------------+--------------+---------+--------+---------------+

The cluster name can be requested with a list of folder clusters.

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 quotas on the number of CPUs and the amount of RAM available to the DB clusters in your cloud. To check the resources in use, open the Quotas page and find the Yandex Managed Service for MongoDB.

  1. Go to the folder page and click 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 the Cloud.

If you don't have the Yandex.Cloud command line interface yet, install 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 flag.

To add a host to the cluster:

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

    $ yc managed-mongodb host add --help
    
  2. 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.

  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. The cluster name can be requested with a list of folder clusters.

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

Removing a host

You can remove a 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 delete the old one.

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

  1. Go to the folder page and click Managed Service for MongoDB.
  2. Click on the name of the cluster you need 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 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 flag.

To remove a host from the cluster, run:

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

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

To remove a host, use the deleteHosts method.