clickhouse 创建分布式表

创建本地表

CREATE TABLE yh118 ON CLUSTER test
(
`@time` DateTime,
`@item_guid` String,
`@metric_name` LowCardinality(String),
`@alg_name` LowCardinality(String),
`value_boolean` Boolean,
`int64` Int64,
`Date` Date

)
ENGINE = ReplicatedMergeTree('/clickhouse/tables/{cluster}/{shard}/default/yh118', '{replica}')
PARTITION BY toYYYYMMDD(`@time`)
ORDER BY (`@time`, `@item_guid`, `@metric_name`)
再创建分布式表
CREATE TABLE dist_yh118 ON CLUSTER test  AS yh118 ENGINE = Distributed('test', 'default', 'yh118');

创建分布式表时,会在zookeeper上留一条q的记录,然后其他集群机器会去这条记录上同步表结构,然后创建
posted @ 2021-02-23 14:06  SH金刚狼  阅读(513)  评论(0编辑  收藏  举报