Spark启动报错:Error initializing SparkContext

报错信息

java.lang.IllegalArgumentException: Required executor memory (1024), overhead (384 MB), and PySpark memory (0 MB) is above the max threshold (1298 MB) of this cluster! Please check the values of 'yarn.scheduler.maximum-allocation-mb' and/or 'yarn.nodemanager.resource.memory-mb'.

解决方案

调整yarn相关参数配置,全部改为2G

  • yarn.scheduler.maximum-allocation-mb
  • yarn.nodemanager.resource.memory-mb

在这里插入图片描述
在这里插入图片描述
重启解决报错

[root@master cloudera]# spark-shell 
Setting default log level to "WARN".
To adjust logging level use sc.setLogLevel(newLevel). For SparkR, use setLogLevel(newLevel).
19/09/23 16:12:22 WARN cluster.YarnSchedulerBackend$YarnSchedulerEndpoint: Attempted to request executors before the AM has registered!
19/09/23 16:12:22 WARN lineage.LineageWriter: Lineage directory /var/log/spark/lineage doesn't exist or is not writable. Lineage for this application will be disabled.
Spark context Web UI available at http://master.cdh:4040
Spark context available as 'sc' (master = yarn, app id = application_1569226132926_0001).
Spark session available as 'spark'.
Welcome to
      ____              __
     / __/__  ___ _____/ /__
    _\ \/ _ \/ _ `/ __/  '_/
   /___/ .__/\_,_/_/ /_/\_\   version 2.4.0-cdh6.3.0
      /_/
         
Using Scala version 2.11.12 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_211)
Type in expressions to have them evaluated.
Type :help for more information.

scala> 
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这个错误是由于SparkContext初始化时出现问题导致的。具体来说,第一个引用中的错误是因为系统内存不足,需要增加堆大小。而第二个引用中的错误是因为所需的执行器内存超过了集群的最大阈值。需要检查'yarn.scheduler.maximum-allocation-mb'和'yarn.nodemanager.resource.memory-mb'的值是否正确设置。 解决这个问题的方法取决于具体的情况。如果是第一个引用中的问题,可以通过增加堆大小来解决。可以通过以下方式增加堆大小: ```shell spark-submit --conf spark.driver.memory=4g --conf spark.executor.memory=4g your_app.py ``` 这将把驱动程序和执行器的内存限制都设置为4GB。如果需要更多的内存,可以相应地增加这些值。 如果是第二个引用中的问题,需要检查集群的配置。可以通过以下方式检查和修改配置: 1. 检查'yarn.scheduler.maximum-allocation-mb'和'yarn.nodemanager.resource.memory-mb'的值是否正确设置。可以使用以下命令检查: ```shell yarn getconf -confKey yarn.scheduler.maximum-allocation-mb yarn getconf -confKey yarn.nodemanager.resource.memory-mb ``` 2. 如果这些值太低,可以通过以下方式修改它们: ```shell yarn-site.xml <property> <name>yarn.scheduler.maximum-allocation-mb</name> <value>8192</value> </property> <property> <name>yarn.nodemanager.resource.memory-mb</name> <value>8192</value> </property> ``` 这将把'yarn.scheduler.maximum-allocation-mb'和'yarn.nodemanager.resource.memory-mb'的值都设置为8192MB。如果需要更多的内存,可以相应地增加这些值。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值