2017-07-25 73 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文件列表。 –