gpt4 book ai didi

python - 使用 Spark,如何连接 master 或解决错误 :"WARN TaskSchedulerImpl: Initial job has not accepted any resources"

转载 作者:可可西里 更新时间:2023-11-01 14:21:45 25 4
gpt4 key购买 nike

请告诉我如何解决以下问题。

首先,我确认以下代码在 master 为“本地”时运行。

然后我启动了两个 EC2 实例 (m1.large)。但是,当 master 为“spark://MASTER_PUBLIC_DNS:7077”时,会出现错误消息“TaskSchedulerImpl”并且失败。

当我从 VALID 地址更改为 Master (spark://INVALID_DNS:7077) 的 INVALID 地址时,会出现相同的错误消息。

即,"WARN TaskSchedulerImpl: Initial job has not accepted any resources; 检查您的集群 UI 以确保工作人员已注册并有足够的内存"

好像this .作为这个评论,我为这个集群分配了 12G 内存,但它失败了。

#!/usr/bin/env python                                                                                     
# -*- coding: utf-8 -*-
from pyspark import SparkContext, SparkConf
from pyspark.mllib.classification import LogisticRegressionWithSGD
from pyspark.mllib.regression import LabeledPoint
from numpy import array

# Load and parse the data
def parsePoint(line):
values = [float(x) for x in line.split(' ')]
return LabeledPoint(values[0], values[1:])
appName = "testsparkapp"
master = "spark://MASTER_PUBLIC_DNS:7077"
#master = "local"


conf = SparkConf().setAppName(appName).setMaster(master)
sc = SparkContext(conf=conf)

data = sc.textFile("/root/spark/mllib/data/sample_svm_data.txt")
parsedData = data.map(parsePoint)

# Build the model
model = LogisticRegressionWithSGD.train(parsedData)

# Evaluating the model on training data
labelsAndPreds = parsedData.map(lambda p: (p.label, model.predict(p.features)))
trainErr = labelsAndPreds.filter(lambda (v, p): v != p).count() / float(parsedData.count())
print("Training Error = " + str(trainErr))

补充

我完成了 friend 建议我完成的三项任务。

1.我打开了主端口,7077。

2.在 master url 中,设置主机名而不是 ip 地址。

->因此,我可以连接到主服务器(我通过 Cluster UI 进行了检查)。

3.我尝试如下设置worker_max_heap,但可能失败了。

ScalaConf().set("spark.executor.memory", "4g").set("worker_max_heapsize","2g")

工作人员允许我使用6.3GB(我通过UI检查过)。它是m1.large。

->我在我的执行日志中发现了一个警告,在一个 worker stderr 中发现了一个错误。

我的执行日志

14/08/08 06:11:59 WARN TaskSchedulerImpl: Initial job has not accepted any resources; check your cluster UI to ensure that workers are registered and have sufficient memory

worker 标准错误

14/08/08 06:14:04 INFO worker.WorkerWatcher: Successfully connected to akka.tcp://sparkWorker@PRIVATE_HOST_NAME1:52011/user/Worker
14/08/08 06:15:07 ERROR executor.CoarseGrainedExecutorBackend: Driver Disassociated [akka.tcp://sparkExecutor@PRIVATE_HOST_NAME1:52201] -> [akka.tcp://spark@PRIVATE_HOST_NAME2:38286] disassociated! Shutting down.

最佳答案

spark-ec2 脚本将 EC2 中的 Spark 集群配置为独立的,这意味着它不能与远程提交一起使用。在弄清楚它不受支持之前,我一直在为您描述的相同错误苦苦挣扎几天。不幸的是,消息错误不正确。

所以你必须复制你的东西并登录到 master 来执行你的 spark 任务。

关于python - 使用 Spark,如何连接 master 或解决错误 :"WARN TaskSchedulerImpl: Initial job has not accepted any resources",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25176197/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com