关于数据库:3-分钟部署-SeaTunnel-Zeta-单节点-Standalone-模式环境

5次阅读

共计 3867 个字符,预计需要花费 10 分钟才能阅读完成。

部署环境(MacOS/Linux)

1. 装置 JDK 环境

目前 SeaTunnel 反对运行在 JDK8 及以上的环境。用户须要自行装置 JDK 环境。

2. 下载安装包

目前 SeaTunnel 的最新版本是 2.3.1 版本。这里咱们装置部署 2.3.1 版本,如果你须要下载其它版本,能够从 https://seatunnel.apache.org/download 中查问对应的版本。

mkdir ~/seatunnel
cd ~/seatunnel
wget https://dlcdn.apache.org/incubator/seatunnel/2.3.1/apache-seatunnel-incubating-2.3.1-bin.tar.gz
tar -zxvf apache-seatunnel-incubating-2.3.1-bin.tar.gz

3. 抉择须要的插件

SeaTunnel 的安装包中默认不蕴含同步数据须要的连接器插件,用户须要先编辑 config 目录下的 plugin_config 文件,这个文件中形容了须要下载和装置的连接器插件,默认所有曾经反对的连接器插件都会下载和装置。咱们能够批改该文件,删除咱们不须要的插件,只保留咱们须要的插件。

cd ~/seatunnel/apache-seatunnel-incubating-2.3.1
vi config/plugin_config 

而后批改内容,本次我只须要 JDBC,MySQL CDC,StarRocks,Assert,Fake,Console 这 6 个连接器,其它的删除,最终文件内容如下:

--connectors-v2--
connector-assert
connector-cdc-mysql
connector-jdbc
connector-starrocks
connector-fake
connector-console
--end--

4. 运行下载安装命令

上面咱们运行连接器下载安装命令,留神,这一步依赖你的机器上曾经装置部署了 Maven 并且机器能够连贯互联网,你能够通过如下命令确认是否装置了 Maven:

mvn

如果显示如下信息,阐明 Maven 环境曾经装置部署好了,如果呈现问题报错,请先装置部署或修复 Maven 的问题再进行上面的部署。

Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /Users/gaojun/app/apache-maven-3.6.3
Java version: 1.8.0_181, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "mac os x", version: "10.16", arch: "x86_64", family: "mac"

运行下载安装连接器插件的命令:

cd ~/seatunnel/apache-seatunnel-incubating-2.3.1
sh bin/install-plugin.sh 

期待命令执行实现,连接器插件即下载安装实现。装置实现后可见~/seatunnel/apache-seatunnel-incubation-2.3.1/connectors/seatunnel/ 目录下曾经有了装置好的连接器插件。

5. 启动一个单节点的 SeaTunnel Zeta 节点

cd ~/seatunnel/apache-seatunnel-incubating-2.3.1
nohup sh bin/seatunnel-cluster.sh 2>&1 &

通过 jps 命令咱们能查看过程是否曾经启动,过程名为 SeaTunnelServer

jps

6. 运行自带的离线批同步 demo 工作

在 config 目录下有一个自带的离线批同步工作的配置文件 v2.batch.config.template,该文件定义了一个作业,应用一个叫 FakeSource 的 Source 连接器生成数据,并将数据发送给 Console 这个 Sink,Console Sink 的作用是将接管到的数据打印到控制台。

所以运行该作业能够看到在控制台中会打印数据,一共有 32 行数据将被打印,每条数据有两个字段 (name, age)。v2.batch.config.template 文件的内容如下:

env {
  # You can set SeaTunnel environment configuration here
  execution.parallelism = 2
  job.mode = "BATCH"
  checkpoint.interval = 10000
  #execution.checkpoint.interval = 10000
  #execution.checkpoint.data-uri = "hdfs://localhost:9000/checkpoint"
}

source {
  # This is a example source plugin **only for test and demonstrate the feature source plugin**
  FakeSource {
    parallelism = 2
    result_table_name = "fake"
    row.num = 16
    schema = {
      fields {
        name = "string"
        age = "int"
      }
    }
  }

  # If you would like to get more information about how to configure Seatunnel and see full list of source plugins,
  # please go to https://seatunnel.apache.org/docs/category/source-v2
}

sink {Console {}

  # If you would like to get more information about how to configure Seatunnel and see full list of sink plugins,
  # please go to https://seatunnel.apache.org/docs/category/sink-v2
}

执行该 demo 作业:

cd ~/seatunnel/apache-seatunnel-incubating-2.3.1
sh bin/seatunnel.sh --config config/v2.batch.config.template

作业运行实现后可能看到如下监控信息:

7. 运行自带的实时同步 demo 作业

在 config 目录下有一个自带的实时同步工作的配置文件 v2.streaming.conf.template,该文件定义了一个作业,应用一个叫 FakeSource 的 Source 连接器生成数据,并将数据发送给 Console 这个 Sink,Console Sink 的作用是将接管到的数据打印到控制台。

所以运行该作业能够看到在控制台中会打印数据,因为是实时作业,该作业不会主动进行,v2.streaming.conf.template 文件的内容如下:

env {
  # You can set flink configuration here
  execution.parallelism = 2
  job.mode = "STREAMING"
  checkpoint.interval = 2000
  #execution.checkpoint.interval = 10000
  #execution.checkpoint.data-uri = "hdfs://localhost:9000/checkpoint"
}

source {
  # This is a example source plugin **only for test and demonstrate the feature source plugin**
  FakeSource {
    parallelism = 2
    result_table_name = "fake"
    row.num = 16
    schema = {
      fields {
        name = "string"
        age = "int"
      }
    }
  }

  # If you would like to get more information about how to configure Seatunnel and see full list of source plugins,
  # please go to https://seatunnel.apache.org/docs/category/source-v2
}

sink {Console {}

  # If you would like to get more information about how to configure Seatunnel and see full list of sink plugins,
  # please go to https://seatunnel.apache.org/docs/category/sink-v2
}

执行该 demo 作业:

cd ~/seatunnel/apache-seatunnel-incubating-2.3.1
sh bin/seatunnel.sh --config config/v2.streaming.conf.template

作业运行 1 分钟左右,应该可能看到如下监控信息:

阐明作业失常运行,通过 Control+ C 完结该作业,停止作业运行。

到此,SeaTunnel Zeta 部署并验证实现。

本文由 白鲸开源科技 提供公布反对!

正文完
 0