目录 1. shell action 2. shell action 日志 3. shell action 限制 1. shell action shell action运行一个shell命令,需要配置的有job-tracker,name-node和一些必要的参数。 经过配置,在启动shell action之前可以创建或删除hdfs文件夹。 可以通过配置文件
目录1. shell action
2. shell action 日志
3. shell action 限制
1. shell actionshell action运行一个shell命令,需要配置的有job-tracker,name-node和一些必要的参数。
经过配置,在启动shell action之前可以创建或删除hdfs文件夹。
可以通过配置文件(通过job-xml元素)给定配置信息,或者是用内嵌的configuration元素进行配置。
可以在内嵌的configuration里面使用el表达式,在configuration里面配置的信息会覆盖job-xml里面相同的值。
需要注意的是,hadoop的mapred.job.tracker和fs.default.name属性不可以在内嵌的configuration里面配置。
跟hadoop的map-reduce jobs一样,可以添加附件到sqoop job里面。具体参见【http://archive.cloudera.com/cdh/3/oozie/workflowfunctionalspec.html#a3.2.2.1_adding_files_and_archives_for_the_job】
shell任务的标准输出(stdout)在shell运行结束之后是可用的。这些信息可以被决策结点使用。如果shell job的输出被配置成可用的,那shell命令必须包含以下两个参数:
输出的格式必须是合法的java属性文件。输出的大小不能超过2kb。语法:
... [job-tracker] [name-node] ... ... [shell settings file] [property-name] [property-value] ... [shell-command] [arg-value] ... [arg-value] [var1=value1] ... [varn=valuen] [file-path] ... [file-path] ... ...
prepare元素里面配置启动job前要删除或者创建的文件夹,文件夹路径必须是以hdfs://host:port开头。
job-xml指定一个存在的配置文件。
configuration里面配置传递给sqoop job的参数。
exec元素包含要执行的shell命令的路径。可以给shell命令添加参数。
argument元素指定要传递给shell脚本的参数。
env-var包含传递给shell命令的环境变量。env-var只能包含一个环境变量和值。如果这个环境变量包含像$path一样的,那它必须写成path=$path:mypath。不能用${path},因为它将会被el解析。
capture-output元素指定用来捕获shell脚本的标准输出。可以通过string action:output(string node, string key)函数【el函数】来获得输出。
例子:
${jobtracker} ${namenode} mapred.job.queue.name ${queuename} ${exec} a b ${exec}#${exec} script failed, error message[${wf:errormessage(wf:lasterrornode())}]
其中,job属性文件如下:
oozie.wf.application.path=hdfs://localhost:8020/user/kamrul/workflows/script#execute is expected to be in the workflow directory.#shell script to runexec=script.sh#cpp executable. executable should be binary compatible to the compute node os.#exec=hello#perl script#exec=script.pljobtracker=localhost:8021namenode=hdfs://localhost:8020queuename=default
运行jar里面的java程序:
${jobtracker} ${namenode} mapred.job.queue.name ${queuename} java -classpath ./${exec}:$classpath hello ${exec}#${exec} script failed, error message[${wf:errormessage(wf:lasterrornode())}]
属性会复制指定的文件到运行该脚本的机器上。当提示找不到文件的时候,试试file
对应的属性文件是:
oozie.wf.application.path=hdfs://localhost:8020/user/kamrul/workflows/script#hello.jar file is expected to be in the workflow directory.exec=hello.jarjobtracker=localhost:8021namenode=hdfs://localhost:8020queuename=default
2. shell action 日志shell action的stdout和stderr输出被重定向到运行该脚本的oozie执行器上的map-reduce任务的stdout。
除了在oozie的web网页上可以看到少部分日志,还可以在hadoop的job-tracker的网页上看到详细的日志信息。
3. shell action 限制虽然shell action可以执行任意的shell命令,但是有以下几个限制:
不支持交互命令。
不能通过sudo来让不同用户执行命令。
用户必须明确的上传所需要的第三方库。oozie通过hadoop的分布式缓冲来上传、打标签、使用。
shell命令会在任意一个hadoop 计算节点上运行,但是计算节点上默认安装的工具集可能会不一样。不过在所有的计算节点上,通常都装有大部分普通的unix工具。因此需要明确的很重要的一点是:oozie只支持有被安装到计算节点上的命令或者通过分布式缓存上传的命令。也就是说,我们必须通过file上传我们要用到的文件。
http://archive.cloudera.com/cdh/3/oozie/dg_shellactionextension.html
转载请注明: 转载自http://jyd.me/
本文链接地址: oozie shell action 配置