如何运行Apache Flink的第一个示例 [英] how to run first example of Apache Flink

查看:431
本文介绍了如何运行Apache Flink的第一个示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从以前的书使用Apache Flink进行流处理"和flink项目中运行第一个示例.每个都有不同的错误

I am trying to run the first example from the oreilly book "Stream Processing with Apache Flink" and from the flink project. Each gives different errors

书中的示例显示NoClassDefFound错误 来自flink项目的示例给出了java.net.ConnectException:连接被拒绝(连接被拒绝)但确实创建了flink作业,请参见屏幕截图.

Example from the book gies NoClassDefFound error Example from flink project gives java.net.ConnectException: Connection refused (Connection refused) but does create a flink job, see screenshot.

下面的详细信息

图书示例

java.lang.BootstrapMethodError:java.lang.NoClassDefFoundError:scala/runtime/java8/JFunction1 $ mcVI $ sp 在io.github.streamingwithflink.chapter1.AverageSensorReadings $$ anon $ 3.createSerializer(AverageSensorReadings.scala:50)

java.lang.BootstrapMethodError: java.lang.NoClassDefFoundError:scala/runtime/java8/JFunction1$mcVI$sp at io.github.streamingwithflink.chapter1.AverageSensorReadings$$anon$3.createSerializer(AverageSensorReadings.scala:50)

这本书的说明是:

  1. 下载提取

    一切正常

    1. 下载 jar文件包括本书中的示例
    2. 运行示例
    1. Download the jar file that includes examples in this book
    2. run example

    ./bin/flink run \
      -c io.github.streamingwithflink.chapter1.AverageSensorReadings \
      examples-scala.jar
    

    似乎从这篇文章顶部的错误消息中找不到该类.

    It seems that the class is not found from error message at the top of this post.

    我将jar放在运行命令的相同目录中

    I put the jar in the same directory I am running the command

    java -version
    openjdk version "1.8.0_242"
    OpenJDK Runtime Environment (Zulu 8.44.0.9-CA-macosx) (build 1.8.0_242-b20)
    OpenJDK 64-Bit Server VM (Zulu 8.44.0.9-CA-macosx) (build 25.242-b20, mixed mode)
    

    我也尝试用同样的错误自己编译jar.

    I also tried compiling the jar myself with the same error.

    https://github.com/streaming-with-flink/examples-scala.git

    mvn clean build

    错误是相同的.

    Flink项目教程

    运行 SocketWindowWordCount

    ./bin/flink run examples/streaming/SocketWindowWordCount.jar --port 9000

    我找到工作了,但是失败了

    I get a job but it fails

    给予java.net.ConnectException: Connection refused (Connection refused)

    我不清楚什么连接被拒绝.我尝试了其他端口,没有任何改变.

    It is not clear to me what connection is refused. I tried different ports with no change.

    如何成功运行flink代码?

    How can I run flink code successfully?

    推荐答案

    我尝试重现失败的AverageSensorReadings示例,但该示例在我的设置中有效.明天我会尝试更深入的研究.

    I tried to reproduce the failing AverageSensorReadings example, but it was working on my setup. I'll try look deeper into it tomorrow.

    关于SocketWindowWordCount示例,错误消息表明Flink作业无法打开与端口9000上套接字的连接.您需要先打开套接字 ,然后再开始作业.您可以使用netcat进行此操作,例如:

    Regarding the SocketWindowWordCount example, the error message indicates that the Flink job failed to open a connection to the socket on port 9000. You need to open the socket before you start the job. You can do this for example with netcat:

    nc -l 9000
    

    作业运行后,您可以通过键入发送消息,并且这些消息将被提取到Flink作业中.您可以看到WebUI中的统计信息根据您的消息所包含的单词数量而变化.

    After the job is running, you can send messages by typing and and these message will be ingested into the Flink job. You can see the stats in the WebUI evolving according to the number of words that your messages consisted of.

    请注意,当您停止Flink作业时,netcat会关闭套接字.

    Note that netcat closes the socket when you stop the Flink job.

    这篇关于如何运行Apache Flink的第一个示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆