SeaTunnel Web 1.0.0 在Ubuntu环境的安装

SeaTunnel Web 在Ubuntu环境的安装

环境说明

  • SeaTunnel 2.3.3
  • SeaTunnel Web 1.0.0

注: SeaTunnel Web 1.0.0 暂未适配 SeaTunnel 2.3.4 。请注意版本匹配关系!

下载软件

下载SeaTunnel二进制文件
下载地址:https://seatunnel.apache.org/download/

  • apache-seatunnel-2.3.3-bin.tar.gz
  • apache-seatunnel-web-1.0.0-bin.tar.gz

安装配置 seatunnel

解压文件

解压文件:

tar -xvf apache-seatunnel-2.3.3-bin.tar.gz
mv apache-seatunnel-2.3.3-bin /opt/

下载连接器

连接器配置列表:
文件路径: apache-seatunnel-2.3.3/config/plugin_config

建议初始下载连接器:

--connectors-v2--
connector-cdc-mysql
connector-fake
connector-console
--end--

下载连接器插件:

bash bin/install-plugin.sh 
或:
./bin/install-plugin.sh 

注意: 不可以使用: sh bin/install-plugin.sh 以防解释器是 dash 而导致出错。
下载位置:
/opt/apache-seatunnel-2.3.3/connectors/seatunnel

注:

  1. 经测试,SeaTunnel 2.3.4 与 SeaTunnel 2.3.3 下载连接器路径不同
2.3.3 : connectors/seatunnel
2.3.4 : connectors/
  1. seatunnel web 1.0.0 将从 ${SEATUNNEL_HOME}/connectors/seatunnel 加载连接器插件.如果没有下载对应插件将导致配置任务时无法选择配置好的数据源。

下载数据库驱动

下载MySQL驱动并添加到lib目录
添加驱动:

cp mysql-connector-j-8.2.0.jar ${SEATUNNEL_HOME}/lib/
cp postgresql-42.7.2.jar ${SEATUNNEL_HOME}/lib/

注:从 Web 发起的数据库同步批任务将使用jdbc 方式连接。Seatunnel 如果没有对应驱动,任务执行将会连接失败。

测试SeaTunnel任务

运行示例任务:

cd apache-seatunnel-2.3.3
bash ./bin/seatunnel.sh --config ./config/v2.batch.config.template -e local

注: 如果你使用的是 SeaTunnel 2.3.4 ,因为seatunnel源码的问题,在Linux环境执行需要批量替换代码换行符为Unix格式

find <seatunnel_home 路径> -type f -print0 | xargs -0 dos2unix --

启动集群模式

创建日志目录:

mkdir /opt/apache-seatunnel-2.3.3/logs

启动:

bash ./bin/seatunnel-cluster.sh -d

安装配置 seatunnel web

解压文件

解压文件:

tar -xvf apache-seatunnel-web-1.0.0-bin.tar.gz
mv apache-seatunnel-web-1.0.0-bin /opt/

配置web元数据库

cd /opt/apache-seatunnel-web-1.0.0-bin
cat script/seatunnel_server_env.sh

配置数据库连接信息。
注:此账号需要有创建数据库权限

export HOSTNAME="127.0.0.1"
export PORT="3306"
export USERNAME="root"
export PASSWORD="123456"

安装MySQL客户端

sudo apt install mysql-client

后面初始化数据库脚本将使用:mysql 命令连接客户端,不安装好将会导致无法连接数据库。

测试数据库连接:

mysql -h 127.0.0.1 -P 3306 -u root -p

初始化数据库:

bash script/init_sql.sh

配置Web应用

配置文件路径:conf/application.yml

cat conf/application.yml

修改内容:

datasource:
    # driver-class-name: com.mysql.jdbc.Driver
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://192.168.8.101:3306/seatunnel?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&allowPublicKeyRetrieval=true
    username: root
    password: 123456

注意:其中MySQL驱动类需要和实际的驱动类修改一致。
Mysql 8.0 及以上版本需使用 : driver-class-name: com.mysql.cj.jdbc.Driver
Mysql 5.0 等较低版本需使用:driver-class-name: com.mysql.jdbc.Driver

注:

  1. 此步骤配置不正确,将导致无法在页面进行用户登录。
  2. seatunnel web 1.0.1 版本中,需配置密钥,否则同样无法登录:
jwt:
  secretKey: 40636f14629a75a2ef37d03aa1c0ec3f

密钥生成方法:openssl rand -hex 16

配置 JAVA_HOME

echo "export JAVA_HOME=/path/to/java" >> ~/.profile

配置 SEATUNNEL_HOME

推荐添加全局配置文件:/etc/profile.d/seatunnel.sh
也可以配置到用户配置文件:

echo "export SEATUNNEL_HOME=/opt/apache-seatunnel-2.3.3" >> ~/.profile
echo "export PATH=$SEATUNNEL_HOME/bin:$PATH" >> ~/.profile

配置 ST_WEB_BASEDIR_PATH

# Seatunnel Web
export ST_WEB_BASEDIR_PATH=/opt/apache-seatunnel-web-1.0.1-bin

注:

  1. seatunnel web 将根据此选项确定程序主目录。进一步基于此目录加载 datasource 文件夹位置。如不配置可导致无法创建数据源。

添加MySQL驱动

下载数据库驱动并添加到lib目录

cp mysql-connector-j-8.2.0.jar apache-seatunnel-web-1.0.0-bin/libs/
cp postgresql-42.7.2.jar apache-seatunnel-web-1.0.0-bin/libs/

注:

  1. 不添加Mysql驱动将导致无法连接元数据库
  2. 不添加其他数据库驱动将导致无法创建对应数据库类型的数据源

下载 datasource 到Web

下载或编写 download_datasource.sh
下载地址: https://seatunnel.apache.org/assets/files/download_datasource-4b79e6fafe80459590a6a0fc2865e5ac.sh

注:seatunnel-web-1.0.1 已包含此文件请忽略
但是seatunnel-web-1.0.1 使用 mvnw 进行下载却缺少mvnw文件及相关配置,需要修改下载命令为:
wget https://repo.maven.apache.org/maven2/org/apache/seatunnel/${datasource}/${version}/${datasource}-${version}.jar -P $DATASOURCE_LIB_DIR

download_datasource.sh

#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

#This script is used to download the connector plug-ins required during the running process.
#All are downloaded by default. You can also choose what you need.
#You only need to configure the plug-in name in config/plugin_config.

# get seatunnel web home
SEATUNNEL_WEB_HOME=$(cd $(dirname $0);pwd)

DATASOURCE_LIB_DIR=${SEATUNNEL_WEB_HOME}/../libs

# the datasource default version is 1.0.0, you can also choose a custom version. eg: 1.1.2:  sh install-datasource.sh 2.1.2
version=1.0.0

if [ -n "$1" ]; then
    version="$1"
fi

# If you do not want to download a certain data source, you can delete the element below
datasource_list=(
  "datasource-plugins-api"
  "datasource-elasticsearch"
  "datasource-hive"
  "datasource-jdbc-clickhouse"
  "datasource-jdbc-hive"
  "datasource-jdbc-mysql"
  "datasource-jdbc-oracle"
  "datasource-jdbc-postgresql"
  "datasource-jdbc-redshift"
  "datasource-jdbc-sqlserver"
  "datasource-jdbc-starrocks"
  "datasource-jdbc-tidb"
  "datasource-kafka"
  "datasource-mysql-cdc"
  "datasource-s3"
  "datasource-sqlserver-cdc"
  "datasource-starrocks"
)

echo "Downloading SeaTunnel Web Datasource lib, usage version is ${version}"

for datasource in "${datasource_list[@]}"
do
    echo "Downloading datasource: ${datasource}"
  wget  https://repo.maven.apache.org/maven2/org/apache/seatunnel/${datasource}/${version}/${datasource}-${version}.jar -P $DATASOURCE_LIB_DIR
done

文件放置路径:

cp download_datasource.sh  apache-seatunnel-web-1.0.0-bin/bin/

下载连接器:

bash bin/download_datasource.sh 

下载路径:

${SEATUNNEL_WEB_HOME}/libs/

注:

  1. 此步骤不执行将导致SeaTunnel Web 无法在页面配置添加数据源
  2. 在 seatunnel web 1.0.1 版本中默认下载目录为:
${SEATUNNEL_WEB_HOME}/datasource/

复制连接器映射配置文件

映射文件在seatunnel安装目录下

cp ${SEATENNEL_HOME}/connectors/plugin-mapping.properties ${SEATUNNEL_WEB_HOME}/conf/

注:此文件用于配置 seatunnel 连接器与任务执行配置时 source 或 sink 的对应关系.
不执行此步骤将导致创建数据源后无法选择数据源。

检查 seatunnel web connect 插件的目录

默认 seatunnel web connect 插件 是从:

$SEATUNNEL_HOME/connectors/seatunnel

而根据seatunnel版本不同,默认下载的connectors并不一定在该目录下。
因此,可能需要手动创建该目录,并复制connectors文件到该目录下。
否则可导致创建数据源后,在创建任务时无法选择数据源。

注意:目前seatunnel web 对 seatunnel 的各版本兼容情况有很大差异,不建议放很多connectors 到目录中,否则可能导致
seatunnel web 无法启动。

启动web服务

bash bin/seatunnel-backend-daemon.sh start

注:

  1. 启动失败原因:1)seatunnel 集群模式未正常启动,服务连接不到集群。2)缺少 mysql 驱动无法连接元数据库。

页面登录

页面访问:

localhost:8801/

默认账号:

user: admin
password: admin

测试使用

添加数据源

添加 mysql 数据源:

jdbc:mysql://192.168.8.101:3306/test

添加 postgresql 数据源:

jdbc:postgresql://192.168.8.101:5432/test

注:此处容易出现错误。

  1. 无可选数据源类型。原因:未下载 datasource,或未放置正确位置。解决方法:参考上面步骤:下载 datasource 到Web
  2. 选择数据源后,无法测试通过。原因:未下载 对应数据库JDBC 驱动并添加到 libs 目录。解决方法:下载 mysql 或 pg 驱动添加在 web 的 libs 目录,然后重启web服务。

添加 Mysql CDC 数据源:

jdbc:mysql://192.168.8.101:3306/test

image
注:

  1. 经实验官方说明与示例存在错误。cdc 的 jdbc 连接需填写 database 名。否则会报base url连接错误。
    image
    image
    image

添加JDBC同步任务

源端配置:
image
注:

  1. 此处易出现配置好数据源后,这里无法选择。可能原因: 1)未配置环境变量 ST_WEB_BASEDIR_PATH,程序无法加载到datasource文件夹下内容。2)未复制连接器映射配置文件 plugin-mapping.properties 到 web 的 conf 目录,程序无法正确匹配连接器与连接类型(source/sink)对应关系。3)seatunnel connect 插件(非 seatunnel web datasource )未下载或目录错误,加载不到对应连接器文件。默认路径为:$SEATUNNEL_HOME/connectors/seatunnel

目标端配置:
image

任务设置:
image
注:当源端为 JDBC 数据源,即使配置为流模式,也会很快结束,因为不是 CDC 连接器。

任务执行:
image
image

注:

  1. 此处易出现错误找不到数据库驱动。原因:mysql ,pg 等的数据库连接驱动需要添加到 seatunnel 的 lib 目录下,并重启集群。

测试 CDC 任务

创建 source:
image

创建 sink:
image
image

设置任务:
image

执行任务:
image

异常处理

找不到类:CopyOnWriteHashMap

报错内容:

Caused by: java.lang.NoClassDefFoundError: com/sun/jersey/client/impl/CopyOnWriteHashMap
	at org.apache.seatunnel.engine.server.checkpoint.CheckpointPlan$Builder.<init>(CheckpointPlan.java:66)
	at org.apache.seatunnel.engine.server.checkpoint.CheckpointPlan$Builder.<init>(CheckpointPlan.java:63)
	at org.apache.seatunnel.engine.server.checkpoint.CheckpointPlan.builder(CheckpointPlan.java:35)
	at org.apache.seatunnel.engine.server.dag.physical.PhysicalPlanGenerator.lambda$generate$0(PhysicalPlanGenerator.java:193)
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1384)
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
	at org.apache.seatunnel.engine.server.dag.physical.PhysicalPlanGenerator.generate(PhysicalPlanGenerator.java:214)
	at org.apache.seatunnel.engine.server.dag.physical.PlanUtils.fromLogicalDAG(PlanUtils.java:61)
	at org.apache.seatunnel.engine.server.master.JobMaster.init(JobMaster.java:215)
	at org.apache.seatunnel.engine.server.CoordinatorService.lambda$submitJob$5(CoordinatorService.java:461)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:750)

类似问题:https://github.com/apache/seatunnel/issues/4971
解决办法:
下载地址:https://repo.maven.apache.org/maven2/org/apache/seatunnel/seatunnel-hadoop3-3.1.4-uber/2.3.3/
下载文件:seatunnel-hadoop3-3.1.4-uber-2.3.3-optional.jar
添加文件到:apache-seatunnel-2.3.3/lib/

mv seatunnel-hadoop3-3.1.4-uber-2.3.3-optional.jar apache-seatunnel-2.3.3/lib/

重启 seatunnel web

xa_data_source_class_name 问题

在 sink 中,如果选择数据源为:postgresql ,且配置需要保证数据一致性时,则需要配置:xa_data_source_class_name
image
值应当为:org.postgresql.xa.PGXADataSource
image

posted @   葵花牌、阳光  阅读(472)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· 【.NET】调用本地 Deepseek 模型
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库
· 上周热点回顾(2.17-2.23)
· 如何使用 Uni-app 实现视频聊天(源码,支持安卓、iOS)
点击右上角即可分享
微信分享提示