会话在 AWS EMR 集群中不活跃 Pyspark

ana*_*nat 14 amazon-emr pyspark

我打开了一个 AWS EMR 集群,并在 pyspark3 jupyter notebook 中运行了以下代码:

"..
textRdd = sparkDF.select(textColName).rdd.flatMap(lambda x: x)
textRdd.collect().show()
.."
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

An error was encountered:
Invalid status code '400' from http://..../sessions/4/statements/7 with error payload: {"msg":"requirement failed: Session isn't active."}
Run Code Online (Sandbox Code Playgroud)

运行线路:

sparkDF.show()
Run Code Online (Sandbox Code Playgroud)

作品!

我还创建了该文件的一小部分,并且我的所有代码都运行良好。

问题是什么?

Kob*_*oba 11

我遇到了同样的问题,超时的原因是驱动程序内存不足。由于您运行collect()所有数据都会发送到驱动程序。默认情况下,驱动程序内存是1000M通过 JupyterHub 创建 Spark 应用程序时,即使您通过config.json. 您可以通过在 jupyter notebook 中执行代码来看到这一点

spark.sparkContext.getConf().get('spark.driver.memory')
Run Code Online (Sandbox Code Playgroud)
1000M
Run Code Online (Sandbox Code Playgroud)

要增加驱动程序内存只需执行

1000M
Run Code Online (Sandbox Code Playgroud)

这将使用增加的驱动程序内存重新启动应用程序。您可能需要为数据使用更高的值。希望能帮助到你。

  • 在我看来,司机可能因多种原因而死亡。但是,无论如何,“%%configure -f”命令都会重新启动它。 (2认同)

Nit*_*ess 9

这个堆栈溢出问题的答案对我有用

从输出来看,如果您的应用程序未以 FAILED 状态完成,这听起来像是 Livy 超时错误:您的应用程序可能花费比 Livy 会话定义的超时时间(默认为 1 小时)更长的时间,因此即使 Spark应用程序成功 如果应用程序花费的时间超过 Livy 会话的超时时间,您的笔记本将收到此错误。

如果是这种情况,解决方法如下:

1. edit the /etc/livy/conf/livy.conf file (in the cluster's master node)
2. set the livy.server.session.timeout to a higher value, like 8h (or larger, depending on your app)
3. restart Livy to update the setting: sudo restart livy-server in the cluster's master
4. test your code again
Run Code Online (Sandbox Code Playgroud)

编辑此设置的替代方法 - https://allinonescript.com/questions/54220381/how-to-set-livy-server-session-timeout-on-emr-cluster-boostrap


Fab*_*ano 0

您可能会从类似的 Stack Overflow 线程中获得一些见解:超时错误:400 StatusCode 错误:“要求失败:会话不活动。”

解决方案可能是增加spark.executor.heartbeatInterval. 默认值为 10 秒。

有关如何更改 Spark 默认值的信息,请参阅EMR 的官方文档:

您可以使用spark-defaults 配置分类或spark 配置分类中的maximizeResourceAllocation 设置更改spark-defaults.conf 中的默认值。