Configuring Settings
Every cluster has a number of settings. The Settings view has a Server Settings tab that lets you view, add, edit, or delete the server’s current settings, or restore the settings to their defaults. There is also an Environment Variables tab that lets you work with environment variables. In addition to configuring settings and environment variables themselves, there are also a couple of global settings that control how the cluster starts when you apply your changes.
WARNING: FOR ADVANCED USERS ONLY. Many ClickHouse settings can be configured through the Altinity Cloud Manager UI. For example, the Accounts Page lets you work with user accounts in a modern UI instead of editing XML files by hand. We strongly recommend using the UI wherever possible; it protects you from syntax errors and other common mistakes.
ANOTHER WARNING: CHANGING YOUR SERVER’S CONFIGURATION MAY RESTART CLICKHOUSE. It’s not always true, but changes to server settings (config.xml
and config.d
) usually require a restart, while changes to user settings (user.xml
and users.d
) usually don’t. The Altinity Knowledge Base has an article on server configuration settings that do and don't require a restart. If you’re not sure, check that article before making changes.
Finally, an important point before we go on: By default, the environment that contains your cluster is configured so that any changes to settings and environment variables are automatically published to your cluster. However, if automatic publishing is turned off for your cluster, you’ll need to use the Publish Configuration feature to make your changes permanent. See Publishing a cluster's configuration for more information.
Working with server settings
The Settings View looks like this:
Figure 1 - The Server Settings tab in the Settings View
Settings with a lock icon next to their names can’t be changed through the Settings View. For any other setting, click the vertical dots icon next to the setting name, then click Edit or Delete.
Adding a setting
Clicking the button at the top of the panel lets you add a setting. There are three types of settings:
- Attribute - A value in the
config.xml
file config.d
file - A value in a file stored in theconfig.d
directoryusers.d
file - A value in a file stored in theusers.d
directory
Setting an attribute in the config.xml
file
The most straightforward kind of setting is an attribute:
Figure 2 - The dialog for setting an attribute
The Value field and Value From fields are mutually exclusive. Value defines the value of the attribute. Value From, on the other hand, refers to a key inside a Kubernetes secret. The format for Value From is secret-name/secret-key
. For example, if the underlying environment contains a Kubernetes secret named clickhouse-data
and the secret contains a key named clickhouse_data_s3_access_key
, clickhouse-data/clickhouse_data_s3_access_key
will use the value of that key as the value of the attribute.
The attribute is added to the config.xml
file. The Name is the name of the XML element that contains the value. Note that if the XML element is contained in other elements, you need to specify the element’s entire path below the root <clickhouse>
element. In the example above, the name logger/level
stores the value in config.xml
like this:
<clickhouse>
<logger>
<level>
debug
</level>
</logger>
</clickhouse>
Setting a value in a file in the config.d
directory
The ACM UI makes it easy to create a file with configuration data in the config.d
directory. The values defined in that file become part of the ClickHouse system configuration. To set a value, enter a filename and its contents:
Figure 3 - Setting a value in the config.d
directory
This example writes the XML in the text box to the file config.d/query_log.xml
. When applied to the ClickHouse cluster, logging settings for the query_log
table in the system
database are updated. Specifically, the retention period for the table is now 90 days (the default is 30).
The value of the Filename field must include an extension. If the contents of the text box are XML, it must be well-formed, and the root element must be either <yandex>
or <clickhouse>
. If not, you’ll see an error message when you try to save your changes:
Figure 4 - An error message for incorrect XML
(The XML starts with a <clickhouse>
tag and ends with a </yandex>
tag.)
Setting a value in a file in the users.d
directory
Similar to the config.d
directory, the ACM UI makes it easy to create a file with configuration data in the users.d
directory. The values defined in that file become part of the ClickHouse system configuration. To set a value, enter a filename and its contents:
Figure 5 - Setting a value in the users.d
directory
This example contains an XML document that defines new users. If you wanted to define multiple users for your ClickHouse cluster, you could go through the ACM UI and create each one individually. However, it might be simpler and faster to define all the users in XML and use this dialog to create the file users.d/myusers.xml
. When the new setting is applied to the ClickHouse cluster, there will be new users based on the data in the XML file.
The value of the Filename field must include an extension. As with config.d
values, if the contents are XML, it must be well-formed, and the root element must be either <yandex>
or <clickhouse>
.
Editing a setting
When you click the vertical dots icon next to a setting name, you can click the Edit menu to, well, edit that setting. The dialogs to edit a setting are exactly the same as the dialogs in Figures 2, 3, and 4 above.
Deleting a setting
Clicking the Delete button in the menu next to a setting name brings up the Delete Setting confirmation dialog:
Figure 6 - Delete Setting configuration dialog
Click OK to delete the setting.
Example: Configuring protobuf schema
As an example, we’ll look at how to use protobuf in your ClickHouse cluster. You need to add two settings:
- The attribute
format_schema_path
- The file
events.proto
inusers.d
To get started, click the button, then create the format_schema_path
attribute and set its value to /etc/clickhouse-server/users.d/
:
Figure 7 - Adding the format_schema_path
attribute
Click OK to create the attribute. Next, click the button again and create a file in users.d
named events.proto
with the contents syntax = "proto3"
:
Figure 8 - Defining the events.proto
file
Click OK to create the setting.
Working with environment variables
To work with environment variables, click the Environment Variables tab in the Settings View:
Figure 9 - The Environment Variables tab in the Settings View
We’ll look at the three environment variables listed in Figure 6 as an example.AWS_ACCESS_KEY_ID
and AWS_SECRET_ACCESS_KEY
define the credentials used to access resources. S3_OBJECT_DISK_PATH
is a simple string.
Adding an environment variable
Clicking the button at the top of the view opens the Environment Variable Details dialog:
Figure 10 - Using Value in the Environment Variable Details dialog
Field details
The fields in the dialog are:
Name
The name of the environment variable. The name can contain only letters [a-zA-Z]
, numbers [0-9]
, underscores [_]
, dots [.]
, and dashes [-]
, it can’t start with a digit, and it can’t be more than 50 characters long.
Value
The value of the variable. This field is mutually exclusive with the Value From field.
Value From
The name of a key inside a Kubernetes secret whose value should be used as the value for this environment variable. This field is mutually exclusive with the Value field.
In Figure 25 above, we’re using the Value field to define the string object_disks/demo/github
as the value of the S3_OBJECT_DISK_PATH
variable. Using the Value From field is slightly more complicated:
Figure 11 - Using Value From in the Environment Variable Details dialog
The format for Value From is secret-name/secret-key
. In the example above, the value clickhouse-data/clickhouse_data_s3_access_key
refers to the first key in this secret:
apiVersion: v1
kind: Secret
metadata:
name: clickhouse-data
type: Opaque
data:
clickhouse_data_s3_access_key: abc...xyz
clickhouse_data_s3_secret_key: zyx...cba
Continuing our example, when using S3 for data storage in ClickHouse, the configuration data must include the<access_key_id>
and <secret_access_key>
elements. With the contents of the keys inside the Kubernetes secret defined as environment variables, they can be used in ClickHouse configuration files via the from_env
attribute:
<access_key_id from_env="AWS_ACCESS_KEY_ID"/>
<secret_access_key from_env="AWS_SECRET_ACCESS_KEY"/>
With this technique, anyone with access to the cluster can use the values from the Kubernetes secret, but no one can get the actual values.
Editing an environment variable
To edit an environment variable, click the vertical dots icon next to the variable name and select Edit from the menu. That takes you to the Environment Variables Details dialog seen in Figures 26 and 27 above.
Deleting an environment variable
Clicking the vertical dots icon next to the variable name and selecting Delete takes you to the Delete Environment Setting dialog:
Figure 12 - The Delete Environment Setting dialog
Setting the Startup Mode
The Startup Mode menu lets you set how the cluster responds to changes in its settings:
Figure 13 - The startup modes for a ClickHouse cluster
The startup modes affect how Altinity Cloud Manager starts your ClickHouse cluster when you apply your new settings. The two modes are:
- Direct mode - If something goes wrong during startup, the ACM will retry the startup several times before giving up.
- Troubleshooting mode - If something goes wrong during startup, the ACM will not try to restart it if it fails. This is useful for debugging any problems with your cluster’s updated configuration.
Setting the Startup Time
Depending on the number of tables and the amount of data in your ClickHouse cluster, it may take longer than normal to start. That means it’s possible that the Kubernetes cluster hosting your ClickHouse cluster will delete and restart the pods needed to run ClickHouse before ClickHouse can start. For that reason, you can define a startup time, which is the number of seconds the Kubernetes cluster should wait for your ClickHouse cluster to start.
Figure 14 - The startup time parameter
If your ClickHouse cluster fails to start, you can check the ClickHouse Logs tab in your cluster’s Logs view for details. See the Cluster logs documentation for more information.
Click the button to set the startup time parameter. Note: this button only, uh, applies to the startup time parameter. It does not apply any changes you’ve made to settings or environment variables.
Resetting everything
The button restores all the standard settings to their default values. Any additional settings you have configured are deleted.