业务背景
将hive中多个表数据同步到clickhouse中提供实时查询,表均2亿条记录。对同步工具的要求一是能够实现抽数时间不宜过长;二是能够自定义控制将数据抽取到clickhouse集群指定的节点实例上。作为一名java开发,自然不想过多依赖Hadoop那一套,网上搜索一番后决定使用seatunnel,通过简单配置化就可以实现数据的抽取。
简介
Apache SeaTunnel (Incubating) 是一个分布式、高性能、易扩展、用于海量数据(离线&实时)同步和转化的数据集成平台。
官方文档:https://interestinglab.github.io/seatunnel-docs/#/
安装
安装比较简单,参考官方文档即可。
配置
config.conf 下述配置是从hive中抽数插入到clickhouse中的配置,数据源是hive的一张表,通过seatunnel插件根据id字段进行分片插入clickhouse集群不同分片。
spark {
spark.sql.catalogImplementation = "hive"
spark.app.name = "hive2clickhouse"
spark.executor.instances = 30
spark.executor.cores = 1
spark.executor.memory = "2g"
spark.ui.port = 13000
}
input {
hive {
pre_sql = "select id,name,create_time from table"
table_name = "table_tmp"
}
}
filter {
convert {
source_field = "data_source"
new_type = "UInt8"
}
org.interestinglab.waterdrop.filter.Slice {
source_table_name = "table_tmp"
source_field = "id"
slice_num = 2
slice_code = 0
result_table_name = "table_8123"
}
org.interestinglab.waterdrop.filter.Slice {
source_table_name = "table_tmp"
source_field = "id"
slice_num = 2
slice_code = 1
result_table_name = "table_8124"

本文介绍了如何利用Apache SeaTunnel进行大数据实时迁移,将Hive中的2亿条记录同步到Clickhouse,以提供实时查询。通过配置Seatunnel,实现了按id字段分片插入Clickhouse集群,确保了数据抽取效率,并详细展示了配置文件和自定义过滤器的代码。整个过程旨在避免过多依赖Hadoop,简化数据同步流程。
最低0.47元/天 解锁文章
3515





