您好,登錄后才能下訂單哦!
這期內(nèi)容當(dāng)中小編將會給大家?guī)碛嘘P(guān)ClickHouse如何部署,文章內(nèi)容豐富且以專業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。
依賴 | 版本 |
---|---|
ClickHouse | 20.11.3.3-2 |
CentOS | 7.x |
Gcc | 4.8.5 |
離線安裝方式(我們使用下載到本地進(jìn)行安裝)
wget https://repo.yandex.ru/clickhouse/rpm/stable/x86_64/clickhouse-client-20.11.3.3-2.noarch.rpm wget https://repo.yandex.ru/clickhouse/rpm/stable/x86_64/clickhouse-common-static-20.11.3.3-2.x86_64.rpm wget https://repo.yandex.ru/clickhouse/rpm/stable/x86_64/clickhouse-common-static-dbg-20.11.3.3-2.x86_64.rpm wget https://repo.yandex.ru/clickhouse/rpm/stable/x86_64/clickhouse-server-20.11.3.3-2.noarch.rpm yum install -y clickhouse-*
yum源在線安裝
sudo yum install yum-utils sudo rpm --import https://repo.clickhouse.tech/CLICKHOUSE-KEY.GPG sudo yum-config-manager --add-repo https://repo.clickhouse.tech/rpm/stable/x86_64 sudo yum install clickhouse-server clickhouse-client
如果您想使用最新版本,請將stable替換為testing(建議您在測試環(huán)境中使用)
ClickHouse中的配置項(xiàng)很多,默認(rèn)會在/etc
下生成clickhouse-server
和clickhouse-client
兩個(gè)目錄,由于我們安裝服務(wù)我們?nèi)バ薷?code>clickhouse-server下的配置文件
修改/etc/clickhouse-server/config.xml
<?xml version="1.0"?> <!-- NOTE: User and query level settings are set up in "users.xml" file. --> <yandex> <logger> <!-- Possible levels: https://github.com/pocoproject/poco/blob/develop/Foundation/include/Poco/Logger.h#L105 --> <level>trace</level> <log>/data2/clickhouse/clickhouse-server.log</log> <errorlog>/data2/clickhouse/clickhouse-server.err.log</errorlog> <size>1000M</size> <count>10</count> <!-- <console>1</console> --> <!-- Default behavior is autodetection (log to console if not daemon mode and is tty) --> </logger> <!--display_name>production</display_name--> <!-- It is the name that will be shown in the client --> <http_port>9123</http_port> <tcp_port>9000</tcp_port> <!-- For HTTPS and SSL over native protocol. --> <!-- <https_port>8443</https_port> <tcp_port_secure>9440</tcp_port_secure> --> <!-- Used with https_port and tcp_port_secure. Full ssl options list: https://github.com/ClickHouse-Extras/poco/blob/master/NetSSL_OpenSSL/include/Poco/Net/SSLManager.h#L71 --> <openSSL> <server> <!-- Used for https server AND secure tcp port --> <!-- 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 --> <certificateFile>/etc/clickhouse-server/server.crt</certificateFile> <privateKeyFile>/etc/clickhouse-server/server.key</privateKeyFile> <!-- openssl dhparam -out /etc/clickhouse-server/dhparam.pem 4096 --> <dhParamsFile>/etc/clickhouse-server/dhparam.pem</dhParamsFile> <verificationMode>none</verificationMode> <loadDefaultCAFile>true</loadDefaultCAFile> <cacheSessions>true</cacheSessions> <disableProtocols>sslv2,sslv3</disableProtocols> <preferServerCiphers>true</preferServerCiphers> </server> <client> <!-- Used for connecting to https dictionary source --> <loadDefaultCAFile>true</loadDefaultCAFile> <cacheSessions>true</cacheSessions> <disableProtocols>sslv2,sslv3</disableProtocols> <preferServerCiphers>true</preferServerCiphers> <!-- Use for self-signed: <verificationMode>none</verificationMode> --> <invalidCertificateHandler> <!-- Use for self-signed: <name>AcceptCertificateHandler</name> --> <name>RejectCertificateHandler</name> </invalidCertificateHandler> </client> </openSSL> <!-- Default root page on http[s] server. For example load UI from https://tabix.io/ when opening http://localhost:8123 --> <!-- <http_server_default_response><![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>]]></http_server_default_response> --> <!-- Port for communication between replicas. Used for data exchange. --> <interserver_http_port>9009</interserver_http_port> <listen_host>0.0.0.0</listen_host> <!-- Don't exit if ipv6 or ipv4 unavailable, but listen_host with this protocol specified --> <!-- <listen_try>0</listen_try> --> <!-- Allow listen on same address:port --> <!-- <listen_reuse_port>0</listen_reuse_port> --> <!-- <listen_backlog>64</listen_backlog> --> <max_connections>4096</max_connections> <keep_alive_timeout>3</keep_alive_timeout> <!-- Maximum number of concurrent queries. --> <max_concurrent_queries>100</max_concurrent_queries> <!-- Set limit on number of open files (default: maximum). This setting makes sense on Mac OS X because getrlimit() fails to retrieve correct maximum value. --> <!-- <max_open_files>262144</max_open_files> --> <!-- Size of cache of uncompressed blocks of data, used in tables of MergeTree family. In bytes. Cache is single for server. Memory is allocated only on demand. Cache is used when 'use_uncompressed_cache' user setting turned on (off by default). Uncompressed cache is advantageous only for very short queries and in rare cases. --> <uncompressed_cache_size>8589934592</uncompressed_cache_size> <!-- Approximate size of mark cache, used in tables of MergeTree family. In bytes. Cache is single for server. Memory is allocated only on demand. You should not lower this value. --> <mark_cache_size>5368709120</mark_cache_size> <!-- Path to data directory, with trailing slash. --> <path>/data2/clickhouse/data/</path> <!-- Path to temporary data for processing hard queries. --> <tmp_path>/data2/clickhouse/tmp/</tmp_path> <!-- Directory with user provided files that are accessible by 'file' table function. --> <user_files_path>/data2/clickhouse/user_files/</user_files_path> <!-- Path to configuration file with users, access rights, profiles of settings, quotas. --> <users_config>users.xml</users_config> <!-- Default profile of settings. --> <default_profile>default</default_profile> <!-- System profile of settings. This settings are used by internal processes (Buffer storage, Distibuted DDL worker and so on). --> <!-- <system_profile>default</system_profile> --> <!-- Default database. --> <default_database>default</default_database> <mlock_executable>false</mlock_executable> <zookeeper incl="zookeeper-servers" optional="true" /> <!-- Substitutions for parameters of replicated tables. Optional. If you don't use replicated tables, you could omit that. See https://clickhouse.yandex/docs/en/table_engines/replication/#creating-replicated-tables --> <macros incl="macros" optional="true" /> <!-- Reloading interval for embedded dictionaries, in seconds. Default: 3600. --> <builtin_dictionaries_reload_interval>3600</builtin_dictionaries_reload_interval> <!-- Maximum session timeout, in seconds. Default: 3600. --> <max_session_timeout>3600</max_session_timeout> <!-- Default session timeout, in seconds. Default: 60. --> <default_session_timeout>60</default_session_timeout> <!-- Query log. Used only for queries with setting log_queries = 1. --> <query_log> <!-- What table to insert data. If table is not exist, it will be created. When query log structure is changed after system update, then old table will be renamed and new table will be created automatically. --> <database>system</database> <table>query_log</table> <!-- PARTITION BY expr https://clickhouse.yandex/docs/en/table_engines/custom_partitioning_key/ Example: event_date toMonday(event_date) toYYYYMM(event_date) toStartOfHour(event_time) --> <partition_by>toYYYYMM(event_date)</partition_by> <!-- Interval of flushing data. --> <flush_interval_milliseconds>7500</flush_interval_milliseconds> </query_log> <!-- Trace log. Stores stack traces collected by query profilers. See query_profiler_real_time_period_ns and query_profiler_cpu_time_period_ns settings. --> <trace_log> <database>system</database> <table>trace_log</table> <partition_by>toYYYYMM(event_date)</partition_by> <flush_interval_milliseconds>7500</flush_interval_milliseconds> </trace_log> <!-- Query thread log. Has information about all threads participated in query execution. Used only for queries with setting log_query_threads = 1. --> <query_thread_log> <database>system</database> <table>query_thread_log</table> <partition_by>toYYYYMM(event_date)</partition_by> <flush_interval_milliseconds>7500</flush_interval_milliseconds> </query_thread_log> <dictionaries_config>*_dictionary.xml</dictionaries_config> <!-- Uncomment if you want data to be compressed 30-100% better. Don't do that if you just started using ClickHouse. --> <compression incl="clickhouse_compression"> </compression> <!-- Allow to execute distributed DDL queries (CREATE, DROP, ALTER, RENAME) on cluster. Works only if ZooKeeper is enabled. Comment it if such functionality isn't required. --> <distributed_ddl> <!-- Path in ZooKeeper to queue with DDL queries --> <path>/a8root/clickhouse/task_queue/ddl</path> <!-- Settings from this profile will be used to execute DDL queries --> <!-- <profile>default</profile> --> </distributed_ddl> <graphite_rollup_example> <pattern> <regexp>click_cost</regexp> <function>any</function> <retention> <age>0</age> <precision>3600</precision> </retention> <retention> <age>86400</age> <precision>60</precision> </retention> </pattern> <default> <function>max</function> <retention> <age>0</age> <precision>60</precision> </retention> <retention> <age>3600</age> <precision>300</precision> </retention> <retention> <age>86400</age> <precision>3600</precision> </retention> </default> </graphite_rollup_example> <format_schema_path>/data2/clickhouse/format_schemas/</format_schema_path> </yandex>
我們一般修改以下配置項(xiàng):
logger
修改日志的存放路徑
http_port
修改瀏覽器訪問的端口,默認(rèn)為8123
tcp_port
修改tcp協(xié)議的傳輸端口
openSSL
一些ssl的認(rèn)證配置文件,我們暫時(shí)不做ssl認(rèn)證,此處不做處理
listen_host
如果我們要對外使用服務(wù)的話,此處需要修改成0.0.0.0
remote_servers
此處是集群相關(guān)的配置信息后續(xù)會詳解
其他自定義的配置可自行修改,修改配置后我們便可以啟動一個(gè)本地的ClickHouse服務(wù)
創(chuàng)建相關(guān)目錄及權(quán)限
mkdir -p /data2/clickhouse chown -R clickhouse:clickhouse /data2/clickhouse
啟動服務(wù)
sudo -u clickhouse clickhouse-server --daemon --pid-file=/var/run/clickhouse-server/clickhouse-server.pid --config-file=/etc/clickhouse-server/config.xml
--daemon
標(biāo)志我們要后臺啟動服務(wù)
--pid-file
指定服務(wù)啟動后的進(jìn)行文件路徑
--config-file
指定服務(wù)啟動的配置文件
如果我們使用調(diào)試可使用以下命令
sudo -u clickhouse clickhouse-server start
要用單獨(dú)的用戶啟動,如果使用root啟動的話系統(tǒng)會做提示信息
ClickHouse安裝完成后會生成clickhouse-server
和clickhouse-client
兩個(gè)目錄,這個(gè)時(shí)候我們使用clickhouse-client
去測試服務(wù)
clickhouse-client -h clickhouse --port 9000 --multiquery --query="show databases"
注意:--port指定的是tcp的端口
運(yùn)行查詢數(shù)據(jù)庫列表返回類似以下信息
_temporary_and_external_tables default system
上述就是小編為大家分享的ClickHouse如何部署了,如果剛好有類似的疑惑,不妨參照上述分析進(jìn)行理解。如果想知道更多相關(guān)知識,歡迎關(guān)注億速云行業(yè)資訊頻道。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。