Hadoop HDFS操作命令总结

1.列出根目录下所有的目录或文件

hadoop fs -ls /

2.列出/logs目录下的所有目录和文件

hadoop fs -ls /logs

3.列出/user目录及其子目录下的所有文件(谨慎使用)

hadoop fs -ls -R /user

4.创建/soft目录

hadoop fs -mkdir /soft

5.创建多级目录

hadoop fs -mkdir -p /apps/windows/2017/01/01

6.将本地的wordcount.jar文件上传到/wordcount目录下

hadoop fs -put wordcount.jar /wordcount

7.下载words.txt文件到本地

hadoop fs -get /words.txt

8.将/stu/students.txt文件拷贝到本地

hadoop fs -copyToLocal /stu/students.txt

9.将word.txt文件拷贝到/wordcount/input/目录

hadoop fs -copyFromLocal word.txt /wordcount/input

10.将word.txt文件从本地移动到/wordcount/input/目录下

hadoop fs -moveFromLocal word.txt /wordcount/input/

11.将/stu/students.txt拷贝一份为/stu/students.txt.bak

hadoop fs -cp /stu/students.txt /stu/students.txt.bak

12.将/flume/tailout/目录下的子目录或文件都拷贝到/logs目录(如果此目录不存在会创建)下

hadoop fs -cp /flume/tailout/ /logs

13.将/word.txt文件重命名为/words.txt

hadoop fs -mv /word.txt /words.txt

14.将/words.txt文件移动到/wordcount/input/目录下

hadoop fs -mv /words.txt /wordcount/input/

15.将/ws目录以及子目录和文件都删除(谨慎使用)

hadoop fs -rm -r /ws

16.删除以"xbs-"开头的目录及其子目录

hadoop fs -rm -r /xbs-*

17.将/wordcount/output2/目录下的a.txt文件删除

hadoop fs -rm /wordcount/output2/a.txt

18.将/wordcount/input/目录下面的所有文件都删除

hadoop fs -rm /wordcount/input/*

19.查看HDFS集群的磁盘空间使用情况

hadoop fs -df -h

20.查看/word.txt文件的内容

hadoop fs -cat /word.txt

21.将name.txt文件中的内容添加到/wordcount/input/words.txt文件中

hadoop fs -appendToFile name.txt /wordcount/input/words.txt

22.动态查看/wordcount/input/words.txt文件的内容

hadoop fs -tail -f /wordcount/input/words.txt

23.统计/flume目录总大小

hadoop fs -du -s -h /flume

24.分别统计/flume目录下各个子目录(或文件)大小

hadoop fs -du -s -h /flume/*

25.运行jar包中的程序

//hadoop jar + 要执行的jar包 + 要运行的类 + 输入目录 + 输出目录
hadoop jar wordcount.jar com.xuebusi.hadoop.mr.WordCountDriver /wordcount/input /wordcount/out

26.查看hdfs集群状态

hdfs dfsadmin -report
[root@hadoop03 apps]# hdfs dfsadmin -report
Configured Capacity: 55737004032 (51.91 GB)
Present Capacity: 15066578944 (14.03 GB)
DFS Remaining: 14682021888 (13.67 GB)
DFS Used: 384557056 (366.74 MB)
DFS Used%: 2.55%
Under replicated blocks: 7
Blocks with corrupt replicas: 0
Missing blocks: 0 -------------------------------------------------
Live datanodes (3): Name: 192.168.71.11:50010 (hadoop01)
Hostname: hadoop01
Decommission Status : Normal
Configured Capacity: 18579001344 (17.30 GB)
DFS Used: 128180224 (122.24 MB)
Non DFS Used: 16187543552 (15.08 GB)
DFS Remaining: 2263277568 (2.11 GB)
DFS Used%: 0.69%
DFS Remaining%: 12.18%
Configured Cache Capacity: 0 (0 B)
Cache Used: 0 (0 B)
Cache Remaining: 0 (0 B)
Cache Used%: 100.00%
Cache Remaining%: 0.00%
Xceivers: 1
Last contact: Mon Jan 09 11:17:43 PST 2017 Name: 192.168.71.13:50010 (hadoop03)
Hostname: hadoop03
Decommission Status : Normal
Configured Capacity: 18579001344 (17.30 GB)
DFS Used: 128196608 (122.26 MB)
Non DFS Used: 13623074816 (12.69 GB)
DFS Remaining: 4827729920 (4.50 GB)
DFS Used%: 0.69%
DFS Remaining%: 25.98%
Configured Cache Capacity: 0 (0 B)
Cache Used: 0 (0 B)
Cache Remaining: 0 (0 B)
Cache Used%: 100.00%
Cache Remaining%: 0.00%
Xceivers: 1
Last contact: Mon Jan 09 11:17:41 PST 2017 Name: 192.168.71.12:50010 (hadoop02)
Hostname: hadoop02
Decommission Status : Normal
Configured Capacity: 18579001344 (17.30 GB)
DFS Used: 128180224 (122.24 MB)
Non DFS Used: 10859806720 (10.11 GB)
DFS Remaining: 7591014400 (7.07 GB)
DFS Used%: 0.69%
DFS Remaining%: 40.86%
Configured Cache Capacity: 0 (0 B)
Cache Used: 0 (0 B)
Cache Remaining: 0 (0 B)
Cache Used%: 100.00%
Cache Remaining%: 0.00%
Xceivers: 1
Last contact: Mon Jan 09 11:17:42 PST 2017

27.查看hadoop fs命令使用帮助

[root@hadoop01 hadoop]# hadoop fs
Usage: hadoop fs [generic options]
[-appendToFile <localsrc> ... <dst>]
[-cat [-ignoreCrc] <src> ...]
[-checksum <src> ...]
[-chgrp [-R] GROUP PATH...]
[-chmod [-R] <MODE[,MODE]... | OCTALMODE> PATH...]
[-chown [-R] [OWNER][:[GROUP]] PATH...]
[-copyFromLocal [-f] [-p] [-l] <localsrc> ... <dst>]
[-copyToLocal [-p] [-ignoreCrc] [-crc] <src> ... <localdst>]
[-count [-q] [-h] <path> ...]
[-cp [-f] [-p | -p[topax]] <src> ... <dst>]
[-createSnapshot <snapshotDir> [<snapshotName>]]
[-deleteSnapshot <snapshotDir> <snapshotName>]
[-df [-h] [<path> ...]]
[-du [-s] [-h] <path> ...]
[-expunge]
[-get [-p] [-ignoreCrc] [-crc] <src> ... <localdst>]
[-getfacl [-R] <path>]
[-getfattr [-R] {-n name | -d} [-e en] <path>]
[-getmerge [-nl] <src> <localdst>]
[-help [cmd ...]]
[-ls [-d] [-h] [-R] [<path> ...]]
[-mkdir [-p] <path> ...]
[-moveFromLocal <localsrc> ... <dst>]
[-moveToLocal <src> <localdst>]
[-mv <src> ... <dst>]
[-put [-f] [-p] [-l] <localsrc> ... <dst>]
[-renameSnapshot <snapshotDir> <oldName> <newName>]
[-rm [-f] [-r|-R] [-skipTrash] <src> ...]
[-rmdir [--ignore-fail-on-non-empty] <dir> ...]
[-setfacl [-R] [{-b|-k} {-m|-x <acl_spec>} <path>]|[--set <acl_spec> <path>]]
[-setfattr {-n name [-v value] | -x name} <path>]
[-setrep [-R] [-w] <rep> <path> ...]
[-stat [format] <path> ...]
[-tail [-f] <file>]
[-test -[defsz] <path>]
[-text [-ignoreCrc] <src> ...]
[-touchz <path> ...]
[-usage [cmd ...]]

Hadoop HDFS操作命令总结的更多相关文章

  1. Hadoop HDFS常用操作命令

    hadoop常用命令:hadoop fs查看Hadoop HDFS支持的所有命令 hadoop fs –ls列出目录及文件信息 hadoop fs –lsr循环列出目录.子目录及文件信息 hadoop ...

  2. (转)hadoop基本操作命令

    http://www.cnblogs.com/gpcuster/archive/2010/06/04/1751538.html 在这篇文章中,我们默认认为Hadoop环境已经由运维人员配置好直接可以使 ...

  3. HADOOP基本操作命令

    在这篇文章中,我们默认认为Hadoop环境已经由运维人员配置好直接可以使用. 假设Hadoop的安装目录HADOOP_HOME为/home/admin/hadoop. 启动与关闭 启动HADOOP 进 ...

  4. Hadoop HDFS 中的一些常用命令

    转载自:hadoop HDFS常用文件操作命令 命令基本格式: hadoop fs -cmd < args > 1.ls hadoop fs -ls / 列出hdfs文件系统根目录下的目录 ...

  5. Hadoop(HDFS,YARN)的HA集群安装

    搭建Hadoop的HDFS HA及YARN HA集群,基于2.7.1版本安装. 安装规划 角色规划 IP/机器名 安装软件 运行进程 namenode1 zdh-240 hadoop NameNode ...

  6. Hadoop HDFS 用户指南

    This document is a starting point for users working with Hadoop Distributed File System (HDFS) eithe ...

  7. Hadoop HDFS负载均衡

    Hadoop HDFS负载均衡 转载请注明出处:http://www.cnblogs.com/BYRans/ Hadoop HDFS Hadoop 分布式文件系统(Hadoop Distributed ...

  8. Hive:org.apache.hadoop.hdfs.protocol.NSQuotaExceededException: The NameSpace quota (directories and files) of directory /mydir is exceeded: quota=100000 file count=100001

    集群中遇到了文件个数超出限制的错误: 0)昨天晚上spark 任务突然抛出了异常:org.apache.hadoop.hdfs.protocol.NSQuotaExceededException: T ...

  9. Hadoop程序运行中的Error(1)-Error: org.apache.hadoop.hdfs.BlockMissingException

    15/03/18 09:59:21 INFO mapreduce.Job: Task Id : attempt_1426641074924_0002_m_000000_2, Status : FAIL ...

随机推荐

  1. 世界围棋人机大战、顶峰对决第一盘:围棋世界冠军Lee Sedol(李世石,围棋职业九段)对战Google DeepMind AlphaGo围棋程序

    Match 1 - Google DeepMind Challenge Match: Lee Sedol vs AlphaGo 很多网站对世界围棋大战进行了现场直播,比如YouTube.新浪.乐视.腾 ...

  2. 使用R语言和XML包抓取网页数据-Scraping data from web pages in R with XML package

    In the last years a lot of data has been released publicly in different formats, but sometimes the d ...

  3. Delphi DBGrid图显用法

    procedure TForm10.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;DataCol: Integer; Column: ...

  4. Webview 支持文件上传

    默认情况下情况下,在一个带有input tpye=file标签的Html页面,使用Android的WebView是不能够支持上传文件的(在iOS和微信上完全正常工作).而这个,也是在我们的前端工程师告 ...

  5. 使用SQL查询连续号码段

    原文http://www.cnblogs.com/tc310/archive/2010/09/17/1829276.html CREATE TABLE #test(fphm INT ,kshm CHA ...

  6. Tapable 0.2.8 入门

    [原文:Tapable 0.2.8 入门] tapable是webpack的核心框架(4.0以上版本的API已经发生了变化),是一个基于事件流的框架,或者叫做发布订阅模式,或观察者模式,webpack ...

  7. 美团的android多渠道包的3种方法

    转: http://tech.meituan.com/mt-apk-packaging.html 美团Android自动化之旅—生成渠道包 zhihu2014-06-13 10:06 概述 每当发新版 ...

  8. 用sc命令查询系统状态

    用sc命令查询系统状态 sc query 语法 sc query                - Enumerates status for active services & driver ...

  9. STL - 判断式(Predicate) - 单参判断式(Unary Predicate)

    Predicate是一种特殊的辅助函数,它会返回Boolean,常常被用来作为排序或者查找准则. Predicate会有1个或者2个操作数. Unary Predicate(单参判断式) 例子: 我们 ...

  10. http协议中content-length 以及chunked编码分析

    转载请注明出处 http://blog.csdn.net/yankai0219/article/details/8269922 0.序 1.http/1.1协议中与chunked编码的相关字段 1)E ...