Apache Spark:启动 PySpark 时出错
Posted
技术标签:
【中文标题】Apache Spark:启动 PySpark 时出错【英文标题】:Apache Spark: Error while starting PySpark 【发布时间】:2015-06-18 20:19:36 【问题描述】:在 Centos 机器上,Python v2.6.6 和 Apache Spark v1.2.1
尝试运行 ./pyspark 时出现以下错误
python似乎有些问题,但无法弄清楚
15/06/18 08:11:16 INFO spark.SparkContext: Successfully stopped SparkContext
Traceback (most recent call last):
File "/usr/lib/spark_1.2.1/spark-1.2.1-bin-hadoop2.4/python/pyspark/shell.py", line 45, in <module>
sc = SparkContext(appName="PySparkShell", pyFiles=add_files)
File "/usr/lib/spark_1.2.1/spark-1.2.1-bin-hadoop2.4/python/pyspark/context.py", line 105, in __init__
conf, jsc)
File "/usr/lib/spark_1.2.1/spark-1.2.1-bin-hadoop2.4/python/pyspark/context.py", line 157, in _do_init
self._accumulatorServer = accumulators._start_update_server()
File "/usr/lib/spark_1.2.1/spark-1.2.1-bin-hadoop2.4/python/pyspark/accumulators.py", line 269, in _start_update_server
server = AccumulatorServer(("localhost", 0), _UpdateRequestHandler)
File "/usr/lib64/python2.6/SocketServer.py", line 402, in __init__
self.server_bind()
File "/usr/lib64/python2.6/SocketServer.py", line 413, in server_bind
self.socket.bind(self.server_address)
File "<string>", line 1, in bind
socket.gaierror: [Errno -2] Name or service not known
>>> 15/06/18 08:11:16 INFO remote.RemoteActorRefProvider$RemotingTerminator: Shutting down remote daemon.
15/06/18 08:11:16 INFO remote.RemoteActorRefProvider$RemotingTerminator: Remote daemon shut down; proceeding with flushing remote transports.
【问题讨论】:
听起来您无法连接到 spark master。你是在本地以独立模式运行它吗? 【参考方案1】:从日志看来 pyspark 无法理解主机 localhost。请检查您的 /etc/hosts 文件,如果 localhost 不可用,请添加一个条目应该可以解决这个问题。
例如:
[Ip] [主机名] 本地主机
如果您无法更改服务器的主机条目 编辑 /python/pyspark/accumulators.py 行号 269 如下
server = AccumulatorServer(("[hosts 文件中的服务器主机名]", 0), _UpdateRequestHandler)
【讨论】:
以上是关于Apache Spark:启动 PySpark 时出错的主要内容,如果未能解决你的问题,请参考以下文章
Apache Spark (PySpark) 在读取 CSV 时处理空值
pyspark 读取 bigquery 时出错:java.lang.ClassNotFoundException:org.apache.spark.internal.Logging$class
Pyspark 错误实例化 'org.apache.spark.sql.hive.HiveSessionStateBuilder':"