clickhouse配置项config.xml详解——服务器配置参数

调研学习clickhouse,上一章介绍了clickhouse的配置项users.xml,这一章介绍另一大项config.xml

从clickhouse的官网看,clickhouse的配置参数主要分了两大方面,一个是config.xml中的服务器配置参数(Server Settings),另一个是常规配置参数(setttings)

这里先介绍服务器配置参数(Server Settings)

 

目录

服务器配置参数介绍

配置文件

覆写

替代

用户设置

举例

注意

服务器设置

builtin_dictionaries_reload_interval

compression

custom_settings_prefixes

core_dump

default_database

default_profile

dictionaries_config

dictionaries_lazy_load

format_schema_path

graphite

graphite_rollup

http_port/https_port

http_server_default_response

include_from

interserver_http_port

interserver_http_host

interserver_http_credentials

keep_alive_timeout

listen_host

logger

send_crash_reports

macros

mark_cache_size

max_server_memory_usage

max_server_memory_usage_to_ram_ratio

max_concurrent_queries

max_concurrent_queries_for_all_users

max_connections

max_open_files

max_table_size_to_drop

max_thread_pool_size

merge_tree

replicated_merge_tree

openSSL

part_log

path

prometheus

query_log

query_thread_log

text_log

trace_log

query_masking_rules

remote_servers

timezone

tcp_port

tcp_port_secure

mysql_port

tmp_path

tmp_policy

uncompressed_cache_size

user_files_path

users_config

zookeeper

use_minimalistic_part_header_in_zookeeper

disable_internal_dns_cache

dns_cache_update_period

access_control_path

user_directories


 

服务器配置参数介绍

本节包含无法在会话或查询级别更改的服务器设置的说明。

这些设置默认存储在/etc/clickhouse-server/config.xml中。

在研究设置之前,先请阅读“配置文件”部分,并注意使用替代(incloptional属性)。

 

配置文件

ClickHouse支持多文件配置管理。主服务器配置文件是/etc/clickhouse-server/config.xml。其他文件必须在/etc/clickhouse-server/config.d目录中。

所有配置文件均应为XML格式。而且,它们通常应具有相同的根元素<yandex>

覆写

主配置文件中指定的某些设置可以在其他配置文件中覆盖:

  • replaceremove属性,用于这些配置文件的元素指定属性。
  • 如果未指定,则它将递归合并元素的内容,替换重复子元素的值。
  • 如果replace指定,则将整个元素替换为指定的元素。
  • 如果remove指定,则删除该元素。

替代

该配置还可以定义“substitutions”(替代)。

如果元素具有incl属性,将使用文件中属性对应的值。默认情况下,替代文件的文件目录是/etc/metrika.xml,这个可以在服务器设置的include_from属性中被更改。

在此文件中,替换值被保存在/yandex/substitution_name元素中。如果incl中指定的替代不存在,则将其记录在日志中。为防止ClickHouse记录缺少的替代项,请指定:optional= true属性。(例如,宏设置)。

可以从ZooKeeper中进行替换,指定属性from_zk =“ /path/to/node”。元素值将替换为ZooKeeper中/path/to/node上节点的内容。还可以将整个XML子树放在ZooKeeper节点上,并将其完全插入到source元素中。

用户设置

 config.xml文件可以使用users设置,为profiles和quotas指定单独的配置。此配置的相对路径在'users_config'元素中设置。默认情况下,它是users.xml。如果省略users_config,则直接在config.xml中指定。

用户配置可以指定在config.xml或者指定为保存在config.d/中的config.xml类似的单独文件。

用户设置的目录名称被定义users_config中(不带.xml后缀)。

默认使用目录users.dusers_config默认使用users.xml

举例

可以为每个用户使用单独的配置文件,如下所示:

$ cat /etc/clickhouse-server/users.d/alice.xml
<yandex>
    <users>
      <alice>
          <profile>analytics</profile>
            <networks>
                  <ip>::/0</ip>
            </networks>
          <password_sha256_hex>...</password_sha256_hex>
          <quota>analytics</quota>
      </alice>
    </users>
</yandex>

注意

对于每个配置文件,服务器启动时会生成file-preprocessed.xml 。这些文件包含所有已完成的替换和替代,仅供参考。

如果在配置文件中使用了ZooKeeper替换项,但是ZooKeeper在服务器启动时不可用,则服务器将从预处理文件中加载配置。

 

 

服务器设置

builtin_dictionaries_reload_interval

重新加载内置词典的时间间隔(以秒为单位),默认3600。可以在不重新启动服务器的情况下“即时”修改词典。

<builtin_dictionaries_reload_interval>3600</builtin_dictionaries_reload_interval>

compression

官方说如果对clickhouse不是很熟悉,不要进行改动。

MergeTree引擎表的数据压缩设置。配置模板如:

<compression>
    <case>
      <min_part_size>...</min_part_size>
      <min_part_size_ratio>...</min_part_size_ratio>
      <method>...</method>
    </case>
    ...
</compression>

<case>部分说明:

  • min_part_size –数据部分的最小大小。
  • min_part_size_ratio –数据部分大小与表大小的比率。
  • method–压缩方法。可接受的值:lz4zstd

可以配置多个<case>部分。

满足条件时的操作:

  • 如果数据部分与条件集匹配,则ClickHouse使用指定的压缩方法。
  • 如果数据部分匹配多个条件集,则ClickHouse将使用第一个匹配的条件集。

举例:

<compression incl="clickhouse_compression">
    <case>
        <min_part_size>10000000000</min_part_size>
        <min_part_size_ratio>0.01</min_part_size_ratio>
        <method>zstd</method>
    </case>
</compression>

custom_settings_prefixes

自定义设置的前缀列表。(在users.xml中有提及)前缀必须用逗号分隔。

(没有其他介绍,我感觉很像自定义变量、宏定义之类的,不能长久存在,只在当前连接有效,退出再连就没有了)

举例:

<custom_settings_prefixes>custom_</custom_settings_prefixes>
SET custom_a = 123;
SELECT getSetting('custom_a');    

core_dump

核心转储文件大小的软限制,默认情况下为1 GB。

<core_dump>
    <size_limit>1073741824</size_limit>
</core_dump> 

(硬限制是通过系统工具配置的)

default_database

默认数据库。

要获取数据库列表,请使用SHOW DATABASES查询。

<default_database>default</default_database>

default_profile

默认设置配置文件。

设置配置文件位于参数中指定的文件中user_config

<default_profile>default</default_profile>

dictionaries_config

外部词典的配置文件的路径。

路径:

  • 指定绝对路径或相对于服务器配置文件的路径。
  • 该路径可以包含通配符*和?

另请参阅“外部词典”。

<dictionaries_config>*_dictionary.xml</dictionaries_config>

dictionaries_lazy_load

延迟加载字典。

如果为true,则每个字典都在首次使用时创建。如果字典创建失败,则正在使用字典的函数将引发异常。

如果为false,则在服务器启动时将创建所有词典,如果有错误,则服务器将关闭。

默认值为true

<dictionaries_lazy_load>true</dictionaries_lazy_load>

format_schema_path

包含输入数据方案(例如CapnProto格式的方案)的目录路径。

  <!-- Directory containing schema files for various input formats. -->
  <format_schema_path>format_schemas/</format_schema_path>

graphite

发送数据到Graphite。它是一款企业级监控。 

设定:

<graphite>
    <host>localhost</host>  -- Graphite服务器
    <port>42000</port>   -- Graphite服务器上的端口
    <timeout>0.1</timeout> -- 发送超时时间,以秒为单位
    <interval>60</interval>  -- 发送间隔,以秒为单位
    <root_path>one_min</root_path> -- 密钥的前缀
    <metrics>true</metrics>  -- 从system.metrics表发送数据
    <events>true</events>  -- 从system.events表发送在该时间段内累积的增量数据
    <events_cumulative>false</events_cumulative> -- 从system.events表发送累积数据
    <asynchronous_metrics>true</asynchronous_metrics> -- 从system.asynchronous_metrics表发送数据
</graphite>

可以配置多个<graphite>子句。例如,您可以使用它以不同的时间间隔发送不同的数据。

graphite_rollup

数据汇总设置

<default>
        <function>max</function>
        <retention>
            <age>0</age>
            <precision>60</precision>
        </retention>
        <retention>
            <age>3600</age>
            <precision>300&
  • 11
    点赞
  • 45
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Aiky哇

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值