[Yandex Cloud documentation](../../index.md) > [Yandex Managed Service for ClickHouse®](../index.md) > [Step-by-step guides](index.md) > Clusters > Managing hosts > Changing a coordination service

# Changing the coordination service from embedded ClickHouse® Keeper to ClickHouse® Keeper on separate hosts

If using embedded ClickHouse® Keeper as a coordination service, you can change it to ClickHouse® Keeper on separate hosts. Once you enable ClickHouse® Keeper on separate hosts, you cannot disable it or switch back to embedded ClickHouse® Keeper.

{% note warning %}

ClickHouse® Keeper hosts are counted towards the cloud [resource quota](https://console.yandex.cloud/cloud?section=quotas) and the [cluster cost](../pricing.md).

{% endnote %}

{% list tabs group=instructions %}

- CLI {#cli}

  If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../cli/quickstart.md#install).

  The folder used by default is the one specified when [creating](../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`.
  
  If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

  To change the coordination service:

  1. View the command description:

      ```bash
      yc managed-clickhouse cluster add-zookeeper --help
      ```

  1. In the command, specify the following host parameters:

      
      ```bash
      yc managed-clickhouse cluster add-zookeeper \
        --name <cluster_name> \
        --resource-preset <host_class> \
        --disk-type <disk_type> \
        --disk-size <storage_size> \
        --host type=keeper,`
              `zone-id=<availability_zone>,`
              `subnet-id=<subnet_ID> \
        --convert-tables-to-replicated <convert_tables>
      ```


      Where:

      * `--resource-preset`: [Host class](../concepts/instance-types.md).
      * `--disk-type`: [Disk type](../concepts/storage.md).
      * `--disk-size`: Storage size, in bytes.

      * `--host`: Host settings:
        * `type`: Host type, `keeper`.
        * `zone-id`: [Availability zone](../../overview/concepts/geo-scope.md).

        
        * `subnet-id`: Subnet ID. Specify if the selected availability zone has two or more subnets.


        You can add multiple hosts at once. Specify a separate `--host` flag for each host.

      * `--convert-tables-to-replicated`: Convert non-replicated tables to [replicated](../concepts/replication.md#replicated-tables) ones.

      You can get the cluster name from the [list of clusters in your folder](cluster-list.md#list-clusters).

- REST API {#api}

    To change the coordination service:

    1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

        ```bash
        export IAM_TOKEN="<IAM_token>"
        ```

    1. Call the [Cluster.AddZookeeper](../api-ref/Cluster/addZookeeper.md) method, e.g., via the following [cURL](https://curl.se/) request:

        1. Create a file named `body.json` and paste the following code into it:

            
            ```json
            {
              "resources": {
                "resourcePresetId": "<host_class>",
                "diskSize": "<storage_size>",
                "diskTypeId": "<disk_type>"
              },
              "hostSpecs": [
                {
                  "zoneId": "<availability_zone>",
                  "type": "KEEPER",
                  "subnetId": "<subnet_ID>"
                }
              ],
              "convertTablesToReplicated": <convert_tables>
            }
            ```


            Where:

            * `resources`: Host configuration:

               * `resourcePresetId`: [Host class](../concepts/instance-types.md) ID. You can get the list of available host classes with their IDs using the [ResourcePreset.list](../api-ref/ResourcePreset/list.md) method.
               * `diskSize`: Storage size, in bytes.
               * `diskTypeId`: [Disk type](../concepts/storage.md).

            * `hostSpecs`: Host settings as an array of elements, one per host. Each element has the following structure:

                * `zoneId`: [Availability zone](../../overview/concepts/geo-scope.md).
                * `type`: Host type, `KEEPER`.

                
                * `subnetId`: [Subnet](../../vpc/concepts/network.md#subnet) ID.


            * `convertTablesToReplicated`: Convert non-replicated tables to [replicated](../concepts/replication.md#replicated-tables) ones.

            You can get the cluster ID with the [list of clusters in the folder](cluster-list.md#list-clusters).

        1. Run this request:

            ```bash
            curl \
              --request POST \
              --header "Authorization: Bearer $IAM_TOKEN" \
              --header "Content-Type: application/json" \
              --url 'https://mdb.api.cloud.yandex.net/managed-clickhouse/v1/clusters/<cluster_ID>:addZookeeper' \
              --data '@body.json'
            ```

    1. View the [server response](../api-ref/Cluster/addZookeeper.md#yandex.cloud.operation.Operation) to make sure your request was successful.

- gRPC API {#grpc-api}

    To change the coordination service:

    1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

        ```bash
        export IAM_TOKEN="<IAM_token>"
        ```

    1. Clone the [cloudapi](https://github.com/yandex-cloud/cloudapi) repository:
       
       ```bash
       cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
       ```
       
       Below, we assume that the repository contents reside in the `~/cloudapi/` directory.

    1. Call the [ClusterService.AddZookeeper](../api-ref/grpc/Cluster/addZookeeper.md) method, e.g., via the following [gRPCurl](https://github.com/fullstorydev/grpcurl) request:

        1. Create a file named `body.json` and paste the following code into it:

            
            ```json
            {
              "cluster_id": "<cluster_ID>",
              "resources": {
                "resource_preset_id": "<host_class>",
                "disk_size": "<storage_size>",
                "disk_type_id": "<disk_type>"
              },
              "host_specs": [
                {
                  "zone_id": "<availability_zone>",
                  "type": "KEEPER",
                  "subnet_id": "<subnet_ID>",
                }
              ],
              "convert_tables_to_replicated": <convert_tables>
            }
            ```


            Where:

            * `resources`: Host configuration:

               * `resource_preset_id`: [Host class](../concepts/instance-types.md) ID. You can get the list of available host classes with their IDs using the [ResourcePresetService.List](../api-ref/grpc/ResourcePreset/list.md) method.
               * `disk_size`: Storage size, in bytes.
               * `disk_type_id`: [Disk type](../concepts/storage.md).

            * `host_specs`: Host settings as an array of elements, one per host. Each element has the following structure:

                * `zone_id`: [Availability zone](../../overview/concepts/geo-scope.md).
                * `type`: Host type, `KEEPER`.

                
                * `subnet_id`: [Subnet](../../vpc/concepts/network.md#subnet) ID.


            * `convertTablesToReplicated`: Convert non-replicated tables to [replicated](../concepts/replication.md#replicated-tables) ones.

            You can get the cluster ID with the [list of clusters in the folder](cluster-list.md#list-clusters).

        1. Run this request:

            ```bash
            grpcurl \
              -format json \
              -import-path ~/cloudapi/ \
              -import-path ~/cloudapi/third_party/googleapis/ \
              -proto ~/cloudapi/yandex/cloud/mdb/clickhouse/v1/cluster_service.proto \
              -rpc-header "Authorization: Bearer $IAM_TOKEN" \
              -d @ \
              mdb.api.cloud.yandex.net:443 \
              yandex.cloud.mdb.clickhouse.v1.ClusterService.addZookeeper \
              < body.json
            ```

    1. Check the [server response](../api-ref/grpc/Cluster/addZookeeper.md#yandex.cloud.operation.Operation) to make sure your request was successful.

{% endlist %}

_ClickHouse® is a registered trademark of [ClickHouse, Inc](https://clickhouse.com)._