I have a simple workflow (see below) which runs a shell script. The shell script runs pyspark script, which moves file from local to hdfs folder.
When I run the shell script itself, it works perfectly, logs are redirect to a folder by > spark.txt 2>&1 right in the shell script.
But when I submit oozie job with following workflow, output from shell seems to be supressed. I tried to redirect all possible oozie logs (-verbose -log) > oozie.txt 2>&1, but it didn't help.
The workflow is finished successfuly (status SUCCESSEDED, no error log), but I see, the folder is not copied to hdfs, however when I run it alone (not through oozie), everything is fine.
<action name="forceLoadFromLocal2hdfs">
<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>driver-script.sh</exec>
<argument>s</argument>
<argument>script.py</argument>
<!-- arguments for py script -->
<argument>hdfsPath</argument>
<argument>localPath</argument>
<file>driver-script.sh#driver-script.sh</file>
</shell>
<ok to="end"/>
<error to="killAction"/>
Thx a lot!
EDIT: Thx to the advice I found full log under the
yarn -logs -applicationId [application_xxxxxx_xxxx]
Thx to the advice I found full log under the
yarn -logs -applicationId [application_xxxxxx_xxxx]
Related
I have a oozie workflow which calls a shell script. The shell script calls a presto cli query. If I execute the shell script from the putty terminal then everything works as expected
But when I run the Workflow an error is raised. I know the shell script itself is being called successfully as I can see my ECHO statement in the log fileas below
This script is stored inside the Hadoop File system
shell script :
#!/bin/bash
echo Execute Presto Command
/home/hdfs/presto-cli --server 1.1.1.1:8080 --catalog hive --schema test --execute 'SELECT * from test limit 10'
However when the presto-cli command is called a "Permission Denied" error is raised
I can see in the Oozie GUI for the action that is running as my HDFS user so I am not sure what permission it refers to?
I read somewhere that you need to tell the workflow to run as the user who launched the workflow and not the YARN user. I added the env-var tag to my workflow action (see below) but this didnt help either
My Workflow's action is below :
<action name="Shell-Action">
<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>_myshell.sh</exec>
<env-var>HADOOP_USER_NAME=${wf:user()}</env-var>
<file>/user/hdfs/scripts/myshell.sh</file>
</shell>
<ok to="end"/>
<error to="fail"/>
</action>
What am I doing wrong?
Thanks
I have python script which I 'm able to run through spark-submit. I need to use it in Oozie.
<!-- move files from local disk to hdfs -->
<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>localPathFile</argument>
<!-- hdfs destination folder, be aware of, script is deleting existing folder! -->
<argument>hdfFolder</argument>
<file>${workflowRoot}driver-script.sh#driver-script.sh</file>
<file>${workflowRoot}load_local_2_hdfs.py#load_local_2_hdfs.py</file>
</shell>
<ok to="end"/>
<error to="killAction"/>
</action>
The script by itself through driver-script.sh runs fine. Through oozie, even the status of workflow is SUCCEEDED, the file is not copied to hdfs. I was not able to find any error logs, or related logs to pyspark job.
I have another topic about supressed logs from Spark by oozie here
Set your script to set -x in the beginning that will show you which line the script is it. You can see those in the stderr.
Can you elaborate on what you mean by file is not copied ? To help you better.
I have a oozie workflow that will invoke a shell file, Shell file will further invoke a driver class of mapreduce job. Now i want to map my oozie jobId to Mapreduce jobId for later process. Is there any way to get oozie jobId in workflow file so that i can pass the same as argument to my driver class for mapping.
Following is my sample workflow.xml file
<workflow-app xmlns="uri:oozie:workflow:0.4" name="test">
<start to="start-test" />
<action name='start-test'>
<shell xmlns="uri:oozie:shell-action:0.2">
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<configuration>
<property>
<name>mapred.job.queue.name</name>
<value>${queueName}</value>
</property>
</configuration>
<exec>${jobScript}</exec>
<argument>${fileLocation}</argument>
<argument>${nameNode}</argument>
<argument>${jobId}</argument> <!-- this is how i wanted to pass oozie jobId -->
<file>${jobScriptWithPath}#${jobScript}</file>
</shell>
<ok to="end" />
<error to="kill" />
</action>
<kill name="kill">
<message>test job failed
failed:[${wf:errorMessage(wf:lastErrorNode())}]</message>
</kill>
<end name="end" />
Following is my shell script.
hadoop jar testProject.jar testProject.MrDriver $1 $2 $3
Try to use ${wf:id()}:
String wf:id()
It returns the workflow job ID for the current workflow job.
More info here.
Oozie drops an XML file in the CWD of the YARN container running the shell (the "launcher" container), and also sets an env variable pointing to that XML (cannot remember the name though).
That XML contains a lot of stuff like name of Workflow, name of Action, ID of both, run attempt number, etc.
So you can sed back that information in the shell script itself.
Of course passing explicitly the ID (as suggested by Alexei) would be cleaner, but sometimes "clean" is not the best way. Especially if you are concerned about whether it's the first run or not...
I am trying to run a Shell Script on Oozie.First, I selected the path of shell script file, after which I added the arguments to run the shell script file. When I try running the oozie worflow, as such, it goes into a running loop which gets killed after 10 seconds.
I also added the Environment Variable by setting the path of the output folder in HDFS. When I run it, again it runs into a loop which gets killed after 10 seconds. I am unable to figure out how to set the path. Please help.
Your question is not clear,
But I gess , your are trying to run Shell Script using Oozie workflow, where Shell Script Arguments will be pass from Oozie it self.
If My understanding is right, you can pass the Argument variable from Oozie via coordinator.properties/coordinator.xml/workflow.xml it self.
Example:
let say You have a shell script, which will perform distcp everytime its execute to anothere dfs location.
Shell Script:
> hadoop dfs -rmr destination_location
> hadoop distcp hdfs://<source_dfs><source_dfs_location> hdfs://<destination_dfs><destination_dfs_location>
workflow.xml:
<action name="shellAction">
<shell xmlns="uri:oozie:shell-action:0.1">
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<configuration>
<property>
<name>oozie.launcher.mapred.job.queue.name</name>
<value>default</value>
</property>
</configuration>
<exec>shell_script.sh</exec>
<file>hdfs://<dfs:port>/<dfs_location/shell_script.sh></file>
<capture-output/>
</shell>
<ok to="end"/>
<error to="killAction"/>
</action>
<kill name="killAction">
<message>Shell Action Failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
</kill>
Note: Shell action chould be defined in oozie_site.xml
Belive these will help u some point
I am new oozie user. Currently I am trying to run a sample bigquery command(e.g: bq ls -p) from a shell script in oozie. But its failing every time. below I have provided the workflow and shell script. I am trying it out in Hortonworks Sandbox and the gcloud is authenticated in hortonworks sandbox box.
I want to know is it not possible to run a bigquery command from oozie? AFAIK Hortonworks sandbox uses same virtualbox as its datanode and jobnode.
If I can run then anyone can help me to find the answer - if I am going to run from larger hadoop cluster, do I need to authenticate the gcloud in each node?
Thanks in advance.
My workflow xml sample:
<workflow..
<start to="run_shell" />
<action name="run_shell" retry-max="2" retry-interval="1">
<shell xmlns="uri:oozie:shell-action:0.2">
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<configuration>
<property>
<name>mapred.job.queue.name</name>
<value>default</value>
</property>
</configuration>
<exec>pl2.sh</exec>
<argument>/user/bandyoa/AP/</argument>
<file>${nameNode}/user/bandyoa/AP/pl2.sh#pl2.sh</file>
<capture-output/>
</shell>
<ok to="end"/>
<error to="failure_mail"/>
</action>
</workflo..>
and shell script:
#!/bin/bash
bq ls -p
Copying all the project settings and auth settings from /home/hdfs/.config and /home/hdfs/.bigqueryrc to /home/ and setting them to be readable/writable to all users made Oozie happy for me. Now bq ls returns the list of tables in default dataset.