2017-07-25 74 views
0

我有非常简单的工作流程。Oozie pyspark工作

<workflow-app name="testSparkjob" xmlns="uri:oozie:workflow:0.5"> 
<start to="testJob"/> 

    <action name="testJob"> 
    <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>local[*]</master> 
     <name>Spark Example</name> 
     <jar>mapping.py</jar> 
     <spark-opts>--executor-memory 1G --num-executors 3 
--executor-cores  1 </spark-opts> 
     <arg>argument1</arg> 
     <arg>argument2</arg> 
    </spark> 
    <ok to="end"/> 
    <error to="killAction"/> 
</action> 
<kill name="killAction"> 
    <message>"Killed job due to error"</message> 
</kill> 
<end name="end"/> 
</workflow-app> 

星火脚本做几乎没有:

if len(sys.argv) < 2: 
    print('You must pass 2 parameters ') 
    #just for testing, later will be discarded, sys.exit(1) will be used.") 
    ext = 'testArgA' 
    int = 'testArgB' 
    #sys.exit(1) 
else: 
    print('arguments accepted') 
    ext = sys.argv[1] 
    int = sys.argv[2] 

该脚本位于同一文件夹作为workflow.xml HDFS。

当我的侏儒我得到了以下错误

Launcher ERROR, reason: Main class 
[org.apache.oozie.action.hadoop.SparkMain], exit code [2] 

我因子评分是权限问题,所以我设定的HDFS文件夹-chmod 777和我的本地文件夹还于chmod 777 我使用的火花1.6工作流程。当我通过spark-submit运行脚本时,一切都很好(即使读取/写入hdfs或配置单元的脚本更加复杂)。

编辑:我试过this

<action name="forceLoadFromLocal2hdfs"> 
<shell xmlns="uri:oozie:shell-action:0.3"> 
    <job-tracker>${jobTracker}</job-tracker> 
    <name-node>${nameNode}</name-node> 
    <configuration> 
    <property> 
     <name>mapred.job.queue.name</name> 
     <value>${queueName}</value> 
    </property> 
    </configuration> 
    <exec>driver-script.sh</exec> 
<!-- single --> 
    <argument>s</argument> 
<!-- py script --> 
    <argument>load_local_2_hdfs.py</argument> 
<!-- local file to be moved--> 
    <argument>localFilePath</argument> 
<!-- hdfs destination folder, be aware of, script is deleting existing folder! --> 
    <argument>hdfsPath</argument> 
    <file>${workflowRoot}driver-script.sh</file> 
    <file>${workflowRoot}load_local_2_hdfs.py</file> 
</shell> 
<ok to="end"/> 
<error to="killAction"/> 

的workkflow得手,但文件不会被复制到HDFS。没有错误。该脚本本身确实有效。更多here

回答

0

不幸的是,Oozie Spark操作仅支持Java工件,因此您必须指定主类(该错误消息几乎没有解释)。所以,你有两个选择:

  1. 重写你的代码的Java /斯卡拉
  2. 使用自定义操作或脚本像 this(我没有测试)
+0

运行shell脚本与Python纸条作为一个论点是我最初的想法,但它是不行的。我希望,现在将是:) Thx非常适合我的想法。 –

+0

无论如何,这是奇怪的,因为在documentatiton我发现:jar元素指示一个逗号分隔的jar或python文件列表。 –