bash Oozie Shell 操作问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17993574/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 06:06:06  来源:igfitidea点击:

Oozie Shell Action Issue

apachebashclouderaoozie

提问by Kasa

I'm trying to implement a simple ls command through a shell action, but i'm facing an error,

我正在尝试通过 shell 操作实现一个简单的 ls 命令,但是我遇到了错误,

Exact Issue:script:

确切问题:脚本:

#!/bin/bash
ls /home/my-directory

stdout logs:

标准输出日志:

>>> Invoking Shell command line now >>
Exit code of the Shell command 2
<<< Invocation of Shell command completed <<<
<<< Invocation of Main class completed <<<
Failing Oozie Launcher, Main class [org.apache.oozie.action.hadoop.ShellMain], exit code [1]
Oozie Launcher failed, finishing Hadoop job gracefully
Oozie Launcher ends


stderr logs:

标准错误日志:

ls: cannot access /home/my-directory: No such file or directory
Failing Oozie Launcher, Main class [org.apache.oozie.action.hadoop.ShellMain], exit code [1]

There is a directory /home/my-directory and it also has sub-directories.

有一个目录 /home/my-directory ,它还有子目录。

It will be great if anyone can provide me a solution to this.

如果有人可以为我提供解决方案,那就太好了。

回答by mister blinky

You don't have control over which node in your cluster Oozie runs the shell action on. Therefore, your script should never reference the local file system of any particular node in your cluster.

您无法控制 Oozie 在集群中的哪个节点上运行 shell 操作。因此,您的脚本不应引用集群中任何特定节点的本地文件系统。

E.g., say your cluster contains two nodes NODE1 and NODE2 and your script references a file that is on NODE1's FS. When Oozie runs your script, it can run it from either NODE1 or NODE2 (remember -- you put your script, job.properties, workflow.xml into HDFS, which is distributed across NODE1 and NODE2). If the script is run from NODE2, then you'll get the No such file or directory error because the file isn't present on the local FS of NODE2.

例如,假设您的集群包含两个节点 NODE1 和 NODE2,并且您的脚本引用了 NODE1 的 FS 上的文件。当 Oozie 运行您的脚本时,它可以从 NODE1 或 NODE2 运行它(请记住——您将您的脚本、job.properties、workflow.xml 放入分布在 NODE1 和 NODE2 之间的 HDFS)。如果脚本是从 NODE2 运行的,那么您将收到 No such file or directory 错误,因为 NODE2 的本地 FS 上不存在该文件。

The important point is that any script you run via Oozie must only reference paths and files in HDFS. If you need a file from the FS local to one node to be referenced, put it in HDFS and use the path within HDFS to reference the file.

重要的一点是,您通过 Oozie 运行的任何脚本只能引用 HDFS 中的路径和文件。如果需要从FS本地到一个节点的一个文件被引用,把它放在HDFS中并使用HDFS内的路径来引用该文件。