hadoopooziehadoop-streaming

Oozie Hadoop Streaming


I am trying to write a simple map only hadoop streaming job reading data from hdfs and pushing it to vertica.

I have written few shell scripts as below

load.sh

  hadoop jar hadoop-streaming-2.7.3.2.5.3.0-37.jar -input $INPUT_DIR -mapper /user/oozie/adhoc_data_load/scripts/export.sh -output $OUTPUT_DIR

export.sh

 ./vsql -c "copy $TABLE from stdin delimiter E'\t' direct null '\\N';" -U $DBUSER -w $DBPWD -h $DBHOST -p $DBPORT

Workflow:

<action name="loadToVertica">
    <shell xmlns="uri:oozie:shell-action:0.1">
            <job-tracker>${jobTracker}</job-tracker>
            <name-node>${nameNode}</name-node>
            <exec>loadVertica.sh</exec>
            <argument>${STREAMING_JAR_PATH}</argument>
            <argument>${nameNode}/user/oozie/optus_adhoc_data/${exportDataDate}</argument>
            <argument>${TABLE_NAME_VERTICA}</argument>
            <argument>${dbHost}</argument>
            <argument>${dbName}</argument>
            <argument>${dbPassword}</argument>
            <argument>${dbPort}</argument>
            <argument>${nameNode}/user/oozie/optus_adhoc_data/output/${exportDataDate}</argument>
            <argument>vsql,export.sh</argument>
            <file>${nameNode}/user/oozie/adhoc_data_load/scripts/loadVertica.sh#loadVertica.sh</file>
            <file>${wfsBasePath}/libs/${STREAMING_JAR_PATH}#${STREAMING_JAR_PATH}</file>
            <file>${wfsBasePath}/config/vsql#vsql</file>
            <file>${wfsBasePath}/scripts/export.sh#export.sh</file>
            <capture-output/>
        </shell>
        <ok to="end"/>
       <error to="end"/>
    </action>

Running it with Oozie user getting below exception:

org.apache.hadoop.ipc.RemoteException(org.apache.hadoop.security.AccessControlException): Permission denied: user=yarn, access=WRITE, inode="/user/yarn/.staging":hdfs:hdfs:drwxr-xr-x
        at org.apache.hadoop.hdfs.server.namenode.FSPermissionChecker.check(FSPermissionChecker.java:319)

Solution:

Add in workflow :

HADOOP_USER_NAME=${wf:user()}


Solution

  • Able to fix this by adding below in Workflow.xml

    HADOOP_USER_NAME=${wf:user()}