Community Articles
Find and share helpful community-sourced technical articles
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.
Labels (1)
Super Guru

Generally you will get permission denied error as below when you run oozie shell action without setting environment variable to username who is submitting the oozie workflow.

Permission denied: user=yarn, access=WRITE oozie shell action

Below are my sample configs

workflow.xml

<workflow-app xmlns="uri:oozie:workflow:0.3" name="shell-wf">
    <start to="shell-node"/>
    <action name="shell-node">
        <shell xmlns="uri:oozie:shell-action:0.1">
            <job-tracker>${jobTracker}</job-tracker>
            <name-node>${nameNode}</name-node>
            <configuration>
                <property>
                    <name>mapred.job.queue.name</name>
                    <value>${queueName}</value>
                </property>
            </configuration>
            <exec>test.sh</exec>
    <file>/user/root/test.sh</file>
        </shell>
        <ok to="end"/>
        <error to="fail"/>
    </action>
    <kill name="fail">
        <message>Shell action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
    </kill>
    <end name="end"/>
</workflow-app>

job.properties

nameNode=hdfs://sandbox.hortonworks.com:8020
jobTracker=sandbox.hortonworks.com:8050
queueName=default
examplesRoot=examples
oozie.wf.application.path=${nameNode}/user/${user.name}

test.sh shell script

#!/bin/bash
hadoop fs -mkdir /user/root/testdir

Error:

mkdir: Permission denied: user=yarn, access=WRITE, inode="/user/root/testdir":root:hdfs:drwxr-xr-x
Failing Oozie Launcher, Main class [org.apache.oozie.action.hadoop.ShellMain], exit code [1]
log4j:WARN No appenders could be found for logger (org.apache.hadoop.metrics2.impl.MetricsSystemImpl).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

How to fix this?

To tell oozie not to run container as yarn but as the user who has submitted the workflow, we need to add below variable environment variable in our workflow.xml file

    <env-var>HADOOP_USER_NAME=${wf:user()}</env-var>

Modified working workflow.xml file:

<workflow-app xmlns="uri:oozie:workflow:0.3" name="shell-wf">
    <start to="shell-node"/>
    <action name="shell-node">
        <shell xmlns="uri:oozie:shell-action:0.1">
            <job-tracker>${jobTracker}</job-tracker>
            <name-node>${nameNode}</name-node>
            <configuration>
                <property>
                    <name>mapred.job.queue.name</name>
                    <value>${queueName}</value>
                </property>
            </configuration>
            <exec>test.sh</exec>
    <env-var>HADOOP_USER_NAME=${wf:user()}</env-var>
    <file>/user/root/test.sh</file>
        </shell>
        <ok to="end"/>
        <error to="fail"/>
    </action>
    <kill name="fail">
        <message>Shell action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
    </kill>
    <end name="end"/>
</workflow-app>

Ouptut:

[root@sandbox ~]# hadoop fs -ls -d /user/root/testdir
drwxr-xr-x   - root hdfs          0 2016-04-08 07:59 /user/root/testdir
[root@sandbox ~]#
9,103 Views
Comments
New Contributor

@Kuldeep Kulkarni - I'm getting an semantic exception in workflow.xml when I add

<env-var>HADOOP_USER_NAME=${wf:user()}</env-var> 

Any pointers ?

Super Guru

@Tushar Bodhale - I think order really matters here. you need to put above line exactly below your script location, please refer my working workflow.xml file. Do let me know if you have any further questions.

Expert Contributor

@Kuldeep Kulkarni This worked for me...Thank you.

New Contributor

@Kuldeep Kulkarni

Please suggest on the order if we are executing a sqoop action. I am getting the below semantic exception.

Error: Invalid app definition, org.xml.sax.SAXParseException; lineNumber: 9; columnNumber: 22; cvc-complex-type.2.4.a: Invalid content was found starting with element 'env-var'. One of '{"uri:oozie:sqoop-action:0.3":prepare, "uri:oozie:sqoop-action:0.3":job-xml, "uri:oozie:sqoop-action:0.3":configuration, "uri:oozie:sqoop-action:0.3":command, "uri:oozie:sqoop-action:0.3":arg}' is expected.

Contributor

hi,

I need to write in a local file using a action. but similarly I get the permission error. do you have any idea?

Don't have an account?
Coming from Hortonworks? Activate your account here
Version history
Revision #:
1 of 1
Last update:
‎04-08-2016 08:11 AM
Updated by:
 
Contributors
Top Kudoed Authors