Step 1: Create coordinator.properties file
oozie.use.system.libpath=true
nameNode=hdfs://<name>:8020
jobTracker=hdfs://<name>:8021
dfs.namenode.kerberos.principal=<value from hdfs-site.xml>
yarn.resourcemanager.principal=<value from hdfs-site.xml>
dfs.web.authentication.kerberos.keytab=<value from hdfs-site.xml>
dfs.web.authentication.kerberos.principal=<value from hdfs-site.xml>
nfs.kerberos.principal=<value from hdfs-site.xml>
nfs.keytab.file=/<value from hdfs-site.xml>
queueName=default
rootDirectory=<path>
oozie.coord.application.path=${nameNode}/${rootDirectory}/coordinator.xml
shellScript=<shell script.sh name>
shellScriptPath=<shell script path>
emailToAddress=<email address>
oozie.email.smtp.host=<value from oozie-site.xml>
oozie.email.smtp.port=<value from oozie-site.xml>
oozie_web=<value from oozie-site.xml>
Step 2: Create coordinator.xml file
<coordinator-app name="name" frequency="${coord:days(1)}" start="2015-07-13T20:20Z" end="2015-07-13T20:59Z" timezone="Canada/Eastern" xmlns="uri:oozie:coordinator:0.1">
<action>
<workflow>
<app-path>${nameNode}/${rootDirectory}/workflow.xml</app-path>
</workflow>
</action>
</coordinator-app>
Step 3: Create workflow.xml
This workflow.xml file sends email on success and failure to the respective configured in coordinator.properties
<workflow-app xmlns='uri:oozie:workflow:0.3' name='shell-wf'>
<start to='shell1' />
<action name='shell1'>
<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>${shellScript}</exec>
<argument>D1</argument>
<argument>D2</argument>
<file>${shellScript}#${shellScript}</file> <!--Copy the executable to compute node's current working directory -->
</shell>
<ok to="sendEmail"/>
<error to="kill-email"/>
</action>
<action name="sendEmail">
<email xmlns="uri:oozie:email-action:0.1">
<to>${emailToAddress}</to>
<subject>Email notifications for job ${wf:id()} success</subject>
<body>The job wf ${wf:id()} successfully completed.</body>
</email>
<ok to="end"/>
<error to="end"/>
</action>
<action name="kill-email">
<email xmlns="uri:oozie:email-action:0.1">
<to>${emailToAddress}</to>
<subject>Email notifications for job ${wf:id()} failure</subject>
<body>The job wf ${wf:id()} Failed. More details about the job : ${oozie_web}/${wf:id()}//</body>
</email>
<ok to="killAction"/>
<error to="killAction"/>
</action>
<kill name="killAction">
<message>Script failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
</kill>
<end name='end' />
</workflow-app>
oozie.use.system.libpath=true
nameNode=hdfs://<name>:8020
jobTracker=hdfs://<name>:8021
dfs.namenode.kerberos.principal=<value from hdfs-site.xml>
yarn.resourcemanager.principal=<value from hdfs-site.xml>
dfs.web.authentication.kerberos.keytab=<value from hdfs-site.xml>
dfs.web.authentication.kerberos.principal=<value from hdfs-site.xml>
nfs.kerberos.principal=<value from hdfs-site.xml>
nfs.keytab.file=/<value from hdfs-site.xml>
queueName=default
rootDirectory=<path>
oozie.coord.application.path=${nameNode}/${rootDirectory}/coordinator.xml
shellScript=<shell script.sh name>
shellScriptPath=<shell script path>
emailToAddress=<email address>
oozie.email.smtp.host=<value from oozie-site.xml>
oozie.email.smtp.port=<value from oozie-site.xml>
oozie_web=<value from oozie-site.xml>
Step 2: Create coordinator.xml file
<coordinator-app name="name" frequency="${coord:days(1)}" start="2015-07-13T20:20Z" end="2015-07-13T20:59Z" timezone="Canada/Eastern" xmlns="uri:oozie:coordinator:0.1">
<action>
<workflow>
<app-path>${nameNode}/${rootDirectory}/workflow.xml</app-path>
</workflow>
</action>
</coordinator-app>
Step 3: Create workflow.xml
This workflow.xml file sends email on success and failure to the respective configured in coordinator.properties
<workflow-app xmlns='uri:oozie:workflow:0.3' name='shell-wf'>
<start to='shell1' />
<action name='shell1'>
<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>${shellScript}</exec>
<argument>D1</argument>
<argument>D2</argument>
<file>${shellScript}#${shellScript}</file> <!--Copy the executable to compute node's current working directory -->
</shell>
<ok to="sendEmail"/>
<error to="kill-email"/>
</action>
<action name="sendEmail">
<email xmlns="uri:oozie:email-action:0.1">
<to>${emailToAddress}</to>
<subject>Email notifications for job ${wf:id()} success</subject>
<body>The job wf ${wf:id()} successfully completed.</body>
</email>
<ok to="end"/>
<error to="end"/>
</action>
<action name="kill-email">
<email xmlns="uri:oozie:email-action:0.1">
<to>${emailToAddress}</to>
<subject>Email notifications for job ${wf:id()} failure</subject>
<body>The job wf ${wf:id()} Failed. More details about the job : ${oozie_web}/${wf:id()}//</body>
</email>
<ok to="killAction"/>
<error to="killAction"/>
</action>
<kill name="killAction">
<message>Script failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
</kill>
<end name='end' />
</workflow-app>
No comments:
Post a Comment