hdfs所有命令行均有$HADOOP_HOME/bin/hadoop脚本执行,不指定参数bin/hadoop会显示所有命令的描述,可通过hadoop fs -help查看命令帮助。

hdfs命令执行样式为hadoop fs -shell

一、文件上传与下载

1、文件上传,将文件从linux本地上传至hdfs

方法1:hadoop fs -put  linux文件 hdfs文件

方法2:hadoop fs -copyFromLocal linux文件 hdfs文件

[hadoop@localhost ~]$ hadoop fs -put /tmp/test1.txt /
[hadoop@localhost ~]$ hadoop fs -copyFromLocal /tmp/test2.txt /tmp/test2test2.txt /

上传的时候可以对文件重命名

 

2、文件下载,将文件从hdfs下载到linux本地

方法1:hadoop fs -get  hdfs文件 linux文件

方法2:hadoop fs -copyToLocal  hdfs文件 linux文件

[hadoop@localhost ~]$ hadoop fs -get /test1.txt /tmp/
[hadoop@localhost ~]$ hadoop fs -copyToLocal /test2test2.txt /tmp/test2.txt

下载的时候也可以对文件重命名

 

二、目录操作

创建目录:例如hadoop fs -mkdir /test

 

三、文件操作

查看文件列表:例如hadoop fs -ls /test/

查看文件内容:例如hadoop fs -cat /test/a.txt

删除文件:例如hadoop fs -rm /test/a.txt

 

相关文章:

  • 2021-11-18
  • 2022-01-07
  • 2021-07-11
  • 2021-08-08
  • 2022-12-23
  • 2021-10-17
  • 2021-09-28
猜你喜欢
  • 2021-11-20
  • 2021-11-06
  • 2021-12-23
  • 2021-11-18
  • 2022-12-23
  • 2021-10-23
相关资源
相似解决方案