Managing shards in a ClickHouse cluster
You can enable sharding for a cluster as well as add and configure individual shards.
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 in the management console and find Managed Service for ClickHouse.
- In the management console
, go to the folder page and select Managed Service for ClickHouse. - Click the cluster name and go to the Shards tab.
- Click Add shard.
- Specify the shard parameters:
- Name and weight
- To copy the schema from a random replica of one of the shards to the hosts of the new shard, select the Copy the data schema option.
- Required number of hosts
- Click Create shard.
If you don't have the Nebius AI 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 shard to a cluster, run the command below (the parameter list in the example is not exhaustive):
ncp managed-clickhouse shards add <new shard name> \
--cluster-name=<cluster name> \
--host zone-id=<availability zone>,`
`subnet-name=<subnet name>
Where:
-
<new shard name>
: Must be unique in a cluster.May contain Latin letters, numbers, hyphens, and underscores. The maximum length is 63 characters.
-
--cluster-name
is the name of a cluster.The cluster name can be requested with a list of clusters in the folder.
-
--host
: Host parameters:zone-id
: Availability zone.subnet-name
: Name of the subnet.
Warning
Use the copy data schema option only if the schema is the same on all cluster shards.
Listing shards in a cluster
- In the management console
, go to the folder page and select Managed Service for ClickHouse. - Click the name of the cluster and select the Shards tab.
If you don't have the Nebius AI 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 shards in a cluster, run the following command:
ncp managed-clickhouse shards list --cluster-name=<cluster name>
The cluster name can be requested with a list of clusters in the folder.
Changing a shard
You can change the shard weight as well as host class and storage size.
- In the management console
, go to the folder page and select Managed Service for ClickHouse. - Click the name of the cluster and select the Shards tab.
- Click
If you don't have the Nebius AI 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:
ncp managed-clickhouse shards update --help
-
Start an operation, such as changing the shard weight:
ncp managed-clickhouse shards update <shard name> \ --cluster-name=<cluster name> \ --weight=<shard weight>
Where:
-
<shard name>
: Can be requested with a list of shards in a cluster. -
--cluster-name
is the name of a cluster.The cluster name can be requested with a list of clusters in the folder.
-
--weight
: Shard weight. The minimum value is0
.
When the operation is complete, the CLI displays information about the changed shard.
-
Deleting a shard
You can delete a shard from a ClickHouse cluster in case:
- It is not the only shard.
- It is not the only shard in a shard group.
When you delete a shard, all tables and data that are saved on that shard are deleted.
- In the management console
, go to the folder page and select Managed Service for ClickHouse. - Click the cluster name and open the Shards tab.
- Click
If you don't have the Nebius AI 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 delete a shard from the cluster, run:
ncp managed-clickhouse shards delete <shard name> \
--cluster-name=<cluster name>
You can request a shard name with a list of cluster shards and a cluster name with a list of clusters in a folder.