安装目标
- 部署 SeaTunnel Engine 分离模式集群
- 部署Prometheus和Grafana
环境说明
- CentOS Linux release 7.4.1708 x86_64
- SeaTunnel 2.3.9
- jdk-8u371-linux-x64
部署规划
# | ip | 角色 |
---|---|---|
1 | 10.61.26.16 | Master(负责作业调度、RESTful API、任务提交、存储Imap数据)、Client |
2 | 10.61.26.17 | worker(负责任务执行) |
3 | 10.61.26.18 | worker(负责任务执行) |
4 | 10.58.41.27 | Prometheus+Grafana |
SeaTunnel安装步骤
准备工作
安装JDK
#1、#2、#3 机器执行
mkdir -p /opt/yeyouluo/soc/
tar -zxvf jdk-8u371-linux-x64.tar.gz -C /opt/yeyouluo/soc/
echo '' >> /etc/profile
echo '# JDK环境' >> /etc/profile
echo "export JAVA_HOME=/opt/yeyouluo/soc/jdk1.8.0_371" >> /etc/profile
echo 'export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar' >> /etc/profile
echo 'export PATH=$JAVA_HOME/bin:$PATH' >> /etc/profile
source /etc/profile
下载SeaTunnel
#1、#2、#3 机器执行
cd /data01/tools/
export version="2.3.9"
wget "https://archive.apache.org/dist/seatunnel/${version}/apache-seatunnel-${version}-bin.tar.gz"
tar -xzvf "apache-seatunnel-${version}-bin.tar.gz" -C /opt/yeyouluo/soc/
cd /opt/yeyouluo/soc/
mv apache-seatunnel-${version} seatunnel
准备连接器插件
#1、#2、#3 机器执行
在开发机器准备好连接器插件,上传到 目录
/opt/yeyouluo/soc/seatunnel/connectors
- 在开发机也下载好相同的版本,可以通过配置
config/plugin_config
来指定所需的插件。 sh bin/install-plugin.sh
- 在开发机也下载好相同的版本,可以通过配置
验证:
shellcd /opt/yeyouluo/soc/seatunnel bin/seatunnel-connector.sh -l
预期输出如下:
shell# bin/seatunnel-connector.sh -l Transform Copy DynamicCompile FieldMapper Filter FilterRowKind JsonPath Metadata Embedding LLM FieldRename TableRename Replace RowKindExtractor Split Sql TableMerge Sink Elasticsearch FtpFile S3File Redis Console LocalFile Http SftpFile Kafka Clickhouse ClickhouseFile Jdbc Source Elasticsearch FakeSource FtpFile S3File Redis LocalFile Http SftpFile Kafka Clickhouse MySQL-CDC Jdbc
配置 SEATUNNEL_HOME
#1、#2、#3 、#4 机器执行(如果#4不配置,则SeaTunnel web会报错 SEATUNNEL_HOME 变量不存在)
添加 /etc/profile.d/seatunnel.sh
文件来配置 SEATUNNEL_HOME
。/etc/profile.d/seatunnel.sh
的内容如下:
cat<<'EOF'>/etc/profile.d/seatunnel.sh
export SEATUNNEL_HOME=/opt/yeyouluo/soc/seatunnel
export PATH=$PATH:$SEATUNNEL_HOME/bin
EOF
预期:
source /etc/profile.d/seatunnel.sh
echo $SEATUNNEL_HOME
配置 Master 节点 JVM 选项
Master节点的JVM参数在
$SEATUNNEL_HOME/config/jvm_master_options
文件中配置。#1 机器执行
shell# JVM Heap -Xms2g -Xmx2g # JVM Dump -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/opt/yeyouluo/soc/seatunnel/dump/zeta-server # Metaspace -XX:MaxMetaspaceSize=2g # G1GC -XX:+UseG1GC
Worker节点的JVM参数在
$SEATUNNEL_HOME/config/jvm_worker_options
文件中配置。worker
节点共有2台,均需修改。#2、#3 机器执行。shell# JVM Heap -Xms2g -Xmx2g # JVM Dump -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/opt/yeyouluo/soc/seatunnel/dump/zeta-server # Metaspace -XX:MaxMetaspaceSize=2g # G1GC -XX:+UseG1GC
配置 SeaTunnel Engine
在
seatunnel.yaml
中进行配置。
修改checkpoint storage
在 #1 master节点修改(其他worker主机也可以修改,但不会生效)
yamlseatunnel: engine: checkpoint: interval: 10000 timeout: 60000 storage: type: hdfs max-retained: 3 plugin-config: storage.type: hdfs fs.defaultFS: file:///opt/yeyouluo/soc/seatunnel/checkpoint
类加载器类加载器缓存模式
#1、#2、#3 机器执行。当运行作业中使用的 Source/Sink 连接器类型不是太多时,更为有效。
yamlseatunnel: engine: classloader-cache-mode: true
IMap持久化配置
#1、#2、#3 机器执行。但worker无效。
TODO
使用telemtry
仅 master需要更改
yamltelemetry: metric: enabled: true
最后,完整的配置文件
seatunnel.yaml
如下:yamlseatunnel: engine: classloader-cache-mode: true history-job-expire-minutes: 1440 backup-count: 1 queue-type: blockingqueue print-execution-info-interval: 60 print-job-metrics-info-interval: 60 slot-service: dynamic-slot: true checkpoint: interval: 10000 timeout: 60000 storage: type: hdfs max-retained: 3 plugin-config: storage.type: hdfs fs.defaultFS: file:///opt/yeyouluo/soc/seatunnel/checkpoint telemetry: metric: enabled: true log: scheduled-deletion-enable: true http: enable-http: true port: 8080 enable-dynamic-port: false
配置 SeaTunnel Engine 网络服务
所有 SeaTunnel Engine 网络相关的配置都在
hazelcast-master.yaml
和hazelcast-worker.yaml
文件中.
Master节点网络配置 hazelcast-master.yaml
:
hazelcast:
cluster-name: seatunnel
network:
rest-api:
enabled: true
endpoint-groups:
CLUSTER_WRITE:
enabled: true
DATA:
enabled: true
join:
tcp-ip:
enabled: true
member-list:
- 10.61.26.16:5801
- 10.61.26.17:5802
- 10.61.26.18:5802
port:
auto-increment: false
port: 5801
properties:
hazelcast.invocation.max.retry.count: 20
hazelcast.tcp.join.port.try.count: 30
hazelcast.logging.type: log4j2
hazelcast.operation.generic.thread.count: 50
hazelcast.heartbeat.failuredetector.type: phi-accrual
hazelcast.heartbeat.interval.seconds: 2
hazelcast.max.no.heartbeat.seconds: 180
hazelcast.heartbeat.phiaccrual.failuredetector.threshold: 10
hazelcast.heartbeat.phiaccrual.failuredetector.sample.size: 200
hazelcast.heartbeat.phiaccrual.failuredetector.min.std.dev.millis: 100
Worker节点网络配置 hazelcast-worker.yaml
:
hazelcast:
cluster-name: seatunnel
network:
join:
tcp-ip:
enabled: true
member-list:
- 10.61.26.16:5801
- 10.61.26.17:5802
- 10.61.26.18:5802
port:
auto-increment: false
port: 5802
properties:
hazelcast.invocation.max.retry.count: 20
hazelcast.tcp.join.port.try.count: 30
hazelcast.logging.type: log4j2
hazelcast.operation.generic.thread.count: 50
hazelcast.heartbeat.failuredetector.type: phi-accrual
hazelcast.heartbeat.interval.seconds: 2
hazelcast.max.no.heartbeat.seconds: 180
hazelcast.heartbeat.phiaccrual.failuredetector.threshold: 10
hazelcast.heartbeat.phiaccrual.failuredetector.sample.size: 200
hazelcast.heartbeat.phiaccrual.failuredetector.min.std.dev.millis: 100
配置作业生成单独的日志文件
要为每个作业输出单独的日志文件,您可以更新 log4j2.properties
文件中的以下配置:
...
rootLogger.appenderRef.file.ref = routingAppender
...
appender.file.layout.pattern = %d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%-30.30c{1.}] [%t] - %m%n
...
此配置为每个作业生成单独的日志文件,例如:
job-xxx1.log
job-xxx2.log
job-xxx3.log
...
启停 SeaTunnel Engine
启动master节点
#1 主机上操作
以通过守护进程使用 -d
参数启动。
mkdir -p $SEATUNNEL_HOME/{logs,dump,checkpoint}
./bin/seatunnel-cluster.sh -d -r master
日志将写入 $SEATUNNEL_HOME/logs/seatunnel-engine-master.log
启动worker节点
#2 、#3主机上 操作
可以通过守护进程使用 -d
参数启动。
mkdir -p $SEATUNNEL_HOME/{logs,dump,checkpoint}
./bin/seatunnel-cluster.sh -d -r worker
日志将写入 $SEATUNNEL_HOME/logs/seatunnel-engine-worker.log
查看状态
ss -lunpt | grep 58
停止
在master(#1)机器上执行:
$SEATUNNEL_HOME/bin/stop-seatunnel-cluster.sh
配置 SeaTunnel Client
在 #1、#2、#3 主机上进行
修改
hazelcast-client.yaml
。cluster-name
与 SeaTunnel Engine 具有相同的cluster-name
;network需要将所有 SeaTunnel Engine Master节点的地址添加到这里。yamlhazelcast-client: cluster-name: seatunnel properties: hazelcast.logging.type: log4j2 connection-strategy: connection-retry: cluster-connect-timeout-millis: 3000 network: cluster-members: - 10.61.26.16:5801
提交作业
./bin/seatunnel.sh --config $SEATUNNEL_HOME/config/v2.batch.config.template --async -n first_jobls
第一次提交后,失败了,重新提交问题不再复现。
SeaTunnel 监控配置
Prometheus配置
#4 主机上操作
#4 上安装Prometheus,过程略。
#4 上,将 SeaTunnel 实例指标导出添加到
/etc/prometheus/prometheus.yml
yamlglobal: scrape_interval: 15s scrape_configs: - job_name: 'seatunnel' scrape_interval: 5s metrics_path: /hazelcast/rest/instance/metrics static_configs: - targets: [ '10.61.26.16:5801' ]
重启Prometheus :
cd /opt/yeyouluo/soc/docker-apps/prometheus/
docker compose restart prometheus
配置Grafana
问题:导入Grafana模板后,监控页面没有正确显示。
原因:Grafana JSON模板不对。
解决办法如下:
- 从源码中拉取最新的json:https://github.com/apache/seatunnel/blob/2.3.8-release/docs/zh/seatunnel-engine/telemetry/grafana-dashboard.json
- 将json中的 promethus id 都替换为 正确的id(正确的id可以从其他监控中去找)
SeaTunnel运维
命令行工具
具体参考 https://seatunnel.apache.org/zh-CN/docs/2.3.9/seatunnel-engine/user-command
查看作业列表
./bin/seatunnel.sh -l
该命令会输出所有当前集群中的作业列表(包含运行完成的历史作业和正在运行的作业)
查看作业状态
./bin/seatunnel.sh -j <jobId>
该命令会输出指定作业的状态信息
获取正在运行的作业监控信息
./bin/seatunnel.sh --get_running_job_metrics
该命令会输出正在运行的作业的监控信息
获取指定作业监控信息
--metrics
参数可以获取指定作业的监控信息
./bin/seatunnel.sh --metrics <jobId>
暂停作业
./bin/seatunnel.sh -s <jobId>
该命令会暂停指定作业,注意,只有开启了checkpoint的作业才支持暂停作业(实时同步作业默认开启checkpoint,批处理作业默认不开启checkpoint需要通过在 env
中配置checkpoint.interval来开启checkpoint)。
暂停作业是以split为最小单位的,即暂停作业后,会等待当前正在运行的split运行完成后再暂停。任务恢复后,会从暂停的split继续运行。
恢复作业
./bin/seatunnel.sh -r <jobId> -c $SEATUNNEL_HOME/config/v2.batch.config.template
该命令会恢复指定作业,注意,只有开启了checkpoint的作业才支持恢复作业(实时同步作业默认开启checkpoint,批处理作业默认不开启checkpoint需要通过在 env
中配置checkpoint.interval来开启checkpoint)。
恢复作业需要指定jobId和作业的配置文件。
运行失败的作业和通过 seatunnel.sh -s <jobId>
暂停的作业都可以通过该命令恢复。
取消作业
./bin/seatunnel.sh -can <jobId1> [<jobId2> <jobId3> ...]
该命令会取消指定作业,取消作业后,作业会被停止,作业的状态会变为 CANCELED
。
支持批量取消作业,可以一次取消多个作业。
被cancel的作业的所有断点信息都将被删除,无法通过 seatunnel.sh -r <jobId>
恢复。
RESTful API
具体参考 https://seatunnel.apache.org/zh-CN/docs/2.3.8/seatunnel-engine/rest-api
返回Zeta集群的概览
shellcurl -XGET http://10.61.26.16:5801/hazelcast/rest/maps/overview
返回当前节点的线程堆栈信息
shellcurl -XGET http://10.61.26.16:5801/hazelcast/rest/maps/thread-dump
返回所有作业及其当前状态的概览
shellcurl -XGET http://10.61.26.16:5801/hazelcast/rest/maps/running-jobs
返回作业的详细信息
shellcurl -XGET http://10.61.26.16:5801/hazelcast/rest/maps/job-info/:jobId # 例如 curl -XGET http://10.61.26.16:5801/hazelcast/rest/maps/job-info/908974689525694470
返回所有已完成的作业信息
shellcurl -XGET http://10.61.26.16:5801/hazelcast/rest/maps/finished-jobs/:state
state可以是
FINISHED
,CANCELED
,FAILED
,UNKNOWABLE
。返回系统监控信息
shellcurl -XGET http://10.61.26.16:5801/hazelcast/rest/maps/system-monitoring-information
提交作业
批量提交作业
停止作业
批量停止作业
加密配置
更新运行节点的tags
卸载
- 停止
$SEATUNNEL_HOME/bin/stop-seatunnel-cluster.sh
- 查看状态
ss -lunpt | grep 58