为什么spark无法通过使用getOrCreate从检查点恢复

时间:2016-10-17 07:14:53

标签: apache-spark pyspark spark-streaming

关于官方文档,我尝试重新传输StreamingContext:

def get_or_create_ssc():
    cfg = SparkConf().setAppName('MyApp').setMaster('local[10]')
    sc = SparkContext(conf=cfg)
    ssc = StreamingContext(sparkContext=sc, batchDuration=2)

    lines = ssc.socketTextStream('localhost', 9999).checkpoint(10)

    def update_func(x, y):
        return sum(x) + (y or 0)

    word = lines.flatMap(lambda x: x.split()).map(lambda x: (x, 1)).updateStateByKey(update_func)
    word.pprint()
    return ssc


ssc = StreamingContext.getOrCreate('checkpoint', get_or_create_ssc)

ssc.start()
ssc.awaitTermination()

当我第一次启动代码时(检查点为空),它也能正常工作

为模拟系统故障,我关闭终端

但重新启动时无法恢复

终端仅显示此

16/10/17 15:04:53 WARN Utils: Your hostname, localhost resolves to a loopback address: 127.0.0.1; using 192.168.177.1 instead (on interface eth0)
16/10/17 15:04:53 WARN Utils: Set SPARK_LOCAL_IP if you need to bind to another address
16/10/17 15:04:55 WARN SparkContext: Use an existing SparkContext, some configuration may not take effect.
16/10/17 15:04:57 WARN SocketInputDStream: isTimeValid called with 1476686252000 ms whereas the last valid time is 1476686572000 ms
[Stage 3:>                                                         (0 + 0) / 20]

以后没有新信息

1 个答案:

答案 0 :(得分:0)

最后,我从Spark UI的环境页面找到了原因。

当我第一次启动代码时,spark.master已设置为' local [10]'。

但是从检查站恢复后,spark.master改为' local [*]'

我必须使用' park.master local [10]'编辑conf / spark-defaults.conf。由于我的VMware只有一个核心。

在官方文档中有一条评论说:

Metadata includes:
    Configuration - The configuration that was used to create the streaming application.

似乎Configuration不包含spark.master。

为什么?

相关问题