Seatunnel的部署和使用
Seatunnel是一个非常易用、高性能、支持实时流式和离线批处理的海量数据集成平台。接下来我给大家讲讲如何使用和部署seatunnel。
1.下载seatunnel
wget https://archive.apache.org/dist/incubator/seatunnel/2.3.1/apache-seatunnel-incubating-2.3.1-bin.tar.gz
2.配置seatunnel插件
在原有的plugin_config中存在着很多插件,但下载速度很慢,所以这边建议挑选自己需要的插件下载
vim config/plugin_config
--connectors-v2--
connector-assert
connector-cdc-mysql
connector-jdbc
connector-fake
connector-console
--end--
3.安装seatunnel插件
sh bin/install-plugin.sh
4.编写json文件
根据自己的需要编写,下面有两个例子,分别是mysql to mysql离线批处理,和mysql实时流模式的模版。
4.1mysql to mysql离线批处理
env {
job.mode="STREAMING"
job.name="SeaTunnel_Job"
checkpoint.interval=10000
}
source {
Jdbc {
url="jdbc:mysql://127.0.0.1:3306/wtinfo"
driver = "com.mysql.cj.jdbc.Driver"
connection_check_timeout_sec = 100
user = "root"
password = "12345"
query = "select * from s1"
partition_num = 10
}
}
sink {
Jdbc {
primary_keys = ["id"]
password="12345"
driver="com.mysql.cj.jdbc.Driver"
user=root
query = "insert into s1 values(?,?,?,?,?,?)"
url="jdbc:mysql://127.0.0.1:3306/wtinfo_test?enabledTLSProtocols=TLSv1.2&rewriteBatchedStatements=true"
}
}
4.2mysql to mysql 流模式
env {
job.mode="STREAMING"
job.name="SeaTunnel_Job"
checkpoint.interval=10000
}
source {
MySQL-CDC {
base-url="jdbc:mysql://127.0.0.1:3306/wtinfo"
username= "root"
password = "12345"
table-names = ["wtinfo.test"]
server-id = 1
}
}
sink {
Jdbc {
primary_keys = ["name"]
password="12345"
driver="com.mysql.cj.jdbc.Driver"
user=root
query = "insert into test values(?,?)"
url="jdbc:mysql://127.0.0.1:3306/wtinfo_test?enabledTLSProtocols=TLSv1.2&rewriteBatchedStatements=true"
}
}
5.执行seatunnel任务
bin/seatunnel.sh --config job/test.config.CDC -e local
运行seatunnel,--config后为配置的json文件
其他的插件不在这里一一展示,大家可以根据需要官网信息配置json。
官网:https://seatunnel.apache.org/