服务器配置

    ClickHouse每x秒重新加载内置字典。 这使得编辑字典 “on the fly”,而无需重新启动服务器。

    默认值:3600.

    示例

    压缩

    数据压缩配置 -引擎表。

    警告

    如果您刚开始使用ClickHouse,请不要使用它。

    配置模板:

    1. <case>
    2. <min_part_size>...</min_part_size>
    3. <min_part_size_ratio>...</min_part_size_ratio>
    4. <method>...</method>
    5. </case>
    6. ...
    7. </compression>

    <case> 参数:

    • min_part_size – The minimum size of a data part.
    • min_part_size_ratio – The ratio of the data part size to the table size.
    • method – Compression method. Acceptable values: lz4zstd.

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

    满足条件时的操作:

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

    如果没有满足数据部分的条件,ClickHouse使用 lz4 压缩。

    示例

    1. <compression incl="clickhouse_compression">
    2. <case>
    3. <min_part_size>10000000000</min_part_size>
    4. <min_part_size_ratio>0.01</min_part_size_ratio>
    5. <method>zstd</method>
    6. </case>
    7. </compression>

    default_database

    默认数据库。

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

    示例

    1. <default_database>default</default_database>

    default_profile

    默认配置文件。

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

    示例

    1. <default_profile>default</default_profile>

    dictionaries_config

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

    路径:

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

    另请参阅 “外部字典”.

    示例

    1. <dictionaries_config>*_dictionary.xml</dictionaries_config>

    dictionaries_lazy_load

    延迟加载字典。

    如果 true,然后在第一次使用时创建每个字典。 如果字典创建失败,则使用该字典的函数将引发异常。

    如果 false,服务器启动时创建所有字典,如果出现错误,服务器将关闭。

    默认值为 true.

    示例

    1. <dictionaries_lazy_load>true</dictionaries_lazy_load>

    format_schema_path

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

    示例

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

    石墨

    将数据发送到 .

    设置:

    • host – The Graphite server.
    • port – The port on the Graphite server.
    • interval – The interval for sending, in seconds.
    • timeout – The timeout for sending data, in seconds.
    • root_path – Prefix for keys.
    • metrics – Sending data from the 系统。指标 桌子
    • events – Sending deltas data accumulated for the time period from the 桌子
    • events_cumulative – Sending cumulative data from the 系统。活动 桌子
    • asynchronous_metrics – Sending data from the 桌子

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

    示例

    1. <graphite>
    2. <host>localhost</host>
    3. <port>42000</port>
    4. <timeout>0.1</timeout>
    5. <interval>60</interval>
    6. <root_path>one_min</root_path>
    7. <metrics>true</metrics>
    8. <events>true</events>
    9. <asynchronous_metrics>true</asynchronous_metrics>
    10. </graphite>

    graphite_rollup

    石墨细化数据的设置。

    有关详细信息,请参阅 .

    示例

    1. <graphite_rollup_example>
    2. <default>
    3. <function>max</function>
    4. <retention>
    5. <age>0</age>
    6. <precision>60</precision>
    7. </retention>
    8. <retention>
    9. <age>3600</age>
    10. <precision>300</precision>
    11. </retention>
    12. <retention>
    13. <age>86400</age>
    14. <precision>3600</precision>
    15. </retention>
    16. </default>
    17. </graphite_rollup_example>

    http_port/https_port

    通过HTTP连接到服务器的端口。

    如果 https_port 被指定, 必须配置。

    如果 http_port 指定时,即使设置了OpenSSL配置,也会忽略该配置。

    示例

    1. <https_port>9999</https_port>

    http_server_default_response

    访问ClickHouse HTTP(s)服务器时默认显示的页面。
    默认值为 “Ok.” (最后有换行符)

    示例

    打开 https://tabix.io/ 访问时 http://localhost: http_port.

    1. <http_server_default_response>
    2. <![CDATA[<html ng-app="SMI2"><head><base href="http://ui.tabix.io/"></head><body><div ui-view="" class="content-ui"></div><script src="http://loader.tabix.io/master.js"></script></body></html>]]>
    3. </http_server_default_response>

    包括_从

    带替换的文件的路径。

    有关详细信息,请参阅部分 “配置文件”.

    示例

    1. <include_from>/etc/metrica.xml</include_from>

    interserver_http_port

    用于在ClickHouse服务器之间交换数据的端口。

    示例

    1. <interserver_http_port>9009</interserver_http_port>

    interserver_http_host

    其他服务器可用于访问此服务器的主机名。

    如果省略,它以相同的方式作为定义 hostname-f 指挥部

    用于脱离特定的网络接口。

    示例

    1. <interserver_http_host>example.yandex.ru</interserver_http_host>

    interserver_http_credentials

    用户名和密码用于在以下期间进行身份验证 复制 与复制*引擎。 这些凭据仅用于副本之间的通信,与ClickHouse客户端的凭据无关。 服务器正在检查这些凭据以连接副本,并在连接到其他副本时使用相同的凭据。 因此,这些凭据应该为集群中的所有副本设置相同。
    默认情况下,不使用身份验证。

    本节包含以下参数:

    • user — username.
    • password — password.

    示例

    ClickHouse在关闭连接之前等待传入请求的秒数。 默认为3秒。

    示例

    1. <keep_alive_timeout>3</keep_alive_timeout>

    listen_host

    对请求可能来自的主机的限制。 如果您希望服务器回答所有这些问题,请指定 ::.

    1. <listen_host>::1</listen_host>
    2. <listen_host>127.0.0.1</listen_host>

    记录器

    日志记录设置。

    键:

    • level – Logging level. Acceptable values: trace, debug, information, warning, error.
    • log – The log file. Contains all the entries according to level.
    • errorlog – Error log file.
    • size – Size of the file. Applies to log和. 一旦文件到达 size,ClickHouse存档并重命名它,并在其位置创建一个新的日志文件。
    • count – The number of archived log files that ClickHouse stores.

    示例

    1. <logger>
    2. <level>trace</level>
    3. <log>/var/log/clickhouse-server/clickhouse-server.log</log>
    4. <errorlog>/var/log/clickhouse-server/clickhouse-server.err.log</errorlog>
    5. <size>1000M</size>
    6. <count>10</count>
    7. </logger>

    还支持写入系统日志。 配置示例:

    1. <logger>
    2. <use_syslog>1</use_syslog>
    3. <syslog>
    4. <address>syslog.remote:10514</address>
    5. <hostname>myhost.local</hostname>
    6. <facility>LOG_LOCAL6</facility>
    7. <format>syslog</format>
    8. </syslog>
    9. </logger>

    键:

    • use_syslog — Required setting if you want to write to the syslog.
    • address — The host[:port] of syslogd. If omitted, the local daemon is used.
    • hostname — Optional. The name of the host that logs are sent from.
    • facility — 在大写字母与 “LOG_” 前缀: (LOG_USER, LOG_DAEMON, LOG_LOCAL3,等等)。
      默认值: LOG_USER 如果 address 被指定, LOG_DAEMON otherwise.
    • format – Message format. Possible values: bsdsyslog.

    复制表的参数替换。

    如果不使用复制的表,则可以省略。

    有关详细信息,请参阅部分 “”.

    示例

    1. <macros incl="macros" optional="true" />

    mark_cache_size

    表引擎使用的标记缓存的近似大小(以字节为单位) 家人

    缓存为服务器共享,并根据需要分配内存。 缓存大小必须至少为5368709120。

    示例

    1. <mark_cache_size>5368709120</mark_cache_size>

    max_concurrent_queries

    同时处理的请求的最大数量。

    示例

    1. <max_concurrent_queries>100</max_concurrent_queries>

    max_connections

    入站连接的最大数量。

    示例

    1. <max_connections>4096</max_connections>

    max_open_files

    打开文件的最大数量。

    默认情况下: maximum.

    我们建议在Mac OS X中使用此选项,因为 getrlimit() 函数返回一个不正确的值。

    示例

    1. <max_open_files>262144</max_open_files>

    max_table_size_to_drop

    限制删除表。

    如果一个大小 MergeTree 表超过 max_table_size_to_drop (以字节为单位),您无法使用删除查询将其删除。

    如果仍然需要在不重新启动ClickHouse服务器的情况下删除表,请创建 <clickhouse-path>/flags/force_drop_table 文件并运行DROP查询。

    默认值:50GB。

    值0表示您可以删除所有表而不受任何限制。

    示例

    1. <max_table_size_to_drop>0</max_table_size_to_drop>

    merge_tree

    微调中的表 MergeTree.

    有关详细信息,请参阅MergeTreeSettings。h头文件。

    示例

    1. <merge_tree>
    2. <max_suspicious_broken_parts>5</max_suspicious_broken_parts>
    3. </merge_tree>

    openSSL

    SSL客户端/服务器配置。

    对SSL的支持由 libpoco 图书馆. 该接口在文件中描述 SSLManager.h

    服务器/客户端设置的密钥:

    • privateKeyFile – The path to the file with the secret key of the PEM certificate. The file may contain a key and certificate at the same time.
    • certificateFile – The path to the client/server certificate file in PEM format. You can omit it if privateKeyFile 包含证书。
    • caConfig – The path to the file or directory that contains trusted root certificates.
    • verificationMode – The method for checking the node’s certificates. Details are in the description of the 同学们 可能的值: none, relaxed, strict, once.
    • verificationDepth – The maximum length of the verification chain. Verification will fail if the certificate chain length exceeds the set value.
    • loadDefaultCAFile – Indicates that built-in CA certificates for OpenSSL will be used. Acceptable values: true, false. |
    • cipherList – Supported OpenSSL encryptions. For example: ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH.
    • cacheSessions – Enables or disables caching sessions. Must be used in combination with sessionIdContext. 可接受的值: true, false.
    • sessionIdContext – A unique set of random characters that the server appends to each generated identifier. The length of the string must not exceed SSL_MAX_SSL_SESSION_ID_LENGTH. 始终建议使用此参数,因为如果服务器缓存会话,以及客户端请求缓存,它有助于避免出现问题。 默认值: ${application.name}.
    • sessionCacheSize – The maximum number of sessions that the server caches. Default value: 1024*20. 0 – Unlimited sessions.
    • sessionTimeout – Time for caching the session on the server.
    • extendedVerification – Automatically extended verification of certificates after the session ends. Acceptable values: true, false.
    • requireTLSv1 – Require a TLSv1 connection. Acceptable values: true, false.
    • requireTLSv1_1 – Require a TLSv1.1 connection. Acceptable values: true, false.
    • requireTLSv1 – Require a TLSv1.2 connection. Acceptable values: true, false.
    • fips – Activates OpenSSL FIPS mode. Supported if the library’s OpenSSL version supports FIPS.
    • privateKeyPassphraseHandler – Class (PrivateKeyPassphraseHandler subclass) that requests the passphrase for accessing the private key. For example: <privateKeyPassphraseHandler>, <name>KeyFileHandler</name>, <options><password>test</password></options>, </privateKeyPassphraseHandler>.
    • invalidCertificateHandler – Class (a subclass of CertificateHandler) for verifying invalid certificates. For example: <invalidCertificateHandler> <name>ConsoleCertificateHandler</name> </invalidCertificateHandler> .
    • disableProtocols – Protocols that are not allowed to use.
    • preferServerCiphers – Preferred server ciphers on the client.

    设置示例:

    1. <openSSL>
    2. <server>
    3. <!-- openssl req -subj "/CN=localhost" -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout /etc/clickhouse-server/server.key -out /etc/clickhouse-server/server.crt -->
    4. <certificateFile>/etc/clickhouse-server/server.crt</certificateFile>
    5. <privateKeyFile>/etc/clickhouse-server/server.key</privateKeyFile>
    6. <dhParamsFile>/etc/clickhouse-server/dhparam.pem</dhParamsFile>
    7. <verificationMode>none</verificationMode>
    8. <loadDefaultCAFile>true</loadDefaultCAFile>
    9. <cacheSessions>true</cacheSessions>
    10. <disableProtocols>sslv2,sslv3</disableProtocols>
    11. <preferServerCiphers>true</preferServerCiphers>
    12. </server>
    13. <client>
    14. <loadDefaultCAFile>true</loadDefaultCAFile>
    15. <cacheSessions>true</cacheSessions>
    16. <disableProtocols>sslv2,sslv3</disableProtocols>
    17. <preferServerCiphers>true</preferServerCiphers>
    18. <!-- Use for self-signed: <verificationMode>none</verificationMode> -->
    19. <invalidCertificateHandler>
    20. <!-- Use for self-signed: <name>AcceptCertificateHandler</name> -->
    21. </invalidCertificateHandler>
    22. </client>
    23. </openSSL>

    part_log

    记录与之关联的事件 . 例如,添加或合并数据。 您可以使用日志来模拟合并算法并比较它们的特征。 您可以可视化合并过程。

    查询记录在 系统。part_log 表,而不是在一个单独的文件。 您可以在以下命令中配置此表的名称 table 参数(见下文)。

    使用以下参数配置日志记录:

    • database – Name of the database.
    • table – Name of the system table.
    • partition_by – Sets a .
    • flush_interval_milliseconds – Interval for flushing data from the buffer in memory to the table.

    示例

    1. <part_log>
    2. <database>system</database>
    3. <table>part_log</table>
    4. <partition_by>toMonday(event_date)</partition_by>
    5. <flush_interval_milliseconds>7500</flush_interval_milliseconds>
    6. </part_log>

    路径

    包含数据的目录的路径。

    尾部斜杠是强制性的。

    示例

    1. <path>/var/lib/clickhouse/</path>

    query_log

    用于记录接收到的查询的设置 log_queries=1 设置。

    查询记录在 表,而不是在一个单独的文件。 您可以更改表的名称 table 参数(见下文)。

    使用以下参数配置日志记录:

    • database – Name of the database.
    • table – Name of the system table the queries will be logged in.
    • partition_by – Sets a 自定义分区键 为了一张桌子
    • flush_interval_milliseconds – Interval for flushing data from the buffer in memory to the table.

    如果该表不存在,ClickHouse将创建它。 如果在ClickHouse服务器更新时查询日志的结构发生了更改,则会重命名具有旧结构的表,并自动创建新表。

    示例

    query_thread_log

    设置用于记录接收到的查询的线程 log_query_threads=1 设置。

    查询记录在 表,而不是在一个单独的文件。 您可以更改表的名称 table 参数(见下文)。

    使用以下参数配置日志记录:

    • database – Name of the database.
    • table – Name of the system table the queries will be logged in.
    • partition_by – Sets a 自定义分区键 对于一个系统表。
    • flush_interval_milliseconds – Interval for flushing data from the buffer in memory to the table.

    如果该表不存在,ClickHouse将创建它。 如果更新ClickHouse服务器时查询线程日志的结构发生了更改,则会重命名具有旧结构的表,并自动创建新表。

    示例

    1. <query_thread_log>
    2. <database>system</database>
    3. <table>query_thread_log</table>
    4. <partition_by>toMonday(event_date)</partition_by>
    5. <flush_interval_milliseconds>7500</flush_interval_milliseconds>
    6. </query_thread_log>

    设置为 系统表操作。

    参数:

    • database — Database for storing a table.
    • table — Table name.
    • partition_by自定义分区键 对于一个系统表。
    • flush_interval_milliseconds — Interval for flushing data from the buffer in memory to the table.

    默认服务器配置文件 config.xml 包含以下设置部分:

    1. <trace_log>
    2. <database>system</database>
    3. <table>trace_log</table>
    4. <partition_by>toYYYYMM(event_date)</partition_by>
    5. <flush_interval_milliseconds>7500</flush_interval_milliseconds>
    6. </trace_log>

    query_masking_rules

    基于正则表达式的规则,在将查询以及所有日志消息存储在服务器日志中之前,这些规则将应用于查询以及所有日志消息,
    system.query_log, system.text_log, system.processes 表,并在日志中发送给客户端。 这允许防止
    从SQL查询敏感数据泄漏(如姓名,电子邮件,个人
    标识符或信用卡号码)记录。

    示例

    1. <query_masking_rules>
    2. <rule>
    3. <name>hide SSN</name>
    4. <regexp>(^|\D)\d{3}-\d{2}-\d{4}($|\D)</regexp>
    5. <replace>000-00-0000</replace>
    6. </rule>
    7. </query_masking_rules>

    配置字段:
    - name -规则的名称(可选)
    - regexp -RE2兼容正则表达式(强制性)
    - replace -敏感数据的替换字符串(可选,默认情况下-六个星号)

    屏蔽规则应用于整个查询(以防止敏感数据从格式错误/不可解析的查询泄漏)。

    对于分布式查询,每个服务器必须单独配置,否则,子查询传递给其他
    节点将被存储而不屏蔽。

    remote_servers

    所使用的集群的配置 表引擎和由 cluster 表功能。

    示例

    1. <remote_servers incl="clickhouse_remote_servers" />

    对于该值 incl 属性,请参阅部分 “配置文件”.

    另请参阅

    时区

    服务器的时区。

    指定为UTC时区或地理位置(例如,非洲/阿比让)的IANA标识符。

    当DateTime字段输出为文本格式(打印在屏幕上或文件中)时,以及从字符串获取DateTime时,时区对于字符串和DateTime格式之间的转换是必需的。 此外,如果在输入参数中没有收到时区,则时区用于处理时间和日期的函数。

    示例

    1. <timezone>Europe/Moscow</timezone>

    tcp_port

    通过TCP协议与客户端通信的端口。

    示例

    1. <tcp_port>9000</tcp_port>

    tcp_port_secure

    TCP端口,用于与客户端进行安全通信。 使用它与 设置。

    可能的值

    整数。

    默认值

    1. <tcp_port_secure>9440</tcp_port_secure>

    mysql_port

    通过MySQL协议与客户端通信的端口。

    可能的值

    整数。

    示例

    1. <mysql_port>9004</mysql_port>

    tmp_path

    用于处理大型查询的临时数据的路径。

    尾部斜杠是强制性的。

    示例

    1. <tmp_path>/var/lib/clickhouse/tmp/</tmp_path>

    tmp_policy

    从政策 存储临时文件。
    如果没有设置 tmp_path 被使用,否则被忽略。

    • move_factor 被忽略

    • keep_free_space_bytes 被忽略

    • max_data_part_size_bytes 被忽略
      -您必须在该政策中只有一个卷

    uncompressed_cache_size

    表引擎使用的未压缩数据的缓存大小(以字节为单位) MergeTree.

    服务器有一个共享缓存。 内存按需分配。 如果选项使用缓存 被启用。

    在个别情况下,未压缩的缓存对于非常短的查询是有利的。

    示例

    1. <uncompressed_cache_size>8589934592</uncompressed_cache_size>

    user_files_path

    包含用户文件的目录。 在表函数中使用 .

    示例

    1. <user_files_path>/var/lib/clickhouse/user_files/</user_files_path>

    users_config

    包含文件的路径:

    • 用户配置。
    • 访问权限。
    • 设置配置文件。
    • 配额设置。

    示例

    1. <users_config>users.xml</users_config>

    zookeeper

    包含允许ClickHouse与 zookpeer 集群。

    ClickHouse使用ZooKeeper存储复制表副本的元数据。 如果未使用复制的表,则可以省略此部分参数。

    本节包含以下参数:

    • node — ZooKeeper endpoint. You can set multiple endpoints.

      例如:

    1. <node index="1">
    2. <host>example_host</host>
    3. <port>2181</port>
    4. </node>
    1. The `index` attribute specifies the node order when trying to connect to the ZooKeeper cluster.
    • session_timeout — Maximum timeout for the client session in milliseconds.
    • root — The 隆隆隆隆路虏脢..陇.貌.垄拢卢虏禄.陇.貌路.隆拢脳枚脢虏.麓脢for脱 可选。
    • identity — User and password, that can be required by ZooKeeper to give access to requested znodes. Optional.

    配置示例

    另请参阅

    use_minimalistic_part_header_in_zookeeper

    ZooKeeper中数据部分头的存储方法。

    此设置仅适用于 MergeTree 家人 它可以指定:

    • 在全球范围内 一节 config.xml 文件

      ClickHouse使用服务器上所有表的设置。 您可以随时更改设置。 当设置更改时,现有表会更改其行为。

    • 对于每个表。

      创建表时,指定相应的 发动机设置. 即使全局设置更改,具有此设置的现有表的行为也不会更改。

    可能的值

    • 1 — Functionality is turned on.

    如果 use_minimalistic_part_header_in_zookeeper = 1,然后 表存储的数据部分的头紧凑使用一个单一的 znode. 如果表包含许多列,则此存储方法显着减少了Zookeeper中存储的数据量。

    注意

    申请后 ,您不能将ClickHouse服务器降级到不支持此设置的版本。 在集群中的服务器上升级ClickHouse时要小心。 不要一次升级所有服务器。 在测试环境中或在集群的几台服务器上测试ClickHouse的新版本更安全。

    Data part headers already stored with this setting can’t be restored to their previous (non-compact) representation.

    默认值: 0.

    disable_internal_dns_cache

    禁用内部DNS缓存。 推荐用于在系统中运行ClickHouse
    随着频繁变化的基础设施,如Kubernetes。

    默认值: 0.

    更新存储在ClickHouse内部DNS缓存中的IP地址的周期(以秒为单位)。
    更新是在一个单独的系统线程中异步执行的。

    默认值: 15.