Clickhouse -- 安裝部署和測試
阿新 • • 發佈:2020-12-17
嚮導
安裝前的準備
- CentOS取消開啟檔案數限制
#在/etc/security/limits.conf、/etc/security/limits.d/90-nproc.conf這2個檔案的末尾加入一下內容:
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072
- CentOS取消SELINUX,修改/etc/selinux/config中的SELINUX=disabled後重啟
- 關閉防火牆
- 安裝依賴
sudo yum install yum-utils libtool *unixODBC*
sudo rpm --import https://repo.clickhouse.tech/CLICKHOUSE-KEY.GPG
sudo yum-config-manager --add-repo https://repo.clickhouse.tech/rpm/stable/x86_64
安裝
單機模式
- 直接yum安裝即可
sudo yum install clickhouse-server clickhouse-client
叢集模式
- 在每臺機器yum安裝
sudo yum install clickhouse-server clickhouse-client
- 每臺機器修改配置檔案config.xml,注意:macros需要根據機器不同去修改
vim /etc/clickhouse-server/config.xml
<listen_host>::</listen_host>
<!-- <listen_host>::1</listen_host> -->
<!-- <listen_host>127.0.0.1</listen_host> -->
- 在每臺機器的etc目錄下新建metrika.xml檔案
vim /etc/metrika.xml
新增如下內容:
<yandex>
<clickhouse_remote_servers>
<perftest_2shards_1replicas>
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>xxx1</host>
<port>9000</port>
</replica>
</shard>
<shard>
<replica>
<internal_replication>true</internal_replication>
<host>xxx2</host>
<port>9000</port>
</replica>
</shard>
</perftest_2shards_1replicas>
</clickhouse_remote_servers>
<zookeeper-servers>
<node index="1">
<host>xxx1</host>
<port>2181</port>
</node>
<node index="2">
<host>xxx2</host>
<port>2181</port>
</node>
<node index="3">
<host>xxx3</host>
<port>2181</port>
</node>
</zookeeper-servers>
<macros>
<replica>xxx2</replica>
</macros>
<networks>
<ip>::/0</ip>
</networks>
<clickhouse_compression>
<case>
<min_part_size>10000000000</min_part_size>
<min_part_size_ratio>0.01</min_part_size_ratio>
<method>lz4</method>
</case>
</clickhouse_compression>
</yandex>
修改配置
vim /etc/clickhouse-server/config.xml
# 修改各種path:
<path>/data/clickhouse/</path>
<tmp_path>/data/clickhouse/tmp/</tmp_path>
<user_files_path>/data/clickhouse/user_files/</user_files_path>
<format_schema_path>/data/clickhouse/format_schemas/</format_schema_path>
啟動
- 前臺啟動:
clickhouse-server --config-file=/etc/clickhouse-server/config.xml
- 後臺啟動:
nohup clickhouse-server --config-file=/etc/clickhouse-server/config.xml > /dev/null 2>&1 &
使用client連線server
clickhouse-client