https://clickhouse.tech/docs/en/operations/server-configuration-parameters/settings/ ---> config.xml
https://clickhouse.tech/docs/en/operations/settings/settings/ ---> users.xml
config.xml文件调用users.xml配置,为profiles和quotas指定单独的配置。此配置的相对路径在'users_config'元素中设置。默认情况下,它是users.xml。如果省略users_config,则直接在config.xml中指定。
vim etc/clickhouse-server/config.xml<users_config>users.xmlusers_config>
Server settings:在config.xml中配置部分
<logger><level>tracelevel> --日志记录级别。可接受的值:trace, debug, information, warning, error<log>/var/log/clickhouse-server/clickhouse-server.loglog> --日志文件,根据级别包含所有条目<errorlog>/var/log/clickhouse-server/clickhouse-server.err.logerrorlog> -- 错误日志文件<size>1000Msize> -- 文件的大小。适用于loganderrorlog,文件达到大小后,ClickHouse将对其进行存档并重命名,并在其位置创建一个新的日志文件<count>10count> -- ClickHouse存储的已归档日志文件的数量logger>
<logger><use_syslog>1use_syslog> -- 写入系统日志<syslog><address>syslog.remote:10514address> -- syslogd的主机[:port]。如果省略,则使用本地守护程序<hostname>myhost.localhostname> -- 可选,从中发送日志的主机的名称。<facility>LOG_LOCAL6facility> -- syslog关键字,其大写字母带有“ LOG_”前缀:(LOG_USER,LOG_DAEMON,LOG_LOCAL3,依此类推)<format>syslogformat> -- 格式。可能的值:bsd和syslogsyslog>logger>
<http_port>8123http_port><https_port>8443https_port><openSSL><server><certificateFile>/etc/clickhouse-server/server.crtcertificateFile><privateKeyFile>/etc/clickhouse-server/server.keyprivateKeyFile><dhParamsFile>/etc/clickhouse-server/dhparam.pemdhParamsFile><verificationMode>noneverificationMode><loadDefaultCAFile>trueloadDefaultCAFile><cacheSessions>truecacheSessions><disableProtocols>sslv2,sslv3disableProtocols><preferServerCiphers>truepreferServerCiphers>server><client><loadDefaultCAFile>trueloadDefaultCAFile><cacheSessions>truecacheSessions><disableProtocols>sslv2,sslv3disableProtocols><preferServerCiphers>truepreferServerCiphers><invalidCertificateHandler><name>RejectCertificateHandlername>invalidCertificateHandler>client>openSSL>
<tcp_port>9000tcp_port>
<tcp_port_secure> 9440 tcp_port_secure>
<mysql_port>9004mysql_port>
<interserver_http_port>9009interserver_http_port>
<interserver_http_host>example.yandex.ruinterserver_http_host>
<interserver_http_credentials><user>adminuser><password>222password>interserver_http_credentials>
<listen_host> :: 1 listen_host><listen_host> 127.0.0.1 listen_host>
<max_connections>4096max_connections>
<keep_alive_timeout>3keep_alive_timeout>
12. max_concurrent_queries元素:同时处理的最大请求数。
<max_concurrent_queries>100max_concurrent_queries>
13.max_server_memory_usage元素:限制ClickHouse服务器的总RAM使用量。取值:正整数、0(自动),默认值:0。
附加信息:默认max_server_memory_usage值计算为memory_amount * max_server_memory_usage_to_ram_ratio。
<max_server_memory_usage>0max_server_memory_usage>
<max_thread_pool_size>10000max_thread_pool_size>
15.max_server_memory_usage_to_ram_ratio 元素:定义可用于Clickhouse服务器的总物理RAM量的一部分。如果服务器尝试利用更多资源,则会将内存减少到适当的数量。可能的值:正双、0-Clickhouse服务器可以使用所有可用的RAM,默认值:0。
在具有低RAM和交换max_server_memory_usage_to_ram_ratio容量的主机上,您可能需要设置大于1的值。
<max_server_memory_usage_to_ram_ratio>0.9max_server_memory_usage_to_ram_ratio>
<max_open_files> 262144 max_open_files>
<uncompressed_cache_size>8589934592uncompressed_cache_size>
<mark_cache_size>5368709120mark_cache_size>
<path>/var/lib/clickhouse/path>
/var/lib/clickhouse/user_files/user_files_path>
<users_config>users.xmlusers_config>
<default_profile>defaultdefault_profile>
<default_database>defaultdefault_database>
<include_from>/etc/metrica.xmlinclude_from>
3600
<graphite><host>localhosthost> -- Graphite服务器<port>42000port> -- Graphite服务器上的端口<timeout>0.1timeout> -- 发送超时时间,以秒为单位<interval>60interval> -- 发送间隔,以秒为单位<root_path>one_minroot_path> -- 密钥的前缀<metrics>truemetrics> -- 从system.metrics表发送数据<events>trueevents> -- 从system.events表发送在该时间段内累积的增量数据<events_cumulative>falseevents_cumulative> -- 从system.events表发送累积数据<asynchronous_metrics>trueasynchronous_metrics> -- 从system.asynchronous_metrics表发送数据graphite>
<query_log><database>systemdatabase> --库名<table>query_logtable> --表名<partition_by>toMonday(event_date)partition_by> --自定义分区键<flush_interval_milliseconds>7500flush_interval_milliseconds> --将数据从内存中的缓冲区刷新到表的时间间隔query_log>
<trace_log><database>systemdatabase> --库名<table>trace_logtable> --表名<partition_by>toYYYYMM(event_date)partition_by> ----自定义分区键<flush_interval_milliseconds>7500flush_interval_milliseconds> ----将数据从内存中的缓冲区刷新到表的时间间隔trace_log>28.query_thread_log元素:使用log_query_threads = 1设置,记录接收到查询的线程。查询记录在system.query_thread_log表中,而不记录在单独的文件中。您可以在table参数中更改表的名称。
<query_thread_log><database>systemdatabase> --库名<table>query_thread_logtable> --表名<partition_by>toMonday(event_date)partition_by> --自定义分区键<flush_interval_milliseconds>7500flush_interval_milliseconds> --将数据从内存中的缓冲区刷新到表的时间间隔query_thread_log>
<part_log><database>systemdatabase> --库名<table>part_logtable> --表名<partition_by>toMonday(event_date)partition_by> --自定义分区键<flush_interval_milliseconds>7500flush_interval_milliseconds> --将数据从内存中的缓冲区刷新到表的时间间隔,单位毫秒。part_log>
<dictionaries_config>*_dictionary.xmldictionaries_config>
<compression incl="clickhouse_compression"> --指定incl<case><min_part_size>10000000000min_part_size> --数据部分的最小大小<min_part_size_ratio>0.01min_part_size_ratio> --数据部分大小与表大小的比率<method>zstdmethod> --压缩算法,zstd和lz4case>compression>
<max_table_size_to_drop>0max_table_size_to_drop>
Server settings:使用set设置(system.settings)
1. log_queries:设置发送到ClickHouse的查询将根据query_log服务器配置参数中的规则记录。
在system.settings中以log_queries为例:
set log_queries=1;Ok.0 rows in set. Elapsed: 0.001 sec.select * from system.settings where name ='log_queries'\GRow 1:──────name: log_queriesvalue: 1changed: 1description: Log requests and write the log to the system table.min: ᴺᵁᴸᴸmax: ᴺᵁᴸᴸreadonly: 0type: Bool1 rows in set. Elapsed: 0.002 sec.
如在服务器上运行少于一个SELECT查询,则将此参数设置为稍小于处理器核心实际数量的值。
如如果每个块中都有必要的条目数,并且max_threads = 8,则将检索8个块,尽管仅读取一个块就足够了。
上一篇:ClickHouse优化典藏
近期文章推荐:
更多精彩内容欢迎关注微信公众号

最后修改时间:2021-05-09 09:24:57
文章转载自 ClickHouse周边,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




