点亮 ⭐️ Star · 照亮开源之路
https://github.com/apache/incubator-seatunnel
本文主要演示通过SeaTunnel-Engine运行同步任务,将 MySQL数据同步至Hive。当然,使用Flink、Spark操作也类似。(文末有视频教程)
第一步:环境准备
Java 8 或 11 并配置JAVA_HOME Git Maven
第二步:下载SeaTunnel并安装连接器
下载地址:https://seatunnel.apache.org/download/ 下载SeaTunnel并安装2.3.0版本 https://www.apache.org/dyn/closer.lua/incubator/seatunnel/2.3.0/apache-seatunnel-incubating-2.3.0-bin.tar.gz
第三步:创建测试数据
create table source_user(userid int(4) primary key not null auto_increment,username varchar(16) not null);
insert into source_user (username) values ("z3");insert into source_user (username) values ("l4");insert into source_user (username) values ("w5");
create table sink_user( userid int, username string);
第四步:运行作业
下载mysql驱动程序并放在 plugins/Jdbc/lib/目录下 MySQL驱动可以从这里下载:https://dev.mysql.com/downloads/connector/j/
目前版本Hive连接器需将以下包拷贝到 ./lib/ 目录下 hive-exec-x.x.x.jar 这个包可以从hive的lib目录下找到。 flink-shaded-hadoop-2-uber-x.x.x-xx.x.jar 这个包可以从这里下载:https://mvnrepository.com/artifact/org.apache.flink/flink-shaded-hadoop-2-uber
env {job.mode = "BATCH"}source {Jdbc {url = "jdbc:mysql://ctyun9/test?serverTimezone=GMT%2b8"driver = "com.mysql.cj.jdbc.Driver"user = "root"password = "123456"query = "select * from source_user"}}transform {}sink {Hive {table_name = "st.sink_user"metastore_uri = "thrift://localhost:9083"}}
通过./bin/seatunnel.sh 可以运行同步任务。 通过-e 可以执行运行模式 LOCAL为本地模式,会在本机启动一个SeaTunnel实例并提交任务运行,任务运行完成后会自动关闭实例 CLUSTER为集群模式,可以把任务提交到SeaTunnel集群。
./bin/seatunnel.sh -e LOCAL -c ./config/mysql_to_hive.conf
集群模式
Apache SeaTunnel

往期推荐
你这么可爱,点个赞吧!

文章转载自SeaTunnel,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




