当我提交一个python脚本作为jar来激发oozie中的动作时,我看到以下错误:
Traceback (most recent call last):
File "/home/hadoop/spark.py", line 5, in <module>
from pyspark import SparkContext, SparkConf
ImportError: No module named pyspark
Intercepting System.exit(1)
虽然我可以看到我的本地FS存在pyspark库:
$ ls /usr/lib/spark/python/pyspark/
accumulators.py heapq3.py rdd.py statcounter.py
broadcast.py __init__.py rddsampler.py status.py
cloudpickle.py java_gateway.py resultiterable.py storagelevel.py
conf.py join.py serializers.py streaming/
context.py ml/ shell.py tests.py
daemon.py mllib/ shuffle.py traceback_utils.py
files.py profiler.py sql/ worker.py
我知道在像https://issues.apache.org/jira/browse/OOZIE-2482这样的oozie上运行pyspark存在问题,但我看到的错误与JIRA票证不同。
此外,我在我的工作流程定义中将--conf spark.yarn.appMasterEnv.SPARK_HOME=/usr/lib/spark --conf spark.executorEnv.SPARK_HOME=/usr/lib/spark
作为spark-opts
传递。
以下是我的示例应用程序供参考:
masterNode ip-xxx-xx-xx-xx.ec2.internal
nameNode hdfs://${masterNode}:8020
jobTracker ${masterNode}:8032
master yarn
mode client
queueName default
oozie.libpath ${nameNode}/user/oozie/share/lib
oozie.use.system.libpath true
oozie.wf.application.path /user/oozie/apps/
<workflow-app name="spark-wf" xmlns="uri:oozie:workflow:0.5">
<start to="spark-action-test"/>
<action name="spark-action-test">
<spark xmlns="uri:oozie:spark-action:0.1">
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<configuration>
<property>
<name>mapred.compress.map.output</name>
<value>true</value>
</property>
</configuration>
<master>${master}</master>
<mode>${mode}</mode>
<name>Spark Example</name>
<jar>/home/hadoop/spark.py</jar>
<spark-opts>--driver-memory 512m --executor-memory 512m --num-executors 4 --conf spark.yarn.appMasterEnv.SPARK_HOME=/usr/lib/spark --conf spark.executorEnv.SPARK_HOME=/usr/lib/spark --conf spark.yarn.appMasterEnv.PYSPARK_PYTHON=/usr/lib/spark/python --conf spark.executorEnv.PYTHONPATH=/usr/lib/spark/python --files ${nameNode}/user/oozie/apps/hive-site.xml</spark-opts>
</spark>
<ok to="end"/>
<error to="kill"/>
</action>
<kill name="kill">
<message>Action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
</kill>
<end name="end"/>
</workflow-app>
# sc is an existing SparkContext.
from pyspark import SparkContext, SparkConf
from pyspark.sql import HiveContext
conf = SparkConf().setAppName('test_pyspark_oozie')
sc = SparkContext(conf=conf)
sqlContext = HiveContext(sc)
sqlContext.sql("CREATE TABLE IF NOT EXISTS src (key INT, value STRING)")
根据这里的建议 - http://www.learn4master.com/big-data/pyspark/run-pyspark-on-oozie,我也确实在我的$ {nameNode} / user / oozie / share / lib文件夹下放了以下两个文件:py4j-0.9-src.zip pyspark.zip。 / p>
我正在使用单节点YARN群集(AWS EMR)&amp;试图找出我可以在我的oozie应用程序中将这些pyspark模块传递给python。任何帮助表示赞赏。
答案 0 :(得分:2)
您收到No module named error
,因为您的配置中未提及PYTHONPATH
。使用--conf
在PYTHONPATH=/usr/lib/spark/python
中再添加一行。我不知道如何在oozie工作流定义中设置此PYTHONPATH
,但在配置中添加PYTHONPATH
属性肯定会解决您的问题。