Changing ClickHouse® settings at the server level
You can specify ClickHouse® settings at the server level
-
Using the Yandex Cloud interfaces. This way, you can specify only the ClickHouse® settings available in Yandex Cloud.
-
Using SQL queries. This way, you can specify settings for MergeTree tables. You can:
- Specify the settings when creating a table.
- Specify the settings of an existing table.
- Restore the default settings of an existing table.
Specifying ClickHouse® settings using the Yandex Cloud interfaces
Changing some server settings will restart ClickHouse® servers on the cluster hosts.
Note
You cannot directly update the Max server memory usage
To configure ClickHouse®:
- In the management console
, go to the folder page and select Managed Service for ClickHouse. - Select the cluster and click Edit in the top panel.
- Under DBMS settings, click Settings.
- Specify the ClickHouse® settings.
- Click Save changes.
If you do not 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 configure ClickHouse®:
-
View the full list of settings specified for the cluster:
yc managed-clickhouse cluster get <cluster_name_or_ID> --full
-
View a description of the update cluster configuration CLI command:
yc managed-clickhouse cluster update-config --help
-
Set the required parameter values:
yc managed-clickhouse cluster update-config <cluster_name_or_ID> \ --set <parameter_1_name>=<value_1>,...
To configure ClickHouse®:
-
Open the current Terraform configuration file with an infrastructure plan.
For more information about creating this file, see Creating clusters.
-
In the Managed Service for ClickHouse® cluster description, under
clickhouse.config
, change the values of the following parameters:resource "yandex_mdb_clickhouse_cluster" "<cluster_name>" { ... clickhouse { ... config { # General DBMS settings ... merge_tree { # MergeTree engine settings ... } kafka { # General settings to get data from Apache Kafka ... } kafka_topic { # Settings for an individual Apache Kafka topic ... } rabbit_mq { # Settings for getting data from RabbitMQ username = "<username>" password = "<password>" } compression { # Data compression settings method = "<compression_method>" min_part_size = <data_part_size> min_part_size_ratio = <size_ratio> } graphite_rollup { # GraphiteMergeTree engine settings for thinning, aggregating, and averaging (rollup) Graphite data. ... } } ... } ... }
Where:
method
: Compression method,LZ4
orZSTD
.min_part_size
: Minimum size of a table data part, bytes.min_part_size_ratio
: Smallest table data part to the full table size ratio.
-
Make sure the settings are correct.
-
Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.
-
Run the command:
terraform validate
If there are errors in the configuration files, Terraform will point to them.
-
-
Confirm updating the resources.
-
Run the command to view planned changes:
terraform plan
If the resource configuration descriptions are correct, the terminal will display a list of the resources to modify and their parameters. This is a test step. No resources are updated.
-
If you are happy with the planned changes, apply them:
-
Run the command:
terraform apply
-
Confirm the update of resources.
-
Wait for the operation to complete.
-
-
For more information, see the Terraform provider documentation
Time limits
A Terraform provider sets the timeout for Managed Service for ClickHouse® cluster operations:
- Creating a cluster, including by restoring one from a backup: 60 minutes.
- Editing a cluster: 90 minutes.
- Deleting a cluster: 30 minutes.
Operations exceeding the set timeout are interrupted.
How do I change these limits?
Add the timeouts
block to the cluster description, for example:
resource "yandex_mdb_clickhouse_cluster" "<cluster_name>" {
...
timeouts {
create = "1h30m" # 1 hour 30 minutes
update = "2h" # 2 hours
delete = "30m" # 30 minutes
}
}
To configure ClickHouse®, use the update REST API method for the Cluster resource or the ClusterService/Update gRPC API call and provide the following in the request:
- Cluster ID in the
clusterId
parameter. To find out the cluster ID, get a list of clusters in the folder. - Required values in the
configSpec.clickhouse.config
parameter. - List of settings to update, in the
updateMask
parameter.
Warning
This API method overrides all parameters of the object being modified that were not explicitly passed in the request to the default values. To avoid this, list the settings you want to change in the updateMask
parameter (one line separated by commas).
Checking MergeTree table settings
-
Connect to the database in the cluster.
-
To view all table-level settings, run the following query:
SHOW CREATE TABLE <table_name>;
Warning
The
SHOW CREATE TABLE
output only includes settings overridden by the user. If a user-defined value matches the default value, this setting is also displayed in the output.
Specifying settings for MergeTree tables using SQL queries
Changing settings when creating a MergeTree table
-
Connect to the database in the cluster.
-
Create a table. To specify its settings, list them in the
SETTINGS
parameter, separated by commas:CREATE TABLE <table_name> ( <table_column_description> ) ENGINE = MergeTree PRIMARY KEY (<column_or_group_of_columns>) SETTINGS <setting_name> = <setting_value>, <setting_name> = <setting_value>;
Example query for the merge_with_ttl_timeout
and merge_with_recompression_ttl_timeout settings:CREATE TABLE <table_name> ( user_id UInt32, message String, ) ENGINE = MergeTree PRIMARY KEY (user_id) SETTINGS merge_with_ttl_timeout = 15000, merge_with_recompression_ttl_timeout = 15000;
For more information about creating MergeTree tables, see the ClickHouse® documentation
Changing the settings of an existing MergeTree table
-
Connect to the database in the cluster.
-
To change the settings for an existing table, run the following query:
ALTER TABLE <table_name> MODIFY SETTING <setting_name> = <new_setting_value>;
You can change multiple settings in a single query. To do this, list the
<setting_name> = <new_setting_value>
pairs separated by commas.
Restoring the default settings of a MergeTree table
-
Connect to the database in the cluster.
-
To restore a default setting value of an existing table, run the following query:
ALTER TABLE <table_name> RESET SETTING <setting_name>;
You can restore multiple default settings in a single query. To do this, list the names of the settings separated by commas.
ClickHouse® is a registered trademark of ClickHouse, Inc