无法复制输入目录中的.xml文件?

dfty9e19  于 2021-06-02  发布在  Hadoop
关注(0)|答案(2)|浏览(338)

我已经在ubuntu15.04中安装了hadoop2.7.1。我想将hadoop中的文件复制到我创建并使用以下命令的输入文件夹: $ mkdir input (在hadoop\u dev中创建输入目录) $ cp etc/hadoop/*.xml input (将所有xml文件复制到输入文件夹)
但它给出了一个错误: cp: target ‘input’ is not a directory 谢谢。

nbysray5

nbysray51#

hadoop文件系统(fs)shell包括各种类似shell的命令,这些命令直接与hadoop分布式文件系统(hdfs)以及hadoop支持的其他文件系统交互,例如本地fs、hftp fs、s3 fs(amazon)、azure blob(micorsoft azure blob)和其他文件系统。
参考hadoop命令指南有更多的信息,包括hadoop fs命令的细节,应该用来实现您的要求,其他可以在参考指南中看到。

copyFromLocal

Usage: hadoop fs -copyFromLocal <localsrc> URI

Similar to put command, except that the source is restricted to a local file reference.

Options:

The -f option will overwrite the destination if it already exists.

mkdir

Usage: hadoop fs -mkdir [-p] <paths>

Takes path uri’s as argument and creates directories.

Options:

The -p option behavior is much like Unix mkdir -p, creating parent directories along the path.
Example:

hadoop fs -mkdir /user/hadoop/dir1 /user/hadoop/dir2
hadoop fs -mkdir hdfs://nn1.example.com/user/hadoop/dir hdfs://nn2.example.com/user/hadoop/dir
Exit Code:

Returns 0 on success and -1 on error.
to94eoyn

to94eoyn2#

如果尝试将配置文件从本地文件系统复制到hdfs,请尝试以下操作:
1在hdfs中创建目录:

hdfs dfs -mkdir /input

2将文件复制到hdfs:

hdfs dfs -put /etc/hadoop/*.xml /input/

更新1:
在/home/hadoopuser/.bashrc中导出hadoop命令(导出hdfs命令)

export HADOOP_HOME=/path/to/hadoop/folder
export PATH=$PATH:$HADOOP_HOME/bin

相关问题