Oozie Email Action Configuration
- Shell Action can be used to send emails for process tasks in oozie, Email Action must be configured with to recipient, cc recipient (optional), email subject, email content, multiple recipients can be used, split recipients address.
- Email Action is executed synchronously, and the process task must wait for the current node's email to be sent before executing subsequent node tasks.
- All node values of Email Action can use EL expressions
Email Action format
- to 和 cc 命令都用来指定邮件的收件人,多个收件人地址用逗号分割,to 必须有,cc可选
- subject 指定邮件标题,body指定邮件内容可以指定邮件内容格式(content type)为 "text/html",默认是"text/plain"
- attachment 用来指定 hdfs中的文件作为附件,多个文件逗号分割,非完全路径(不是以hdfs://开头的路径)默认为hdfs上的路径,不能使用本地文件作为附件。
Oozie Email 配置
oozie-site.xml中加入邮件服务器 和发件人信息 ,如果使用smtp协议必须开通
<property>
<name>oozie.email.smtp.host</name>
<value>smtp.qq.com</value>
</property>
<property>
<name>oozie.email.smtp.port</name>
<value>587</value>
</property>
<property>
<name>oozie.email.from.address</name>
<value>[email protected]</value>
</property>
<property>
<name>oozie.email.smtp.auth</name>
<value>true</value>
</property>
<property>
<name>oozie.email.smtp.username</name>
<value>[email protected]</value>
</property>
<property>
<name>oozie.email.smtp.password</name>
<value>bfxymlcmuuorbdef</value>
</property>
Email Action 使用实例一:Oozie自带案例运行
1,新建 job.properties
2,workflow.xml
3,首先在本地的测试节点上创建文件夹
mkdir -p /opt/mydata/user/oozie/xwj_test/apps/shell/email
4,在hdfs上创建目录 hdfs dfs -mkdir -p /user/oozie/xwj_test/apps/shell/email
5,将上述文件上传到新建好的目录中
cd /opt/mydata/user/oozie/xwj_test/apps/shell/email
6,将本地文件 上传到hdfs目录中
hdfs dfs -put ../email/* /user/oozie/xwj_test/apps/shell/email
7,查看hdfs上的目录文件是否存在
hdfs dfs -ls -r /user/oozie/xwj_test/apps/shell/email
8,切换yarn用户重新提交任务
su yarn
oozie job -oozie http://hadoop-node0.novalocal:11000/oozie -config /opt/mydata/user/oozie/xwj_test/apps/shell/
email/job.properties -run
查看邮件结果