Oozie Hive 操作使用 -i init 脚本

Oozie Hive Action Using -i init script

我如何运行 Oozie Hive 或 Hive2 动作与初始化脚本?

在 CLI 中,这通常可以通过 -i init.hive 参数来完成;但是,当通过 <argument>-i init.hive</argument> 在 Oozie Action 中使用它时,工作流会因错误而停止。

我将 init.hive 文件与 <file>init.hive#init.hive</file> 属性 链接在一起,它在本地应用程序缓存目录中可用。

$ ll appcache/application_1480609892100_0274/container_e55_1480609892100_0274_01_000001/ | grep init
> lrwxrwxrwx 1 root root    42 Jan 12 12:24 init.hive -> /hadoop/yarn/local/filecache/519/init.hive

错误(在本地appcache中)如下

Connecting to jdbc:hive2://localhost:10000/
Connected to: Apache Hive (version 1.2.1000.2.4.0.0-169)
Driver: Hive JDBC (version 1.2.1000.2.4.0.0-169)
Transaction isolation: TRANSACTION_REPEATABLE_READ
Running init script  init.hive
  init.hive (No such file or directory)

hive2 操作如下所示(完整的工作流程可以在 Github https://github.com/chaosmail/oozie-bugs/tree/master/simple-hive-init/simple-hive-init-wf 上找到)

<action name="test-action">
<hive2 xmlns="uri:oozie:hive2-action:0.1">
  <jdbc-url>${jdbcURL}</jdbc-url>
  <script>query.hive</script>
  <argument>-i init.hive</argument>
  <file>init.hive#init.hive</file>
</hive2>
<ok to="end"/>
<error to="fail"/>
</action>

编辑 1:添加了工作流程操作

[回顾上面的评论线程,再加上一些额外的回顾]

Oozie 文档指出您的 Action 中可能有多个 <argument> 元素,这暗示必须单独提供参数。
回想起来,这是有道理的——在命令行上, shell 会将参数列表解析为 args[] Java 可执行文件的数组,但 Oozie 不是 shell 解释器...

经验表明,Beeline 的 command-line args 接受两种语法变体...

  • -xValue(一个参数)表示选项 -x 与关联的 Value
  • -x 后跟 Value (两个参数)意思相同


所以你有两种正确的方法通过 Oozie 将 command-line 参数传递给 Beeline:

  • <argument>-xValue</argument>
  • <argument>-x</argument> <argument>Value</argument>

另一方面,<argument>-x Value</argument> 会失败,因为在 single-arg 语法中,Beeline 认为分隔符 space 应该是值的一部分...!