如果本地节点上也存在相同的路径,HDFS 会感到困惑
HDFS getting confused if same path is present on local node as well
我使用的是CDH 5.4.1集群提供的Hadoop。
我面临的问题是 HDFS 上有一个路径为 /tmp/data 的目录
它有一些 csv 文件说 abc.csv
现在这个相同的文件夹也出现在节点(比如节点 1)的一个本地 linux fs 上,并且包含一个 csv 文件 xyz.csv.
当我从 node1 运行 执行以下命令时:hdfs dfs -ls /tmp/data/*.csv
我希望输出显示 abc.csv 但是我收到一条错误消息
ls: `/tmp/data/xyz.csv': No such file or directory
当 运行 在其本地 linux fs 上没有相同文件夹路径的其他节点上时,相同的命令给出正确的输出。
我的理解是,因为我正在使用 hdfs dfs
命令,Hadoop 应该只在 dfs space 中查找,而不是与本地 [=35] 混淆=] 文件系统,但这似乎不正确。
请指出此行为背后的原因是什么?
My understanding was that since I am using hdfs dfs command hadoop should be looking in dfs space only and not get confused with local linux fs
仅当您已正确设置 Hadoop 客户端 XML 配置文件以使用 hdfs://
URI 而不是 file://
在core-site.xml中,fs.defaultFS
的默认值为file://
此值应在 CDH 或 HDP 托管环境中正确设置,但
您将看到 Bash(或您选择的任何 shell)在将参数传递给 HDFS 命令之前通配符和扩展通配符的效果。在您的本地文件系统中有一个文件位于 /tmp/data/xyz.csv。因此,真正被调用的命令是 hdfs dfs -ls /tmp/data/xyz.csv
。由于 xyz.csv 在您的 HDFS 集群中不存在,因此报告为未找到文件。
您可以通过将参数用单引号引起来来解决此问题,以防止通配扩展:
> # local file system
> ls /tmp/data/*.csv
/tmp/data/xyz.csv
> # attempting to check HDFS, but wildcard expansion happens before invoking command
> hdfs dfs -ls /tmp/data/*.csv
ls: `/tmp/data/xyz.csv': No such file or directory
> # wrap in single quotes to prevent globbing expansion
> hdfs dfs -ls '/tmp/data/*.csv'
-rw-r--r-- 3 naurc001 supergroup 0 2017-02-02 11:52 /tmp/data/abc.csv
我使用的是CDH 5.4.1集群提供的Hadoop。 我面临的问题是 HDFS 上有一个路径为 /tmp/data 的目录 它有一些 csv 文件说 abc.csv 现在这个相同的文件夹也出现在节点(比如节点 1)的一个本地 linux fs 上,并且包含一个 csv 文件 xyz.csv.
当我从 node1 运行 执行以下命令时:hdfs dfs -ls /tmp/data/*.csv
我希望输出显示 abc.csv 但是我收到一条错误消息
ls: `/tmp/data/xyz.csv': No such file or directory
当 运行 在其本地 linux fs 上没有相同文件夹路径的其他节点上时,相同的命令给出正确的输出。
我的理解是,因为我正在使用 hdfs dfs
命令,Hadoop 应该只在 dfs space 中查找,而不是与本地 [=35] 混淆=] 文件系统,但这似乎不正确。
请指出此行为背后的原因是什么?
My understanding was that since I am using hdfs dfs command hadoop should be looking in dfs space only and not get confused with local linux fs
仅当您已正确设置 Hadoop 客户端 XML 配置文件以使用 hdfs://
URI 而不是 file://
在core-site.xml中,fs.defaultFS
的默认值为file://
此值应在 CDH 或 HDP 托管环境中正确设置,但
您将看到 Bash(或您选择的任何 shell)在将参数传递给 HDFS 命令之前通配符和扩展通配符的效果。在您的本地文件系统中有一个文件位于 /tmp/data/xyz.csv。因此,真正被调用的命令是 hdfs dfs -ls /tmp/data/xyz.csv
。由于 xyz.csv 在您的 HDFS 集群中不存在,因此报告为未找到文件。
您可以通过将参数用单引号引起来来解决此问题,以防止通配扩展:
> # local file system
> ls /tmp/data/*.csv
/tmp/data/xyz.csv
> # attempting to check HDFS, but wildcard expansion happens before invoking command
> hdfs dfs -ls /tmp/data/*.csv
ls: `/tmp/data/xyz.csv': No such file or directory
> # wrap in single quotes to prevent globbing expansion
> hdfs dfs -ls '/tmp/data/*.csv'
-rw-r--r-- 3 naurc001 supergroup 0 2017-02-02 11:52 /tmp/data/abc.csv