当前位置:   article > 正文

HDFS的基本操作_第1关:hdfs的基本操作

第1关:hdfs的基本操作

前提要求:已成功搭建Hadoop集群
【实验描述】
Hadoop提供也hadoop分布式文件系统交互的命令,通过了解Hadoop shell命令的用法。掌握对hadoop分布式系统的操作;以下是一些基础命令操作。

  1. 查看hdfs分布式系统根目录下所有文件和文件夹信息
[root@hadoop1 ~]# hdfs dfs -ls /
  • 1
  1. 利用hdfs dfs –mkdir 命令在hdfs上创建test1、test2和test3目录。
[root@hadoop1 ~]# hdfs dfs -mkdir /test1
[root@hadoop1 ~]# hdfs dfs -mkdir /test2
[root@hadoop1 ~]# hdfs dfs -mkdir /test3
[root@hadoop1 ~]# hdfs dfs -ls /
Found 3 items
drwxr-xr-x   - root supergroup          0 2021-11-12 10:18 /test1
drwxr-xr-x   - root supergroup          0 2021-11-12 10:18 /test2
drwxr-xr-x   - root supergroup          0 2021-11-12 10:20 /test3
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  1. 在本地系统编辑文件test1.txt,操作命令如下:
[root@hadoop1 ~]# vim test1.txt
添加以下内容:
filename test1.txt

#同样操作创建test2.txt和test3.txt文件。
#利用hdfs dfs –put命令上传文件test1.txt到hdfs的/test1目录;上传文件test2.txt到hdfs的/test2.txt目录;上传文件test3.txt到hdfs的/test3.txt目录,操作命令如下:
[root@hadoop1 ~]# hdfs dfs -put test1.txt /test1
[root@hadoop1 ~]# hdfs dfs -put test2.txt /test2
[root@hadoop1 ~]# hdfs dfs -put test3.txt /test3

#上传成功后,利用hdfs dfs –ls命令进行查看
[root@hadoop1 ~]# hdfs dfs -ls /test1
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/734155
推荐阅读
相关标签
  

闽ICP备14008679号