hdfs(hadoop分布式文件系统) 常用操作命令

[hadoop fs -]=[hdfs dfs -]
(1)启动集群
全启动:
start-all.sh
start-dfs.sh 单独
start-yarn.sh 单独
单独启动节点:
hadoop-daemon.sh start namenode
关闭:
hadoop-daemon.sh stop namenode
关闭所有:
stop-all.sh
stop-dfs.sh 单独
stop-yarn.sh 单独

(2)帮助信息
hadoop fs -help appendToFile
介绍 语法 + 解释
hdfs dfs -lsr / 查看详细文件信息(常用)
(3)上传文件到hdfs①
hdfs dfs -put body.txt /centos/file/body.txt
(4) 上传文件到hdfs②
hdfs dfs -copyFromLocal body.txt /centos/file/body.txt
(5) 下载文件到本地①
hdfs dfs -get /centos/file/body.txt .
(6)下载文件到本地②
hdfs dfs -copyToLocal /centos/file/body.txt .

(7)hdfs文件内容不能随意修改但可以追加内容 appendToFile
hdfs dfs -appendToFile body.txt /centos/file/hello.txt

(xx)echo use hdfs ! >body.txt 内容重定向到文件中
(8)查看目录信息
hadoop fs -lsr / 查看详细文件信息
(9)创建目录
hadoop fs -mkdir -p /uer/atiguigu/
递归创建文件夹
不加p只能创建一层
(10)从本地剪切到hdfs
hdfs dfs -moveFromLocal body.txt /centos/file
(11) cat 显示文件内容
hdfs dfs -cat /centos/file/body.txt
(12) tail 显示文件末尾内容
hdfs dfs -tail /centos/file/body.txt
(13)权限问题
hdfs dfs -chmod xxx /centos/file/body.txt
u g o
hdfs dfs -chown root:root /centos/file/body.txt
chown:可以同时修改用户和用户组
chgrp 只能修改用户组
(14)删除问题
hdfs dfs -rm /centos/file/body.txt 只能删除文件
hdfs dfs -rmr /centos/file/ 可以递归删除文件夹/删除文件 (常用)
hdfs dfs -rmr /centos/file/ 可以删除空目录
(15)hdfs 内部复制和移动文件
hdfs dfs -cp /centos/file/body.txt /usr/antiguigu/
hdfs dfs -mv /centos/file/body.txt /usr/antiguigu/
(16)文件系统可用空间信息
hdfs dfs -df -h /
(17) 特定文件夹可用空间信息
hdfs dfs -du -s -h /centos/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值