Meaning of hadoop job status - hadoop

I run the command hadoop job -list all to show all the submitted jobs, and it shows state meaning as: Running : 1 Succeded : 2 Failed : 3 Prep : 4.
But now I have a job whose status is 5. The list command output like this: job_201209101415_429766 5 1358332807055 user NORMAL NA
Anybody konws what it means?
Thank you!

Job status 5 implies Killed. Please check this web link
http://hadoop.apache.org/docs/r0.20.2/api/constant-values.html#org.apache.hadoop.mapred.JobStatus.KILLED

Related

Launching and Monitoring a job at the same time in Ansible tower CLI

We have installed Ansible Tower and have the CLI tools implemented. We can launch jobs in the CLI using the following -
tower-cli job launch -J 5
This returns the output like so -
Resource changed.
=== ============ ======================== ======= =======
id job_template created status elapsed
=== ============ ======================== ======= =======
119 5 2017-12-05T20:26:31.197Z pending 0.0
=== ============ ======================== ======= =======
And then we can monitor the status like this -
tower-cli job monitor 119.
Is it possible to pass the input of ID into the monitor cli argument in some way (or is it possible to run both at the same time)? Since we have multiple jobs running on the server, we would need to be able to reliably get the job id each time.
I didn't see anything about this when I read over the documentation at http://tower-cli.readthedocs.io/en/latest/cli_ref/index.html.
Thanks.
I'm on tower-cli version Tower CLI 3.3.0. I ran tower-cli job launch --help which gave the following, related commands:
--monitor If sent, immediately calls `job monitor` on the
newly launched job rather than exiting with a
success.
--wait Monitor the status of the job, but do not print
while job is in progress.
So I think you can just do the following:
tower-cli job launch -J 5 --monitor
(I add the --wait command when I'm running this in my CI build, which is why I included it above)
I fixed this by doing the following -
OUTPUT="$(tower-cli job launch -J 5 | grep -o '[0-9]*' | head -1 )"
tower-cli monitor $OUTPUT

How get exception,error,log for HIVE-SQOOP based Batch Job?

I have Hadoop cluster with 6 datanode and 1 namenode. I have few(4) jobs in HIVE which run on every day and push some data from logfile to our OLPT data base using sqoop. I do not have oozie installed in the environment. All are written in HIVE script file (.sql file) and I run those from unix script(.sh file). Those shell script file are attach with different OS cron job to run those on different time.
Now Requirement is This:
Generate log/status for each job separately on daily basis. So that at the end of the day looking into those log we can identify which job run successfully and time it took to run , which job failed and dump/stack stace for that failed job.(Feature plan is that we will have mail server and every failed or success job shell script will send mail to respective stack holder with those log/status file as attachment)
Now my problem is how I can find error/exception if anything I have to run those batch job / shell script and how to generate success log also with execution time?
I tried to get the output in text file for each query run into HIVE by redirecting the output but that is not working.
for example :
Select * from staging_table;>>output.txt
Is there any way to do this by configuring HIVE log for each and every HIVE job on day to day basis?
Please let me know if any one face this issue and how can I resolve this?
Select * from staging_table;>>output.txt
this is Redirecting output if you are looking for that option then below is the way from the console.
hive -e 'Select * from staging_table' > /home/user/output.txt
this will simply redirect the output. It wont display job specific log information.
However, I am assuming that you are running on yarn, if you are expecting to see application(job) specific for logs please see this
Resulting log file locations :
During run time you will see all the container logs in the ${yarn.nodemanager.log-dirs}
Using UI you can see the logs i.e job level and task level.
other way is to look from and dump application/job specific logs from command line.
yarn logs -applicationId your_application_id
Please note that using the yarn logs -applicationId <application_id> method is preferred but it does require log aggregation to be enabled first.
Also see much better explanation here

What are the different ways to check if the mapreduce program ran successfully

If we need to automate a mapreduce program or run from a script, what are the different ways to check if the mapreduce program ran successfully? One way is to find is if _SUCCESS file is created in the output directory. Does the command "hadoop jar program.jar hdfs:/input.txt hdfs:/output" return 0 or 1 based on success or failure ?
Just like any other command in Linux, you can check the exit status of a
hadoop jar command using the built in variable $?.
You can use:
echo $?
after executing the hadoop jar command to check its status.
The exit status value varies from 0 to 255. An exit status of zero implies that the command executed successfully while a non-zero value indicates that the command failed.
Edit: To see how to achieve automation or to run from a script, refer Hadoop job fails when invoked by cron.

Does hadoop list command show jobs having state other than 1?

I know that hadoop job -list commnad lists currently running jobs, i.e. jobs whose state is 1 (Running). But does it list jobs which are failed? I mean can I get an output something like this:
1 jobs currently running
JobId State StartTime UserName
job_200808111901_0001 3 1218506470390 abc
job_200808111901_0002 2 1218506470390 xyz
Note that the states of the above jobs are 3 (Failed) and 2 (Succeeded).
I am very new to Hadoop, so please pardon me if this too simple question. I tried to google, but all the examples give listed jobs with state 1 only.
Just add all and you will get what you desire.
Execute something like: hadoop job -list all.
An example output would look something like the following:
$ hadoop job -list all
0 jobs submitted
States are:
Running : 1 Succeded : 2 Failed : 3 Prep : 4
JobId State StartTime UserName Priority SchedulingInfo
For more details about the hadoop commands and especialy hadoop job, read here.

DATASTAGE: how to run more instance jobs in parallel using DSJOB

I have a question.
I want to run more instance of same job in parallel from within a script: I have a loop in which I invoke jobs with dsjob and without option "-wait" and "-jobstatus".
I want that jobs completed before script termination, but I don't know how to verify if job instance terminated.
I though to use wait command but it is not appropriate.
Thanks in advance
First,you should assure job compile option "Allow Multiple Instance" choose.
Second:
#!/bin/bash
. /home/dsadm/.bash_profile
INVOCATION=(1 2 3 4 5)
cd $DSHOME/bin
for id in ${INVOCATION[#]}
do
./dsjob -run -mode NORMAL -wait test demo.$id
done
project -- test
job -- demo
$id -- invocation id
the two line in shell scipt:guarantee the environment path can work.
Run the jobs like you say without the -wait, and then loop around running dsjob -jobinfo and parse the output for a job status of 1 or 2. When all jobs return this status, they are all finished.
You might find, though, that you check the status of the job before it actually starts running and you might pick up an old status. You might be able to fix this by first resetting the job instance and waiting for a status of "Not running", prior to running the job.
Invoke the jobs in loop without wait or job-status option
after your loop , check the jobs status by dsjob command
Example - dsjob -jobinfo projectname jobname.invocationid
you can code one more loop for this also and use sleep command under that
write yours further logic as per status of the jobs
but its good to create Job Sequence to invoke this multi-instance job simultaneously with the help of different invoaction-ids
create a sequence job if these are in same process
create different sequences or directly create different scripts to trigger these jobs simultaneously with invocation- ids and schedule in same time.
Best option create a standard generalized script where each thing will be getting created or getting value as per input command line parameters
Example - log files on the basis of jobname + invocation-id
then schedule the same script for different parameters or invocations .

Resources