[英]Connect local IPython notebook to Spark on air gapped cluster
我有一台用於日常工作的W7機器。 我的公司還在私有雲上有一個空白的Hadoop集群。 我只能通過膩子訪問雲。 當我想在集群上使用Spark時,我啟動了膩子,然后執行以下兩項操作之一:
有沒有辦法使用本地W7 IPython筆記本連接到Spark?
丹尼爾·達拉博斯(Daniel Darabos)評論后進行一些試錯
我按照本教程在W7機器上本地安裝了Spark。 然后,我按照本教程創建了一個新的pyspark配置文件並更改了啟動文件。 此時,我可以在本地啟動Ipython並成功地創建一個Spark上下文。 當我跑步時:
sc.stop()
conf = SparkConf().setAppName('SPark Test').setMaster('localhost:7077')
sc = SparkContext(conf=conf)
然后我得到一個錯誤:
---------------------------------------------------------------------------
Py4JJavaError Traceback (most recent call last)
<ipython-input-15-1e8f5b112924> in <module>()
1 sc.stop()
2 conf = SparkConf().setAppName('SPark Test').setMaster('localhost:7077')
----> 3 sc = SparkContext(conf=conf)
C:\Spark\python\pyspark\context.pyc in __init__(self, master, appName, sparkHome, pyFiles, environment, batchSize, serializer, conf, gateway, jsc, profiler_cls)
111 try:
112 self._do_init(master, appName, sparkHome, pyFiles, environment, batchSize, serializer,
--> 113 conf, jsc, profiler_cls)
114 except:
115 # If an error occurs, clean up in order to allow future SparkContext creation:
C:\Spark\python\pyspark\context.pyc in _do_init(self, master, appName, sparkHome, pyFiles, environment, batchSize, serializer, conf, jsc, profiler_cls)
168
169 # Create the Java SparkContext through Py4J
--> 170 self._jsc = jsc or self._initialize_context(self._conf._jconf)
171
172 # Create a single Accumulator in Java that we'll send all our updates through;
C:\Spark\python\pyspark\context.pyc in _initialize_context(self, jconf)
222 Initialize SparkContext in function to allow subclass specific initialization
223 """
--> 224 return self._jvm.JavaSparkContext(jconf)
225
226 @classmethod
C:\Spark\python\lib\py4j-0.8.2.1-src.zip\py4j\java_gateway.py in __call__(self, *args)
699 answer = self._gateway_client.send_command(command)
700 return_value = get_return_value(answer, self._gateway_client, None,
--> 701 self._fqn)
702
703 for temp_arg in temp_args:
C:\Spark\python\pyspark\sql\utils.pyc in deco(*a, **kw)
34 def deco(*a, **kw):
35 try:
---> 36 return f(*a, **kw)
37 except py4j.protocol.Py4JJavaError as e:
38 s = e.java_exception.toString()
C:\Spark\python\lib\py4j-0.8.2.1-src.zip\py4j\protocol.py in get_return_value(answer, gateway_client, target_id, name)
298 raise Py4JJavaError(
299 'An error occurred while calling {0}{1}{2}.\n'.
--> 300 format(target_id, '.', name), value)
301 else:
302 raise Py4JError(
Py4JJavaError: An error occurred while calling None.org.apache.spark.api.java.JavaSparkContext.
: org.apache.spark.SparkException: Could not parse Master URL: 'localhost:7077'
at org.apache.spark.SparkContext$.org$apache$spark$SparkContext$$createTaskScheduler(SparkContext.scala:2693)
at org.apache.spark.SparkContext.<init>(SparkContext.scala:506)
at org.apache.spark.api.java.JavaSparkContext.<init>(JavaSparkContext.scala:61)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:234)
at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:379)
at py4j.Gateway.invoke(Gateway.java:214)
at py4j.commands.ConstructorCommand.invokeConstructor(ConstructorCommand.java:79)
at py4j.commands.ConstructorCommand.execute(ConstructorCommand.java:68)
at py4j.GatewayConnection.run(GatewayConnection.java:207)
at java.lang.Thread.run(Unknown Source)
使用PuTTY創建SSH隧道,該隧道將本地端口(例如7077
)轉發到Spark主服務器(例如spark-master:7077
)。 然后在您的本地IPython Notebook中使用本地端口( spark://localhost:7077
)作為Spark主設備的地址。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.