什么是 clickhouse 中的 `macros` 以及 clickhouse 中 `macros` 的用途?
What is `macros` in clickhouse and what is use of `macros` in clickhouse?
Clickhouse 中的 macros
是什么?
macros
在 Clickhouse 中的用例是什么?
<macros>
<cluster>MyFirstCluster</cluster>
<replica>chdw1-5</replica>
<shard>5</shard>
</macros>
配置中各个属性的含义是什么?
在配置中分配每个属性的最佳做法是什么?
它们用于复制引擎 ZK 路径。
CREATE TABLE table_name
(
EventDate DateTime,
CounterID UInt32,
UserID UInt32,
ver UInt16
) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{layer}-{shard}/table_name', '{replica}', ver)
PARTITION BY toYYYYMM(EventDate)
ORDER BY (CounterID, EventDate, intHash32(UserID))
SAMPLE BY intHash32(UserID)
每个CH节点都是独立的,不知道clustering/sharding/replication。
但是 Replicated* 引擎使用 ZK 路径进行复制(将自己标识为副本)。此 ZK 路径由宏呈现。
所以在你的情况下而不是
ReplicatedReplacingMergeTree('/clickhouse/{cluster}/tables/{shard}/table_name', '{replica}', ver)
现实中宏会被替换。
Clickhouse 中的 macros
是什么?
macros
在 Clickhouse 中的用例是什么?
<macros>
<cluster>MyFirstCluster</cluster>
<replica>chdw1-5</replica>
<shard>5</shard>
</macros>
配置中各个属性的含义是什么?
在配置中分配每个属性的最佳做法是什么?
它们用于复制引擎 ZK 路径。
CREATE TABLE table_name
(
EventDate DateTime,
CounterID UInt32,
UserID UInt32,
ver UInt16
) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{layer}-{shard}/table_name', '{replica}', ver)
PARTITION BY toYYYYMM(EventDate)
ORDER BY (CounterID, EventDate, intHash32(UserID))
SAMPLE BY intHash32(UserID)
每个CH节点都是独立的,不知道clustering/sharding/replication。
但是 Replicated* 引擎使用 ZK 路径进行复制(将自己标识为副本)。此 ZK 路径由宏呈现。
所以在你的情况下而不是
ReplicatedReplacingMergeTree('/clickhouse/{cluster}/tables/{shard}/table_name', '{replica}', ver)
现实中宏会被替换。