单机版
安装客户端和服务端
到rpm包存放的路径下
rpm -ivh *.rpm
下载链接:
链接:https://pan.baidu.com/s/16WCVsMgFMYNxZTRtgUjsjA
提取码:cj24
修改配置文件(如果需要外网访问)
# vi /etc/clickhouse-server/config.xml
放开 <listen_host>::</listen_host> 的注释
启动服务
service clickhouse-server start
看到如下提示说明成功启动
Start clickhouse-server service: Path to data directory in /etc/clickhouse-server/config.xml: /var/lib/clickhouse/
DONE
启动客户端(检验安装是否成功)
clickhouse-client
wbl.clickhouse :) select 1
SELECT 1
┌─1─┐
│ 1 │
└───┘
1 rows in set. Elapsed: 0.003 sec.
集群版
vim /etc/metrika.xml
写入如下配置
<!-- 其中大部分配置一样,下面的node01、node02、node03根据自己的节点名称进行配置 -->
<yandex>
<clickhouse_remote_servers>
<perftest_3shards_1replicas>
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>node01</host>
<port>9000</port>
</replica>
</shard>
<shard>
<replica>
<internal_replication>true</internal_replication>
<host>node02</host>
<port>9000</port>
</replica>
</shard>
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>node03</host>
<port>9000</port>
</replica>
</shard>
</perftest_3shards_1replicas>
</clickhouse_remote_servers>
<!--zookeeper相关配置-->
<zookeeper-servers>
<node index="1">
<host>node01</host>
<port>2182</port>
</node>
<node index="2">
<host>node02</host>
<port>2182</port>
</node>
<node index="3">
<host>node03</host>
<port>2182</port>
</node>
</zookeeper-servers>
<!-- 这里的配置在不同的机器上需要配置不同的host -->
<macros>
<replica>node03</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>
然后将配置文件发往集群其它节点,修改
<macros>
<replica>node03</replica>
</macros>
验证
每个节点启动服务,进入客户端
select * from system.clusters;
看到一下现象,说明搭建成功
node01
node02
node03
表中的 is_local 字段 表示在那台节点上进入的客户端
完美搭建!