create table default.kafka_table_local ON CLUSTER default (
id Int32,
age UInt32,
msg String
) ENGINE = ReplicatedMergeTree(
'/clickhouse/tables/kafka_sink_table/{shard}',
'{replica}')
ORDER BY (id);
创建分布式表。
CREATE TABLE kafka_table_distributed ON CLUSTER default AS default.kafka_table_local
ENGINE = Distributed(default, default, kafka_table_local, id);
创建view把Kafka消费表消费到的数据导入ClickHouse目的表。
CREATE MATERIALIZED VIEW consumer TO kafka_table_distributed AS SELECT * FROM kafka_src_table;