Hadoop常用的操作命令(2)

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]

网站栏目:Hadoop常用的操作命令(2)
文章起源:http://lszwz.com/article/jdopgo.html

其他资讯

售后响应及时

7×24小时客服热线

数据备份

更安全、更高效、更稳定

价格公道精准

项目经理精准报价不弄虚作假

合作无风险

重合同讲信誉,无效全额退款