简体   繁体   English

在不提供 .jar 的情况下在远程集群上运行 Flink 作业

[英]Run a Flink job on a remote cluster without providing a .jar

I have the following problem: I want to create a Flink job in IntelliJ on a local machine and run it on a remote cluster which is located in a VM.我有以下问题:我想在本地机器上的 IntelliJ 中创建一个 Flink 作业,并在位于 VM 中的远程集群上运行它。 I used the createRemoteEnvironment function but anonymous classes as well as lambda expressions require jar files (if I didn't miss anything).我使用了createRemoteEnvironment函数,但匿名类以及 lambda 表达式需要 jar 文件(如果我没有遗漏任何东西)。 Is there a (or another) way to run a Flink job on remote cluster without providing jar files?是否有(或另一种)方法可以在不提供 jar 文件的情况下在远程集群上运行 Flink 作业? The following code is a simple Flink job I wanted to run on the remote cluster (without a jar).下面的代码是我想在远程集群上运行的一个简单的 Flink 作业(没有 jar)。

public static void main(String[] args) throws Exception {
    StreamExecutionEnvironment env = StreamExecutionEnvironment.createRemoteEnvironment("192.168.56.101", 6123);

    DataStream<Tuple2<String, Integer>> dataStream = env
        .socketTextStream("192.168.56.102", 8080)
        .flatMap((String sentence, Collector<Tuple2<String, Integer>> out) ->
            {
                for (String word: sentence.split(" ")) {
                    out.collect(new Tuple2<String, Integer>(word, 1));
                }
            });


    // Alternative approach with an anonymous class
    /*DataStream<Tuple2<String, Integer>> dataStream = env
        .socketTextStream("localhost", 8080)
        .flatMap(new FlatMapFunction<String, Tuple2<String, Integer>>() {
        @Override
        public void flatMap(String sentence, Collector<Tuple2<String, Integer>> out) 
        throws Exception {
            for (String word: sentence.split(" ")) {
                out.collect(new Tuple2<String, Integer>(word, 1));
            }
        }
    });*/

    dataStream.print();

    env.execute("Window WordCount");
}

Thanks for any help!谢谢你的帮助!

Based on the description here the error may be less than intuitive, but it essentially means you need a dependency.根据这里的描述,错误可能不太直观,但它本质上意味着您需要一个依赖项。

Conceptually, that means you need to provide the dependency.从概念上讲,这意味着您需要提供依赖项。

And this is normally done by providing it in a jar.这通常是通过将它放在一个罐子里来完成的。

So, based on how dependencies work in general I think the answer is that you must indeed provide the Jar to run the code that requires the dependency.因此,基于依赖项的一般工作方式,我认为答案是您确实必须提供 Jar 来运行需要依赖项的代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Flink:包装可执行的非flink jar 在flink集群中运行 - Flink: Wrap executable non-flink jar to run it in a flink cluster 使用RestClusterClient在Flink群集上运行已部署的作业 - Run already deployed job on Flink Cluster using RestClusterClient Flink:在Flink集群上执行Jar文件 - Flink: Jar file execution on Flink cluster 远程 flink 作业查询 Hive 上的纱线集群错误:NoClassDefFoundError: org/apache/hadoop/mapred/JobConf - remote flink job with query to Hive on yarn-cluster error:NoClassDefFoundError: org/apache/hadoop/mapred/JobConf Apache Storm:不创建jar就以编程方式将拓扑提交到远程集群 - Apache Storm: Submit Topology programatically to remote cluster without creating jar 如何增加Flink taskmanager.numberOfTaskSlots在没有Flink服务器的情况下运行它(在IDE或胖罐子里) - How to increase Flink taskmanager.numberOfTaskSlots to run it without Flink server(in IDE or fat jar) 运行时 Flink 作业执行失败 - Flink Job Execution Failed on run Flink 作业在 EMR 集群上运行失败 - Flink job runs to fail on EMR cluster 通过Java代码将Flink任务jar package上传到Flink集群 - Upload the Flink task jar package to the Flink cluster through Java code 通过http运行livy作业,而无需每次都上传jar - Run livy job via http without uploading jar every time
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM