简体   繁体   English

使用-i init脚本的Oozie Hive Action

[英]Oozie Hive Action Using -i init script

How can I run an Oozie Hive or Hive2 Action with init scripts? 如何使用初始化脚本运行Oozie Hive或Hive2 Action?

In the CLI this can be usually done via the -i init.hive argument; 在CLI中,这通常可以通过-i init.hive参数来完成。 however when using this in an Oozie Action via <argument>-i init.hive</argument> the workflow stops with an error. 但是,当通过<argument>-i init.hive</argument>在Oozie Action中使用此功能时,工作流将因错误而停止。

I linked the init.hive file with the <file>init.hive#init.hive</file> property and it is available in the local appcache directory. 我用<file>init.hive#init.hive</file>属性链接了init.hive文件,该<file>init.hive#init.hive</file>在本地appcache目录中可用。

$ 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

The error (in the local appcache) is the following 错误(在本地应用程序缓存中)如下

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)

The hive2 action looks like this (the complete workflow can be found on Github https://github.com/chaosmail/oozie-bugs/tree/master/simple-hive-init/simple-hive-init-wf ) 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>

Edit 1: added workflow action 编辑1:添加工作流操作

[Recap of the comments thread above, plus some extra stuff in retrospect] [上面评论线程的回顾,以及回顾中的一些额外内容]

The Oozie documentation states that you may have multiple <argument> elements in your Action, which hints that the arguments must be provided separately. Oozie文档指出,您的操作中可能有多个<argument>元素,这暗示必须单独提供参数。
In retrospect, it makes sense -- on a command line, it's the shell that would parse the list of arguments into an args[] array for the Java executable, but Oozie is not a shell interpreter... 回想起来,这很有意义-在命令行上, 是将参数列表解析 为Java可执行文件 args[] 数组的shell,但是Oozie不是shell解释器...

And experience shows that Beeline accepts two syntax variants for its command-line args... 经验表明Beeline的命令行参数接受两种语法变体...

  • -xValue (one arg) means option -x with associated Value -xValue (一个arg)表示具有相关Value选项-x
  • -x followed by Value (two args) means the same thing -x后跟Value (两个args)表示同一件事


So you have two correct ways to pass command-line arguments to Beeline via Oozie: 因此,您有两种通过Oozie将命令行参数传递给Beeline的正确方法:

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

On the other hand, <argument>-x Value</argument> would fail, because in single-arg syntax, Beeline considers that the separator space should be part of the value...! 另一方面, <argument>-x Value</argument>会失败,因为在单参数语法中,Beeline认为分隔符空间应该是值的一部分...!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM