大数据Hadoop学习记录(1)----HDFS目录和文件Shell操作

HDFS目录和文件Shell操作

推荐使用Ubuntu16+Hadoop 2.7.x版本,不会出现什么问题

1、首先进入Hadoop环境
cd /usr/local/hadoop
2、启动Hadoop
./sbin/start-dfs.sh
3、查看Hadoop是否启动成功
jps

在这里插入图片描述
看到以上内容说明启动成功了

4、查看hadoop fs支持的所有命令
./bin/hdfs dfs
5、查看Hadoop下put的使用方法
./bin/hadoop fs -help put
6、创建一个用户目录
./bin/hdfs dfs -mkdir -p /user/hadoop	
7、用shell查询命令查看我们在路径user下面创建的文件夹
./bin/hdfs dfs -ls /user

在这里插入图片描述

8、创建一个二级目录, 在根目录下创建一个input文件夹
./bin/hdfs dfs -mkdir /input
9、查看根目录下创建的文件夹
./bin/hdfs dfs -ls /

在这里插入图片描述

10、删除目录,删除刚才创建的input文件夹
./bin/hdfs dfs -rm -r /input
11、查看input文件夹是否被删除
./bin/hdfs dfs -ls /

在这里插入图片描述
可以看见创建的input文件夹已经被删除了

12、创建一个txt文件、编辑文件内容
touch first.txt
gedit first.txt

在这里插入图片描述

13、将first.txt文件上传到user/Hadoop/input目录下
./bin/hdfs dfs -put ./first.txt  /user/hadoop/input
14、在[user/hadoop/input]目录下查看上传的first.txt文件
./bin/hdfs dfs -ls /user/hadoop/input

在这里插入图片描述

15、查看first.txt文件内容
./bin/hdfs dfs  -cat /user/hadoop/input/first.txt

在这里插入图片描述

16、将HDFS中的first.txt文件下载到本地文件系统中
./bin/hdfs dfs -get /user/hadoop/input/first.txt /home/zhangjian/下载

在这里插入图片描述
已经成功将first.txt文件从HDFS文件系统下载到本地了

  • 2
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值