首页 > 解决方案 > 成功创建火花上下文后,Livy 会话卡在启动

问题描述

我一直在尝试使用在 Ubuntu 18.04 上运行的 Livy 0.7 服务器创建一个新的 spark 会话。在同一台机器上,我有一个正在运行的火花集群,有 2 个工人,我能够创建一个正常的火花会话。

我的问题是,在对 Livy 服务器运行以下请求后,会话停留在启动状态:

import json, pprint, requests, textwrap
host = 'http://localhost:8998'
data = {'kind': 'spark'}
headers = {'Content-Type': 'application/json'}
r = requests.post(host + '/sessions', data=json.dumps(data), headers=headers)
r.json()

我可以看到会话正在启动并从会话日志中创建了 spark 会话:

20/06/03 13:52:31 INFO SparkEntries: Spark context finished initialization in 5197ms
20/06/03 13:52:31 INFO SparkEntries: Created Spark session.
20/06/03 13:52:46 INFO CoarseGrainedSchedulerBackend$DriverEndpoint: Registered executor NettyRpcEndpointRef(spark-client://Executor) (xxx.xx.xx.xxx:1828) with ID 0
20/06/03 13:52:47 INFO BlockManagerMasterEndpoint: Registering block manager xxx.xx.xx.xxx:1830 with 434.4 MB RAM, BlockManagerId(0, xxx.xx.xx.xxx, 1830, None)

也来自火花主用户界面:

火花运行应用程序

并在livy.rsc.server.idle-timeout达到会话日志后输出:

20/06/03 14:28:04 WARN RSCDriver: Shutting down RSC due to idle timeout (10m).
20/06/03 14:28:04 INFO SparkUI: Stopped Spark web UI at http://172.17.52.209:4040
20/06/03 14:28:04 INFO StandaloneSchedulerBackend: Shutting down all executors
20/06/03 14:28:04 INFO CoarseGrainedSchedulerBackend$DriverEndpoint: Asking each executor to shut down
20/06/03 14:28:04 INFO MapOutputTrackerMasterEndpoint: MapOutputTrackerMasterEndpoint stopped!
20/06/03 14:28:04 INFO MemoryStore: MemoryStore cleared
20/06/03 14:28:04 INFO BlockManager: BlockManager stopped
20/06/03 14:28:04 INFO BlockManagerMaster: BlockManagerMaster stopped
20/06/03 14:28:04 INFO OutputCommitCoordinator$OutputCommitCoordinatorEndpoint: OutputCommitCoordinator stopped!
20/06/03 14:28:04 INFO SparkContext: Successfully stopped SparkContext
20/06/03 14:28:04 INFO SparkContext: SparkContext already stopped.

然后死了:( 在此处输入图像描述

我已经尝试过增加驱动程序超时但没有运气,并且没有发现任何类似的已知问题,我猜这与火花驱动程序与 rsc 的连接有关,但我不知道在哪里配置它

有人知道原因/解决方案吗?

标签: apache-sparkubuntulivyapache-spark-standalone

解决方案


我们在其中一个环境中遇到了类似的问题。工作环境和非工作环境之间的唯一区别是 livy.conf 文件中的 spark master 设置。

我从 livy.conf 中删除了配置 livy.spark.master=yarn 并从代码本身设置了这个值。

// pass master as yarn 
public static JavaSparkContext getSparkContext(final String master, final String appName) {

    LOGGER.info("Creating spark context");
    SparkConf conf = new SparkConf().setAppName(appName);
    if (Strings.isNullOrEmpty(master)) {
      LOGGER.warn("No spark master found setting local!!");
      conf.setMaster("local");
    } else {
      conf.setMaster(master);
    }
    conf.set("spark.submit.deployMode", "client");
    return new JavaSparkContext(conf);
  }

这对我有用。

如果有人能指出这对我来说是如何工作的,那将会有所帮助。


推荐阅读