Oozie - Hadoop commands are not executing (Shell)

2019-07-17 10:46发布

问题:

I am running a shell script that has hadoop commands.

Getting the following error when executing the same

Main class [org.apache.oozie.action.hadoop.ShellMain], exit code [1]

I am running a simple shell script with Cloudera Hue - Oozie

However when the script has no hadoop commands, it gets executed sucessfully.

I have set oozie.use.system.libpath=true and could see my libs are in

user/oozie/share/lib/<lib_timestmap>

Below is the shell script I am trying to run

#! /bin/bash
$(hadoop fs -mkdir /<location path>)

Wokflow.xml

<workflow-app name="Shell-copy" xmlns="uri:oozie:workflow:0.4">
    <start to="Shell-copy"/>
    <action name="Shell-copy">
        <shell xmlns="uri:oozie:shell-action:0.1">
            <job-tracker>${jobTracker}</job-tracker>
            <name-node>${nameNode}</name-node>
            <exec>test.sh</exec>
            <file>/user/hue/oozie/workspaces/_rrv9kor_-oozie-38-1455857816.12/test.sh#test.sh</file>
              <capture-output/>
        </shell>
        <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>
  • The scripts with hadoop commands either throwing the above error or displayed as completed successfully with none of the hadoop commands processed and only the echo's or other shell commands are executed.

回答1:

The problem with the shell action is that shell jobs are deployed as the 'mapred' user. As the above is deploying the oozie job from a user account other than mapred user , Permission Denied error was thrown.The way to solve this is to set the HADOOP_USER_NAME environment variable to the user account name through which you deploy your oozie workflow.

<env-var>HADOOP_USER_NAME=user_name_goes_here</env-var>