Dolphinscheduler集成Flink任务踩坑记录

1、关于Flink打包

flink任务编写完成,在本地运行调试正常后,我打包提交到Dolphinscheduler平台进行测试。运行后没多久就报错:

 [taskAppId=TASK-10-108-214]:[138] -  -> java.lang.NoClassDefFoundError: org/apache/flink/streaming/connectors/kafka/FlinkKafkaConsumer
		at com.bigdata.flink.FlinkKafka.main(FlinkKafka.java:30)
Caused by: java.lang.ClassNotFoundException: org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer

在这里插入图片描述
看日志详情,我们可以看到任务已经开始准备提交了,但是在环境里找不到FlinkKafkaConsumer。

flink run -m yarn-cluster -ys 1 -yjm 1G -ytm 2G -yqu default -p 1 -sae -c com.bigdata.flink.FlinkKafka flink-job/bigdata-flink.jar

我的打包方式是通过IDEA 菜单的Build Artfacts…打出的jar文件很小,而且依赖包也都没有被打进去。
于是换了一种方式:

  • 配置pom文件
<build>
        <!--<pluginManagement>-->
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>1.8</version>
                <executions>
                    <execution>
                        <id>add-source</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>src/main/scala</source>
                                <source>src/test/scala</source>
                            </sources>
                        </configuration>
                    </execution>
                    <execution>
                        <id>add-test-source</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-test-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>src/test/scala</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>net.alchim31.maven</groupId>
                <artifactId>scala-maven-plugin</artifactId>
                <version>3.1.5</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <scalaVersion>2.11.8</scalaVersion>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>utf-8</encoding>
                </configuration>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <appendAssemblyId>false</appendAssemblyId>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <archive>
                        <manifest>
                            <!-- 此处指定main方法入口的class -->
                            <mainClass>com.bigdata.flink.FlinkKafka</mainClass>
                        </manifest>
                    </archive>
                </configuration>

                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>assembly</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <!--</pluginManagement>-->
    </build>
  • 执行maven下的package命令;可以看到这种打包方式执行后的jar包里包含了所需的依赖包。
  • 在这里插入图片描述
  • 在这里插入图片描述

2、HADOOP_CLASSPATH环境变量配置

环境依赖的问题解决后,在执行中又出现了HADOOP_CLASSPATH环境变量的报错。

taskAppId=TASK-10-112-218]:[138] -  -> 
	------------------------------------------------------------
	 The program finished with the following exception:
	
	org.apache.flink.client.program.ProgramInvocationException: The main method caused an error: No Executor found. Please make sure to export the HADOOP_CLASSPATH environment variable or have hadoop in your classpath. For more information refer to the "Deployment" section of the official Apache Flink documentation.
		at org.apache.flink.client.program.PackagedProgram.callMainMethod(PackagedProgram.java:372)
		at org.apache.flink.client.program.PackagedProgram.invokeInteractiveModeForExecution(PackagedProgram.java:222)
		at org.apache.flink.client.ClientUtils.executeProgram(ClientUtils.java:114)
		at org.apache.flink.client.cli.CliFrontend.executeProgram(CliFrontend.java:812)
		at org.apache.flink.client.cli.CliFrontend.run(CliFrontend.java:246)
		at org.apache.flink.client.cli.CliFrontend.parseAndRun(CliFrontend.java:1054)
		at org.apache.flink.client.cli.CliFrontend.lambda$main$10(CliFrontend.java:1132)
		at org.apache.flink.runtime.security.contexts.NoOpSecurityContext.runSecured(NoOpSecurityContext.java:28)
		at org.apache.flink.client.cli.CliFrontend.main(CliFrontend.java:1132)
	Caused by: java.lang.IllegalStateException: No Executor found. Please make sure to export the HADOOP_CLASSPATH environment variable or have hadoop in your classpath. For more information refer to the "Deployment" section of the official Apache Flink documentation.

这次需要修改worker所在节点的flink文件。

  • 找到 flink/bin/flink文件
  • 在第一行加入
export HADOOP_CLASSPATH=`hadoop classpath`
  • 在这里插入图片描述
  • 无需重启集群机器,直接重跑flink任务即可。
  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: DolphinScheduler是一个分布式的开源任务调度系统,它支持多种任务类型,包括Shell、Python、Spark、Flink等,可以实现任务的定时调度、依赖关系管理、任务监控等功能。DolphinScheduler还提供了可视化的任务编排界面,方便用户进行任务的配置和管理。 ### 回答2: DolphinScheduler作为分布式调度系统,能够支持多种类型的定时任务。 定时任务是指在确定的时间点自动执行的任务。 这些任务可以是简单的脚本,也可以是复杂的ETL管道或数据处理应用程序。 DolphinScheduler的定时任务非常灵活,可以配置多种调度策略和参数,可以通过控制面板在运行时监控和管理任务DolphinScheduler的调度支持多种调度方式,包括周期性调度,CRON调度和序列调度等。 周期性调度是指通过配置固定的时间间隔来调度任务。CRON调度基于时间表达式的调度方式,可以灵活地配置任务在每天、每周、每月的特定时间点执行。 序列调度是用于处理依赖项的调度,可以配置任务在另一个任务完成后执行。 DolphinScheduler的定时任务还支持任务生命周期管理、任务告警和自动容错处理等功能。 在任务生命周期管理中,可以设置任务的启动方式和停止方式。任务告警可以在任务执行成功或失败时发送通知,便于用户及时发现任务执行问题。自动容错处理是通过检测任务异常状态来重新执行任务,以确保任务的准确性和一致性。 总体来说,DolphinScheduler定时任务非常灵活和强大,提供了各种调度策略和参数配置方式,可以配置任何类型的任务。 并且,DolphinScheduler的用户友好性、可配置性和易于扩展性,也使其成为许多企业选择的首选调度解决方案。 ### 回答3: DolphinScheduler是一款分布式调度和数据处理系统,提供了一个全面的解决方案来管理大规模的任务调度应用程序和数据处理作业。其中,Dolphinscheduler定时任务是该系统最突出的功能之一,为用户提供了一种可靠和方便的时间控制系统,让用户可以轻松地管理和执行固定的作业和任务Dolphinscheduler定时任务可以针对多种任务类型进行设置,包括数据抽取、数据转换、离线计算、机器学习和实时计算等。它能够根据自定义的执行计划和触发条件来实现定时运行任务,如按照年、月、日、小时、分钟、秒等不同时间间隔或周期进行任务的触发。同时,Dolphinscheduler还可以设置任务的依赖关系和顺序,确保任务的顺序执行及错误处理,让用户更加灵活地编排任务流程。 除此之外,Dolphinscheduler定时任务还允许用户配置多种告警机制,包括邮件、短信、微信等方式,以便及时通知处理人员任务执行情况或异常情况。此外,Dolphinscheduler还支持任务执行过程中的监控和日志记录,自动维护任务的状态和详细的执行信息,以便检查和分析任务的执行状况。 总之,DolphinScheduler定时任务是一种强大的工具,能够为用户提供灵活的任务调度管理,帮助用户轻松处理复杂的数据处理任务和作业流程。在大规模数据处理应用场景中,Dolphinscheduler定时任务的出现为用户提供了一种便捷高效的工具,减轻了用户的管理和运维负担。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值