ClickHouse副本表和分布式表

1.在集群的每个机器上面建立本地表
1)方式一:在集群每台机器上运行代码

CREATE TABLE st_center.st_pc_office_all_user_retention_v1
(
    `apptypeid` String,
    `qid` String,
    `os` String,
    `ver` String,
    `type` String,
    `user_type` String,
    `install_day` UInt64,
    `dau` UInt64,
    `day1_dau` UInt64,
    `day2_dau` UInt64,
    `day3_dau` UInt64,
    `dt` String
)
ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/{table}', '{replica}')
PARTITION BY dt
ORDER BY (dt, qid, ver, os, type, user_type, apptypeid)
SETTINGS index_granularity = 8192;

2)方式二:一次性在集群每个机器上建立本地表

CREATE TABLE IF NOT EXISTS st_center.st_pc_office_all_user_retention_v1 ON CLUSTER default_cluster 
(
  ...
)
ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/{table}', '{replica}')
PARTITION BY dt
ORDER BY (dt, qid, ver, os, type, user_type, apptypeid)
SETTINGS index_granularity = 8192;

关键词:ON CLUSTER

  • [1] /clickhouse/tables/是一般性前缀
  • [2] {layer}-{shard}是分片识别符,同一个分片内的所有机器应该保持相同
  • [3] /cl
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值