将flink作业提交到远程virtualbox不起作用

pkln4tw6  于 2021-06-21  发布在  Flink
关注(0)|答案(1)|浏览(602)
package org.myorg.quickstart;

import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.api.common.functions.FlatMapFunction;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.util.Collector;
import org.apache.flink.runtime.minicluster.LocalFlinkMiniCluster;
import org.apache.flink.configuration.Configuration;

public class WordCount {

public static void main(String[] args) throws Exception {

    final LocalFlinkMiniCluster cluster = new LocalFlinkMiniCluster(new Configuration(), false); //line 16
    cluster.start(); //line 17

    final StreamExecutionEnvironment env = StreamExecutionEnvironment.createRemoteEnvironment("localhost", 6123);

    final long N = 10;
    DataStream<Long> stream = env.generateSequence(1, N);
    stream.map(new MapFunction<Long, Long>() {
        @Override
        public Long map(Long value) throws Exception {
            return 2 * value;
        }
    }).print();
    env.execute("WC Test");
}

public static final class LineSplitter implements FlatMapFunction<String, Tuple2<String, Integer>> {

    @Override
    public void flatMap(String value, Collector<Tuple2<String, Integer>> out) {
        // normalize and split the line
        String[] tokens = value.toLowerCase().split("\\W+");

        // emit the pairs
        for (String token : tokens) {
            if (token.length() > 0) {
                out.collect(new Tuple2<String, Integer>(token, 1));
            }
        }
    }
}
}

以上代码可以在本地小型集群上成功地在本地(windows+idea)运行。
然后,我把第16行和第17行注解掉。我开始一个 Flink 在virtualbox中 start-local.sh 或者 start-cluster.sh . 但是,我的程序失败了 IDEA 这一次。它抱怨与工作经理没有联系,如下所示。
有人能帮我找出失败的原因吗?我需要特殊的设置吗 Flink 在virtualbox中。我已经转发了 JobManager 港口 6123 在virtualbox设置中。我甚至编辑了 jar 运行 jar 在virtualbox中出现相同的错误。

09:16:00,631 INFO org.apache.flink.streaming.api.environment.RemoteStreamEnvironment - Running remotely at localhost:6123
09:16:01,220 INFO org.apache.flink.client.program.StandaloneClusterClient - Submitting job with JobID: 2e53f2e2f66f023c2f4748f7fe6d4545. Waiting for job completion.
Submitting job with JobID: 2e53f2e2f66f023c2f4748f7fe6d4545. Waiting for job completion.
09:16:01,220 INFO org.apache.flink.client.program.StandaloneClusterClient - Starting client actor system.
09:16:02,212 INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started
09:16:02,295 INFO Remoting - Starting remoting
09:16:02,530 INFO Remoting - Remoting started; listening on addresses :[akka.tcp://flink@127.0.0.1:56050]
09:16:02,542 INFO org.apache.flink.runtime.client.JobClientActor - Disconnect from JobManager null.
09:16:02,550 INFO org.apache.flink.runtime.client.JobClientActor - Received job Window WordCount (2e53f2e2f66f023c2f4748f7fe6d4545).
09:16:02,550 INFO org.apache.flink.runtime.client.JobClientActor - Could not submit job Window WordCount (2e53f2e2f66f023c2f4748f7fe6d4545), because there is no connection to a JobManager.
09:16:02,624 WARN akka.remote.ReliableDeliverySupervisor - Association with remote system [akka.tcp://flink@127.0.0.1:6123] has failed, address is now gated for [5000] ms. Reason is: [Association failed with [akka.tcp://flink@127.0.0.1:6123]].

Process finished with exit code 1
fwzugrvs

fwzugrvs1#

我发现问题是因为maven的代码库与flink运行的版本不同。一旦我确定所有lib都更新到flink1.1.2,就没有问题了。

相关问题