Managing shards

You can enable sharding for a cluster as well as add and configure individual shards.

Make sure that your shards consist of at least 3 hosts to ensure higher availability. We don't recommend sharding small tables: query processing is faster with a standard cluster.

Enable sharding

Managed Service for ClickHouse clusters are created in a configuration with one shard. To start sharding data, follow the guidelines in Sharding ClickHouse tables.

Change a shard

You can change the shard weight as well as host class and storage size.

  1. Go to the folder page and select Managed Service for ClickHouse.
  2. Click the name of a cluster and open the Shards tab.
  3. Click horizontal-ellipsis and select Change.

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 parameter.

To change a shard in the cluster:

  1. View a description of the CLI's shard change command:

    yc managed-clickhouse shards update --help
    
  2. Start an operation, such as changing the shard weight:

    yc managed-clickhouse shards update --cluster-name clickhouse12 \
                                  --name shard1 \
                                  --weight 80
    

When the operation is complete, the CLI displays information about the changed shard:

name: shard1
cluster_id: c9fmo2rf013t4q0ab8m1
config:
  clickhouse:
    config:
      effective_config:
        log_level: INFORMATION
  ...

  weight: "80"

To change the shard settings, use the updateShard method.

List shards in a cluster

  1. Go to the folder page and select Managed Service for ClickHouse.

  2. Click the name of a cluster and open the Shards tab.

To list the shards in a cluster, use the listShards method.

Add a shard

The number of shards in Managed Service for ClickHouse 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 ClickHouse block.

  1. Go to the folder page and select Managed Service for ClickHouse.
  2. Click on the name of the cluster you need and go to the Hosts tab.
  3. Click Add shard.
  4. Enter a name for the shard and add the desired number of hosts.
  5. Click Create shard.

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

Delete a shard

You can delete a shard from a ClickHouse cluster provided that it's not the only shard in it.

  1. Go to the folder page and select Managed Service for ClickHouse.

  2. Click on the name of a cluster and open the Shards tab.

  3. Click image in the line of the desired host and select Delete.

Use the deleteHosts method to delete a host.