如何正确编辑 clickhouse-server config.xml 文件?

How does one properly edit the clickhouse-server config.xml file?

ClickHouse quick start guide 表示在修改 config.xml 时:"It's not really handy to directly edit config.xml file considering package updates. Recommended way is to override the config elements in files of config.d directory."

我是 ClickHouse(以及守护进程配置)的新手。那句话是什么意思? config.d 目录在哪里?哪些文件应该放入该目录,内容应该是什么?

表示建议在config.d目录下创建一个单独的配置文件(与当前配置文件位于同一路径,默认为/etc/clickhouse-server/config.d/)。

"considering package updates" 意味着如果你更新你的 clickhouse-server 包,它可能会重写 /etc/clickhouse-server/config.xml,所以你不应该在那里做任何改变 - 它'将被重写和丢失。

是这么说的in the documentation:

The main server config file is 'config.xml'. It resides in the /etc/clickhouse-server/ directory. Certain settings can be overridden in the *.xml and *.conf files from the 'conf.d' and 'config.d' directories next to the config.

因此,您应该创建一个 /etc/clickhouse-server/config.d/ 目录;然后,在那里创建一个配置文件(如 config.xmlmy_config.conf 或其他)。您应该在那里进行所有自定义设置,这些设置与原始 /etc/clickhouse-server/config.xml 文件不同。

例如,您可以将 HTTP 端口从 8123 更改为 8663:

# cat /etc/clickhouse-server/config.d/test.xml
<?xml version="1.0"?>
<yandex>
    <http_port>8663</http_port>
</yandex>

请确保重新启动守护程序(如果您使用的是 Ubuntu,则为 sudo service clickhouse-server restart)以应用配置更改。