目
3.2、在 hallo100 的/etc/clickhouse-server/config.d 目录下创建一个名为metrika.xml 的配置文件,内容如下:
3.3、在 hallo100 的/etc/clickhouse-server/config.xml 中增加如下内容
4.3、在hallo100、hallo101、hallo102上分别查询数据,均能够查到说明配置成功了
3.3、在 hallo100上创建 Distribute 分布式表
一、副本
1、简介
副本的目的主要是保障数据的高可用性,即使一台 ClickHouse 节点宕机,那么也可以从其他服务器获得相同的数据。
副本只支持合并数家族,支持的引擎如下:

2、副本写入流程

clickhouse集群没有主从之分
3、副本配置步骤
基于上次安装的一台服务器将其它两台安装好,具体操作如下:
04 - Clickhouse-21.7.3.14-2单机版安装
https://blog.csdn.net/K_520_W/article/details/143823561
3.1、启动zookeeper集群
zookeeper完全分布式安装部署
https://blog.csdn.net/K_520_W/article/details/99340192
3.2、在 hallo100 的/etc/clickhouse-server/config.d 目录下创建一个名为metrika.xml 的配置文件,内容如下:
<?xml version="1.0"?>
<yandex>
<zookeeper-servers>
<node index="1">
<host>hallo100</host>
<port>2181</port>
</node>
<node index="2">
<host>hallo101</host>
<port>2181</port>
</node>
<node index="3">
<host>hallo102</host>
<port>2181</port>
</node>
</zookeeper-servers>
</yandex>
将文件的所有者改为启动clickhouse的用户所有,并且配置相关的文件的所有者必须都是
[root@hallo102 clickhouse-server]# ll config.d/
总用量 4
-rw-r--r-- 1 root root 374 11月 23 18:01 metrika.xml
[root@hallo102 clickhouse-server]#
3.3、在 hallo100 的/etc/clickhouse-server/config.xml 中增加如下内容
<zookeeper incl="zookeeper-servers" optional="true" />
<include_from>/etc/clickhouse-server/config.d/metrika.xml</include_from>
3.4、以上的内容在其它两台服务器都需要配置一遍
3.5、重新启动3台clickhouse服务
4、测试副本
4.1、在所有服务器上分别建表
副本只能同步数据,不能同步表结构,所以我们需要在每台机器上自己手动建表
/* hallo100 */
create table t_order_rep2 (
id UInt32,
sku_id String,
total_amount Decimal(16,2),
create_time Datetime
) engine =ReplicatedMergeTree('/clickhouse/table/01/t_order_rep','rep_100')
partition by toYYYYMMDD(create_time)
primary key (id)
order by (id,sku_id);
/* hallo101 */
create table t_order_rep2 (
id UInt32,
sku_id String,
total_amount Decimal(16,2),
create_time Datetime
) engine =ReplicatedMergeTree('/clickhouse/table/01/t_order_rep','rep_101')
partition by toYYYYMMDD(create_time)
primary key (id)
order by (id,sku_id);
/* hallo102 */
create table t_order_rep2 (
id UInt32,
sku_id String,
total_amount Decimal(16,2),
create_time Datetime
) engine =ReplicatedMergeTree('/clickhouse/table/01/t_order_rep','rep_102')
partition by toYYYYMMDD(create_time)
primary key (id)
order by (id,sku_id);
ReplicatedMergeTree 中,第一个参数是分片的 zk_path 一般按照: /clickhouse/table/{shard}/{table_name} 的格式写,如果只有一个分片就写 01 即可。
第二个参数是副本名称,相同的分片副


6513

被折叠的 条评论
为什么被折叠?



