Creating a ClickHouse cluster
A ClickHouse cluster consists of one or more database hosts you can configure replication between.
Note
The number of hosts you can create together with a ClickHouse cluster depends on the selected host class.
If there are two or more hosts in a cluster, another three ZooKeeper hosts will be added to it automatically. These hosts are taken into account when calculating the consumed cloud resource quota.
How to create a ClickHouse cluster
-
In the management console
, select the folder where you want to create a DB cluster.- Select a Managed Service for ClickHouse service.
-
Click Create cluster.
-
Enter a name for the cluster in the Cluster name field. It must be unique within the folder.
-
Under Resources:
-
Select the platform, VM type, and host class that defines the technical specifications of the VMs where the DB hosts will be deployed. All available options are listed under Host classes. When you change the host class for the cluster, the characteristics of all existing instances change, too.
-
Select the size of disk to be used for data and backups. For more information about how backups take up storage space, see Backups in Managed Service for ClickHouse.
-
-
Under Hosts:
- To create additional DB hosts, click Add host. Once the second host is added, the Configure ZooKeeper button will appear. Change the ZooKeeper settings in ZooKeeper host class, ZooKeeper storage size, and ZooKeeper hosts, if required.
- Set the parameters of DB hosts being created alongside the cluster. To change the added host, hover over the host line and click
.
-
Under DBMS settings:
-
If you want to manage cluster users via SQL, select Enabled from the drop-down list in the User management via SQL field and enter the
admin
user password. This disables user management through other interfaces.Otherwise, select Disabled.
-
If you want to manage databases via SQL, select Enabled from the drop-down list in the Managing databases via SQL field. This disables database management through other interfaces. The field is inactive if user management via SQL is disabled.
Otherwise, select Disabled.
Alert
You can't disable activated settings to manage users and databases via SQL. You can enable these as required later when editing cluster settings.
-
Username and password.
Note
The username may contain Latin letters, numbers, hyphens, and underscores, but must begin with a letter or an underscore.
The password must be between 8 and 128 characters.
-
DB name. Database name may contain Latin letters, numbers, and underscores. The name may be up to 63 characters long. You cannot create a database named
default
. -
Configure the DBMS settings, if required.
-
-
Under Hosts, select the parameters of database hosts created together with the cluster. To change the settings of a host, click the
icon in the line with its number:- Availability zone: Select an availability zone.
- Subnet: Specify a subnet in the selected availability zone.
- Public access: Allow access to the host from the internet.
To add hosts to the cluster, click Add host.
-
Configure cluster service settings, if required:
-
Backup start time (UTC): UTC time in 24-hour format to start backing up the cluster. If the time is not set, the backup will start at 22:00 UTC.
-
Deletion protection: Manages cluster protection from accidental deletion by a user.
Cluster deletion protection will not prevent a manual connection to delete the contents of a database.
-
-
Click Create cluster.
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 create a cluster:
-
Check whether the folder has any subnets for the cluster hosts:
ncp vpc subnet list
-
View a description of the create cluster CLI command:
ncp managed-clickhouse cluster create --help
-
Specify cluster parameters in the create command (the list of supported parameters in the example is not exhaustive):
ncp managed-clickhouse cluster create \ --name <cluster name> \ --network-name <network name> \ --host type=<clickhouse or zookeeper>,` `zone-id=<availability zone>,` `subnet-id=<subnet ID>,` `assign-public-ip=<public access to host: true or false> \ --clickhouse-resource-preset <host class> \ --clickhouse-disk-type <disk type> \ --clickhouse-disk-size <storage size in GB> \ --user name=<username>,password=<user password> \ --database name=<database name> \ --deletion-protection=<protection from cluster deletion: true or false>
You need to specify
subnet-id
if the selected availability zone has two or more subnets.Cluster deletion protection will not prevent a manual connection to delete the contents of a database.
You can manager cluster users and databases via SQL.
Alert
You can't disable activated settings to manage users and databases via SQL. You can enable these as required later when editing cluster settings.
-
To enable SQL user management:
- Set
--enable-sql-user-management
totrue
. - Set a password for the
admin
user in the--admin-password
parameter.
ncp managed-clickhouse cluster create \ ... --enable-sql-user-management true \ --admin-password "<admin password>"
- Set
-
To enable SQL database management:
- Set
--enable-sql-user-management
and--enable-sql-database-management
totrue
; - Set a password for the
admin
user in the--admin-password
parameter.
ncp managed-clickhouse cluster create \ ... --enable-sql-user-management true \ --enable-sql-database-management true \ --admin-password "<admin account password>"
- Set
-
Note
When creating a cluster, the anytime
maintenance mode is set by default. You can set a specific maintenance period when updating the cluster settings.
Examples
Creating a single-host cluster
To create a cluster with a single host, provide a single --host
parameter.
Create a Managed Service for ClickHouse cluster with test characteristics:
- Named
mych
. - Network
default
. - With a single ClickHouse host of the
s3-c2-m8
class in theb0rcctk2rvtr8efcch64
subnet and theeu-north1-c
availability zone. - With 20 GB of storage.
- With one user,
user1
, with theuser1user1
password. - With one database,
db1
. - Protection against accidental cluster deletion.
Run the following command:
ncp managed-clickhouse cluster create \
--name mych \
--network-name default \
--clickhouse-resource-preset s3-c2-m8 \
--host type=clickhouse,zone-id=eu-north1-c,subnet-id=b0cl69g98qumiqmtg12a \
--clickhouse-disk-size 20 \
--user name=user1,password=user1user1 \
--database name=db1 \
--deletion-protection=true