前提
- 需要一个Zookeeper集群
- 需要三个节点部署ClickHouse
config.xml基础配置
vi config.xml
通常要检查xml里面这几个:
listen_host # 改成<listen_host>::</listen_host>
tcp_port # 要改端口这里http 和 tcp
http_port
path
timezone #时区
user_scripts_path #自定义方法的一些实现
user_defined_executable_functions_config
include_from # 这里面应该是要有metrika.xml
分片配置
/etc/clickhouse-server/config.d/metrika.xml
<yandex>
<remote_servers>
<clickhouse_cluster_3shards_1replicas>
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>master</host>
<port>9000</port>
</replica>
</shard>
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>slave1</host>
<port>9000</port>
</replica>
</shard>
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>slave2</host>
<port>9000</port>
</replica>
</shard>
</clickhouse_cluster_3shards_1replicas>
</remote_servers>
<zookeeper>
<node index="1">
<host>master</host>
<port>2181</port>
</node>
<node index="2">
<host>slave1</host>
<port>2181</port>
</node>
<node index="3">
<host>slave2</host>
<port>2181</port>
</node>
</zookeeper>
<macros>
<shard>1</shard>
<replica>1-2</replica>
<replica>1-2-1</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>
集群节点配置clickhouse_remote_servers
clickhouse_cluster_3shards_1replicas 集群分片的名称
zookeeper配置 zookeeper-server
副本分片 macros
网络 networks
压缩相关配置 clickhouse_compression