ClickHouse-Server 的配置文件在/etc/clickhouse-server
路径下,配置文件主要有三个:config.xml、metrika.xml、users.xml,其中 config.xml 为 ClickHouse-Server 的主配置文件。
在 config.xml 配置文件同级的 conf.d 和 config.d 文件夹下,用户可以新建*.xml
文件来覆盖 config.xml 文件中的配置(这里不建议用户手动更改,建议在控制台提供的配置下发功能中统一下发配置)。
例如,在 config.xml 文件同级的目录下新建 config.d 目录:
<yandex>
<tcp_port>9900</tcp_port>
</yandex>
重启 clickhouse-server,可以发现监听的 TCP 端口变成了9000。<yandex>
<metric_log>
<database>system</database>
<table>metric_log</table>
<flush_interval_milliseconds>7500</flush_interval_milliseconds>
<collect_interval_milliseconds>1000</collect_interval_milliseconds>
</metric_log>
</yandex>
重启 clickhouse-server,clickhouse-client 执行命令SELECT * FROM system.metric_log LIMIT 1 FORMAT Vertical;
,自动创建 system.metric_log 表。ClickHouse 配置提供了“替换”的功能,可以使用incl属性将指定文件中的配置替换到 config.xml 配置文件中来,这样使得主配置文件不至于过于冗余,方便维护。在默认的 config.xml 配置中,我们可以看到<remote_servers>
、<macros>
、<zookeeper>
这三个标签都是有 incl 属性的,可以将 metrika.xml 文件中对应的<clickhouse_remote_servers>
、<macros>
、<zookeeper-servers>
配置加载到 config.xml 文件中。替换文件的路径默认为/etc/metrika.xml
,可通过<include_from>
配置来修改。
注意:
如果 incl 属性中替换的配置是不存在的,会在日志中记录下来。如果您不想让日志记录这些不存在的替换配置,使用
optional="true"
属性即可。
在 config.xml 配置中,users_config 表示用户相关的配置文件的路径,默认设置为 users.xml。users.xml 中可以配置用户的密码、权限、profile、quota 等信息,针对不同的用户可以有不同的配置。
在 user.xml 统计目录下,可以新建 users.d 目录,在该目录下添加用户相关的配置,可以降低 users.xml 文件的冗余,易于维护。例如:/etc/clickhouse-server/users.d/testUser.xml
<yandex>
<users>
<testUser>
<profile>default</profile>
<networks>
<ip>::/0</ip>
</networks>
<password>12345</password>
<quota>default</quota>
</testUser>
</users>
</yandex>
具体的 Server 参数配置和 Settings 配置可参考官网 Server 参数配置 和 Settings 配置。
本页内容是否解决了您的问题?