无法在Sparkversion 2.0.1中创建SparkContext



i M最近将Spark版本从1.5更新为2.0.1。由Python脚本停止工作。

1.5中的代码

sc=SparkContext(appName="YOGI")

在Spark 2.0.1

中修改的代码
sc =SparkContext().master("spark://107.110.74.58:7077").appName("Python Spark SQL basic example").getOrCreate()

File "/home/yogendra.s/codebase/processRawData.py", line 56, in <module>
    sc =SparkContext().master("spark://107.110.74.58:7077").appName("Python Spark SQL basic example").getOrCreate()
  File "/home/yogendra.s/.spark_update/spark_hadoop2_7/python/lib/pyspark.zip/pyspark/context.py", line 115, in __init__
  File "/home/yogendra.s/.spark_update/spark_hadoop2_7/python/lib/pyspark.zip/pyspark/context.py", line 174, in _do_init
  File "/home/yogendra.s/.spark_update/spark_hadoop2_7/python/lib/pyspark.zip/pyspark/accumulators.py", line 259, in _start_update_server
  File "/usr/lib/python2.7/SocketServer.py", line 420, in __init__
    self.server_bind()
  File "/usr/lib/python2.7/SocketServer.py", line 434, in server_bind
    self.socket.bind(self.server_address)
  File "/usr/lib/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
socket.gaierror: [Errno -2] Name or service not known

Content of my default.xml
spark.master                       spark://107.110.74.58:7077
spark.driver.memory                20g
spark.executor.memory              20g

查看您的代码:

sc = SparkContext()。主(" Spark://107.110.74.58:7077").AppName(" Python) Spark SQL基本示例")。getorCreate()

您应该尝试使用.setMaster而不是.master

火花文件建议:

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

在您的情况下尝试:

from pyspark import SparkContext, SparkConf
conf = SparkConf().setAppName("Python Spark SQL basic example").setMaster("spark://107.110.74.58:7077")
sc = SparkContext(conf=conf)

请注意,我已经删除了.getOrCreate() Part

相关内容

  • 没有找到相关文章

最新更新