Managing shards
You can enable sharding for a cluster as well as add and configure individual shards.
Warning
If a cluster uses hybrid storage at the Preview stage, only shards with a single host can be added to this cluster. This restriction is removed at the General Availability stage.
Enabling sharding
Managed Service for ClickHouse clusters are created with one shard. To start sharding data, add one or more shards and create a distributed table.
Adding 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.
- Go to the folder page and select Managed Service for ClickHouse.
- Click on the name of the cluster you need and go to the Hosts tab.
- Click Add shard.
- Enter a name for the shard and add the desired number of hosts.
- Click Create shard.
To add a shard to the cluster, use the addShard method.
Listing shards in a cluster
-
Go to the folder page and select Managed Service for ClickHouse.
-
Click the name of a cluster and open the Shards tab.
To list the shards in a cluster, use the listShards method.
Changing a shard
You can change the shard weight as well as host class and storage size.
- Go to the folder page and select Managed Service for ClickHouse.
- Click the name of a cluster and open the Shards tab.
- Click and select Change.
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 change a shard in the cluster:
-
View a description of the CLI's shard change command:
yc managed-clickhouse shards update --help
-
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.
Deleting a shard
You can delete a shard from a ClickHouse cluster provided that:
- It's not the only shard.
- It's not the only shard in a group of shards.
When you delete a shard, all tables and data that are saved on that shard are deleted.
-
Go to the folder page and select Managed Service for ClickHouse.
-
Click on the name of a cluster and open the Shards tab.
-
Click in the line of the desired host and select Delete.
Use the deleteShard method to delete a shard.