温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Hadoop常用的操作命令(2)

发布时间:2020-07-25 14:25:41 来源:网络 阅读:370 作者:小疯魔 栏目:大数据
Hadoop常用的操作命令

列出目录清单
[root@centos67 ~]# hdfs dfs -ls /

递归列出目录清单
[root@centos67 ~]# hdfs dfs -lsr /

创建目录
[root@centos67 ~]# hdfs dfs -mkdir /input/test

删除目录
[root@centos67 ~]# hdfs dfs -rmr /input/test

创建文件
[root@centos67 ~]# hdfs dfs -touchz /input/test/test.txt

文件重命名
[root@centos67 ~]# hdfs dfs -mv /input/test/test.txt /input/test/test.exe

上传文件
[root@centos67 ~]# hdfs dfs -put ./test.log /input/test/

下载文件
[root@centos67 ~]# hdfs dfs -get /input/test/test.log ./

查看文件内容
[root@centos67 ~]# hdfs dfs -cat /input/test/test.log

删除文件
[root@centos67 ~]# hdfs dfs -rm /input/test/test.log

复制文件
[root@centos67 ~]# hdfs dfs -cp /input/test/test.log /test.log

统计目录下的所有文件大小
[root@centos67 ~]# hdfs dfs -du /input

统计整个目录大小
[root@centos67 ~]# hdfs dfs -dus /input

将指定目录下所有文件内容保存为一个文件,并且下载到本地
[root@centos67 ~]# hdfs dfs -getmerge /input/test ./test.txt

查看文件的最后1KB内容
[root@centos67 ~]# hdfs dfs /input/test/test.log

修改文件属主属组,可以加-R递归
[root@centos67 ~]# hdfs dfs -chown xiaomo:xiaomo /input/test/test.log

修改文件权限,可以加-R递归
[root@centos67 ~]# hdfs dfs -chmod 700 /input/test/test.log

统计当前文件/目录信息
目录数、文件数、文件大小、文件名/目录名
[root@centos67 ~]# hdfs dfs -count /input/test/test.log

清空回收站,文件被删除时,它首先会移到临时目录.Trash/中,
当超过延迟时间之后,文件才会被永久删除 
[root@centos67 ~]# hdfs dfs -expunge

[root@centos67 ~]# hdfs dfs -test /input
对/input进行如下类型的检查: 
-e 是否存在,如果存在,返回0,否则返回1 
-z 是否为空,如果长度为0,返回0,否则返回1 
-d 是否为目录,如果为目录,返回0,否则返回1 

显示文件内容,压缩文件会解压
[root@centos67 ~]# hdfs dfs -text /input/test/test.log

查看某个命令的帮助
[root@centos67 ~]# hdfs dfs -help ls
[root@centos67 ~]# hdfs dfs -help touchz

将正在运行的hadoop作业kill掉
[root@centos67 ~]# hdfs job –kill [job-id]


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI