【发布时间】:2017-04-17 17:44:35
【问题描述】:
我在 HDFS 中有一个 shell 脚本。我已经使用以下工作流程在 oozie 中安排了这个脚本。
工作流程:
<workflow-app name="Shell_test" xmlns="uri:oozie:workflow:0.5">
<start to="shell-8f63"/>
<kill name="Kill">
<message>Action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
</kill>
<action name="shell-8f63">
<shell xmlns="uri:oozie:shell-action:0.1">
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<exec>shell.sh</exec>
<argument>${input_file}</argument>
<env-var>HADOOP_USER_NAME=${wf:user()}</env-var>
<file>/user/xxxx/shell_script/lib/shell.sh#shell.sh</file>
<file>/user/xxxx/args/${input_file}#${input_file}</file>
</shell>
<ok to="End"/>
<error to="Kill"/>
</action>
<end name="End"/>
职位属性
nameNode=xxxxxxxxxxxxxxxxxxxx
jobTracker=xxxxxxxxxxxxxxxxxxxxxxxx
queueName=default
oozie.use.system.libpath=true
oozie.wf.application.path=${nameNode}/user/${user.name}/xxxxxxx/xxxxxx
参数文件
tableA
tableB
tablec
tableD
现在 shell 脚本针对 args 文件中的单个作业名称运行。如何安排这个 shell 脚本并行运行。
我希望脚本同时运行 10 个作业。
这样做需要哪些步骤。我应该对工作流程进行哪些更改。
我是否应该为运行 10 个并行作业创建 10 个工作流。或者处理这个问题的最佳方案是什么。
我的 shell 脚本:
#!/bin/bash
[ $# -ne 1 ] && { echo "Usage : $0 table ";exit 1; }
table=$1
job_name=${table}
sqoop job --exec ${job_name}
我的 sqoop 作业脚本:
sqoop job --create ${table} -- import --connect ${domain}:${port}/${database} --username ${username} --password ${password} --query "SELECT * from ${database}.${table} WHERE \$CONDITIONS" -m 1 --hive-import --hive-database ${hivedatabase} --hive-table ${table} --as-parquetfile --incremental append --check-column id --last-value "${last_val}" --target-dir /user/xxxxx/hive/${hivedatabase}.db/${table} --outdir /home/$USER/logs/outdir
【问题讨论】:
-
他们总是
10吗?为什么不使用fork和join? -
那么你应该在脚本本身中处理它。这个脚本是关于什么的?
标签: shell hadoop hdfs oozie oozie-coordinator