



Solution | Solution 1: Dual-Write -> Single-Write | Solution 2: Collective Consumption |
Approach | Create a new consumer group and set up a separate data import task on the TCHouse-C platform. | Share the connector's consumer group. The ClickHouse data import task essentially adds a consumer group and, together with the connector task, collectively consumes kafka data. |
Implementation Policy | Proactively migrate to avoid risks in advance. Actively start the ClickHouse kafka data import task during off-peak hours and decommission the ckafka connector. Operations during off-peak hours have controllable risks. | Migrate passively to prevent secondary failures. Prepare the SQL contingency plan for the ClickHouse kafka data import task in advance, and start the task after the connector fails. Create a new consumer group or use an existing consumer group on the kafka platform. After a connector failure or exception, create a kafka consumption table and generate a materialized view to import data on the TCHouse-C platform. |
Advantages | The links are independent and do not affect each other. Operations during off-peak hours have controllable risks. | Data will not be duplicated. Existing tasks remain unchanged for now, and business operations are unaffected in the short term. |
Disadvantages | Log data generated by dual writes may have minor duplicates. | Collective consumption carries a rebalance risk. If a topic has only a single partition, you cannot determine whether the clickhouse import task is functioning normally. Creating custom tables has high requirements. If a task is misconfigured, there is a risk of data loss. The consumer group information of the connector needs to be collected in advance. It is deeply hidden and has poor usability. The post-failure mitigation plan has low timeliness, and the scope of the failure impact is uncontrollable. The warehouse table may contain a small amount of duplicate data. |
Rollback Plan | - | Dual-write phase: If the outcome does not meet expectations, you can directly delete the kafka data import task on the TCHouse-C platform. Single-write phase: If the outcome does not meet expectations, you can restart the connector and delete the kafka data import task on the TCHouse-C platform. |
Fallback Plan | - | Deleting the kafka data import task on the TCHouse-C platform means deleting the kafka consumption tables and materialized views. Restart the ckafka connector task. |
-- 0 Query topic information imported to ClickHouse in ckafka-- 1 Create a Kafka engine table in ClickHouseCREATE TABLE kafka_table_qiang_test_1 ON CLUSTER default_cluster (key String,value String) ENGINE = KafkaSETTINGSkafka_broker_list = '10.0.x.x:9092',kafka_topic_list = 'qiang-test-mysql',kafka_group_name = 'cg_qiang-test-mysql_1',kafka_format = 'JSONEachRow', -- Select an appropriate format based on your data format, such as JSON, Avro, or CSV.kafka_num_consumers = 1, -- Adjust as needed.kafka_max_block_size = 65536,kafka_skip_broken_messages = 0; -- The default value is 0.-- 2 Create a target table for storing data.-- The Kafka engine table itself only consumes data and does not persist it. Therefore, you need to create a table for actually storing data.CREATE TABLE real_table_qiang_test_1 ON CLUSTER default_cluster (key String,value String) ENGINE = MergeTree()ORDER BY key;-- 3 Create a Materialized View to import data from the Kafka table into the actual table.CREATE MATERIALIZED VIEW view_to_real_table_qiang_test_1 ON CLUSTER default_cluster TO real_table_qiang_test_1 ASSELECTkey,valueFROM kafka_table_qiang_test_1;-- 4 Query data in ClickHouse when you start sending data to kafka.SELECT * FROM real_table_qiang_test_1;select count(1) from INFORMATION_SCHEMA.real_table_qiang_test_1 limit 5;-- 5 To pause the materialized view and stop data collectionDROP VIEW IF EXISTS view_to_real_table_qiang_test_1 ON CLUSTER default_cluster;SELECT name FROM system.tables WHERE name LIKE '%view_to_real_table_qiang_test_1%'; -- Verify that the deletion was successful.
Apakah halaman ini membantu?
Anda juga dapat Menghubungi Penjualan atau Mengirimkan Tiket untuk meminta bantuan.
masukan