暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

【Demo】使用 SeaTunnel 将数据从 Kafka 迁移到 Redis

SeaTunnel 2023-09-08
1150

第一步:下载

SeaTunnel2.3.1源码 

下载地址:https://seatunnel.apache.org/download

Idea中的目录结构


第二部:通过源码编译 Apache SeaTunnel

通过maven进行代码编译

编译命令

    mvn clean package -pl seatunnel-dist -am -Dmaven.test.skip=true
    复制

    编译单个模块命令

      mvn clean package -pl seatunnel-examples/seatunnel-engine-examples -am -Dmaven.test.skip=true -T 1C

      复制

      第三步:运行

      编译完通过SeaTunnelEngineExample类来运行

        public class SeaTunnelEngineExample {


        public static void main(String[] args)
        throws FileNotFoundException, URISyntaxException, CommandException {
        String configurePath = args.length > 0 ? args[0] : "/examples/fake_to_console.conf";
        String configFile = getTestConfigFile(configurePath);
        ClientCommandArgs clientCommandArgs = new ClientCommandArgs();
        clientCommandArgs.setConfigFile(configFile);
        clientCommandArgs.setCheckConfig(false);
        clientCommandArgs.setJobName(Paths.get(configFile).getFileName().toString());
        Change Execution Mode to CLUSTER to use client mode, before do this, you should start
        SeaTunnelEngineServerExample
        clientCommandArgs.setMasterType(MasterType.LOCAL);
        SeaTunnel.run(clientCommandArgs.buildCommand());
        }
        复制

        这样就运行成功啦!

        附上配置文件样例

          env {
          execution.parallelism = 2
          job.mode = "BATCH"
          }
          source {
          Jdbc {
          url = "jdbc:mysql://xxxxxx:3306/xxxxx"
          driver = "com.mysql.cj.jdbc.Driver"
          connection_check_timeout_sec = 100
          user = "root"
          password = "xxxxx"
          query = "select * from test"
          #partition_column = "id"
          #partition_num = 10
          }
          }
          sink {
          Redis {
          host = xxxxxx
          port = 6379
          key = "seatunnel_jdbc"
          data_type = list
          auth = "xxxxxx"
          }
          }
          复制

          运行结果

          常见问题

            java.lang.RuntimeException: Plugin PluginIdentifier{engineType='seatunnel', pluginType='source', pluginName='XXXX'} not found.
            复制

            这种报错是seatunnel-engine-examples模块缺少引用,在pom中引用下对应插件重新编译即可

              <dependency>
              <groupId>org.apache.seatunnel</groupId>
              <artifactId>connector-rabbitmq</artifactId>
              <version>${project.version}</version>
              </dependency>

              复制




                mvn clean package -pl seatunnel-dist -am -Dmaven.test.skip=true
                复制

                如果maven提示下载listenablefuture失败,可以通过链接

                (https://download.csdn.net/download/u010479989/87965702)下载

                版权声明:本文为CSDN博主「小灰灰__」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。

                原文链接:https://blog.csdn.net/u010479989/article/details/130868244



                Apache SeaTunnel





                Apache SeaTunnel 是一个分布式、高性能、易扩展、用于海量数据(离线&实时)同步和转化的数据集成平台

                仓库地址: 
                https://github.com/apache/seatunnel

                网址:
                https://seatunnel.apache.org/

                Apache SeaTunnel 下载地址:
                https://seatunnel.apache.org/download
                 
                衷心欢迎更多人加入!

                我们相信,在「Community Over Code」(社区大于代码)、「Open and Cooperation」(开放协作)、「Meritocracy」(精英管理)、以及「多样性与共识决策」等 The Apache Way 的指引下,我们将迎来更加多元化和包容的社区生态,共建开源精神带来的技术进步!


                我们诚邀各位有志于让本土开源立足全球的伙伴加入 SeaTunnel 贡献者大家庭,一起共建开源!

                提交问题和建议:
                https://github.com/apache/seatunnel/issues

                贡献代码:
                https://github.com/apache/seatunnel/pulls

                订阅社区开发邮件列表 : 
                dev-subscribe@seatunnel.apache.org

                开发邮件列表:
                dev@seatunnel.apache.org

                加入 Slack:
                https://join.slack.com/t/apacheseatunnel/shared_invite/zt-1kcxzyrxz-lKcF3BAyzHEmpcc4OSaCjQ

                关注 Twitter: 
                https://twitter.com/ASFSeaTunnel

                精彩推荐




                Apache SeaTunnel Connector 使用文档和使用案例有奖征稿来了!一起玩开源




                使用 Apache SeaTunnel 实现 Kafka Souce 解析复杂 Json 案例




                众望所归,Apache SeaTunnel Web UI 即将发布!



                点击在看点赞转发⭐️!


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

                评论