Hadoop 常用命令

来源:互联网 发布:儿童服装淘宝网 编辑:程序博客网 时间:2024/06/14 02:04
概述

 

所有的hadoop命令 由bin / hadoop脚本调用。不带任何参数运行 hadoop脚本会打印所有命令的描述。

用法: hadoop [--config confdir] [COMMAND] [GENERIC_OPTIONS] [COMMAND_OPTIONS]

Hadoop有一个选项解析框架用于解析一般的选项和运行类。

COMMAND_OPTIONDescription--config confdir覆盖缺省配置目录。默认值是$ {HADOOP_HOME} / conf目录。GENERIC_OPTIONS多个命令都支持的通用选项
COMMAND 
COMMAND_OPTIONS在下面的章节描述他们的各种各样的命令和选项。这些命令被分为用户命令 和管理命令
常规选项:
下面的选项被 dfsadminfsfsck和 job支持。 应用程序要实现 工具支持 常规选项
GENERIC_OPTIONDescription-conf <configuration file>指定应用程序的配置文件。-D <property=value>使用给定的属性值。-fs <local|namenode:port>指定名称节点。-jt <local|jobtracker:port>指定一个jobtracker。仅适用于JOB-files <comma separated list of files>指定要复制到map reduce集群的文件,用逗号分割。仅适用于JOB。 -libjars <comma seperated list of jars>指定 包含到classpath中中的jar文件,用逗号分割仅适用于JOB。 -archives <comma separated list of archives>指定归档的文件,用逗号分割适用于JOB

用户命令:
hadoop集群用户常用命令

archive

创建Hadoop的档案。更多的信息可以被发现在参考 Hadoop Archives

 

用法: hadoop archive -archiveName NAME <src>* <dest>

COMMAND_OPTIONDescription-archiveName NAME创建的归档文件名字src使用正则表达式的文件系统的路径名。dest将包含压缩文件的目标目录。

distcp

递归地拷贝文件或目录。更多的信息可以发现在Hadoop的DistCp指南

用法: hadoop distcp <srcurl> <desturl>

COMMAND_OPTIONDescriptionsrcurl源URLdesturl目的 Url

fs

用法: hadoop fs [GENERIC_OPTIONS] [COMMAND_OPTIONS]

运行一个通用的文件系统的用户客户端。

各种命令,可以查阅文件系统Shell指南

fsck

运行HDFS文件系统检查工具。的详细信息,请参阅fsck的

用法: hadoop fsck [GENERIC_OPTIONS] <path> [-move | -delete | -openforwrite] [-files [-blocks [-locations | -racks]]]

COMMAND_OPTIONDescription<path>检查的起点文件系统路径-move移动损坏的文件到 / lost + found -delete删除损坏文件-openforwrite打印在wirte的文件-files打印检查过的文件-blocks打印block report.-locations打印 每个block的location  -racks打印出的网络拓扑结构的数据节点的位置。
fetchdt
获取NameNode的代表团令牌从。请参阅fetchdt,了解更多信息。

用法: hadoop fetchdt [GENERIC_OPTIONS] [--webservice <namenode_http_addr>] <path>

COMMAND_OPTIONDescription<fileName>File name to store the token into.--webservice <https_address>使用http协议取代rpc 
jar
运行一个jar文件。用户可以在一个jar文件捆绑他们的Map Reduce代码和执行,使用这个命令。

 

用法: hadoop jar <jar> [mainClass] args...

streaming作业是通过这个命令执行。实例可以被称为 流的例子

Word count 统计的例子还使用jar命令来运行。它可以被称为 wordcount的例

job

和Map Reduce作业交互的命令。

用法: hadoop job [GENERIC_OPTIONS] [-submit <job-file>] | [-status <job-id>] | [-counter <job-id> <group-name> <counter-name>] | [-kill <job-id>] | [-events <job-id> <from-event-#> <#-of-events>] | [-history [all] <jobOutputDir>] | [-list [all]] | [-kill-task <task-id>] | [-fail-task <task-id>] | [-set-priority <job-id> <priority>]

COMMAND_OPTIONDescription-submit <job-file>Submits the job.-status <job-id>打印 the map and reduce的完成百分比和 所有计数器。-counter <job-id> <group-name> <counter-name>打印计数器的值。-kill <job-id>杀死任务-events <job-id> <from-event-#> <#-of-events>打印给定范围内jobtracker接收到的事件细节
 -history [all] <jobOutputDir>-history <jobOutputDir> 打印失败,被杀死的详情,更多的关于一个作业的细节比如成功的任务,做过的任务尝试等信息可以通过指定[all]选项查看。-list [all]-list all显示所有工作。 -list  仅显示尚未完成的工作。
  -kill-task <task-id>杀死任务。被杀死的任务不会不利于失败尝试。-fail-task <task-id>使任务失败。被失败的任务会对失败尝试不利。-set-priority <job-id> <priority>改变工作的优先级,允许的值有  VERY_HIGH, HIGH, NORMAL, LOW, VERY_LOW

pipes

运行一个pipes job.

用法: hadoop pipes [-conf <path>] [-jobconf <key=value>, <key=value>, ...] [-input <path>] [-output <path>] [-jar <jar file>] [-inputformat <class>] [-map <class>] [-partitioner <class>] [-reduce <class>] [-writer <class>] [-program <executable>] [-reduces <num>]

COMMAND_OPTIONDescription-conf <path>Configuration for job-jobconf <key=value>, <key=value>, ...增加或者覆盖任务的配置 -input <path>Input 目录-output <path>Output 目录-jar <jar file>Jar 文件名-inputformat <class>InputFormat的类型-map <class>  Map的类型-partitioner <class>  Partitioner的类型-reduce <class>  Reduce 的类型-writer <class> RecordWriter 的类型-program <executable>可执行文件的URI-reduces <num>  reduces的数目
queue

命令交互,并查看作业队列信息

用法: hadoop queue [-list] | [-info <job-queue-name> [-showJobs]] | [-showacls]

COMMAND_OPTIONDescription-list获取系统中配置的作业队列的列表。除了与作业队列调度相关的信息。
 -info <job-queue-name> [-showJobs]显示作业队列中的信息和相关的调度信息,特别是工作队列。如果-showJobs选项是目前的工作提交到特定的工作队列显示的列表。
 -showacls显示队列名称和允许当前用户的操作相关的队列。这个列表只显示用户可以访问的。
  
version

打印版本

用法: hadoop version


CLASSNAME
hadoop脚本可以用来调用任何类。

 

用法: hadoop CLASSNAME

运行名为CLASSNAME的类。

classpath
打印类路径中需要得到Hadoop的jar和所需的库。

 

用法: hadoop classpath



管理命令

hadoop集群管理员常用命令。

balancer
运行集群平衡工具。管理员可以简单的按下Ctrl-C来停止平衡的过程。更多详细信息,请参阅重新平衡

 用法: hadoop balancer [-threshold <threshold>]

COMMAND_OPTIONDescription-threshold <threshold>磁盘容量的百分比。这将覆盖默认的阈值。
daemonlog

获取/设置每个守护进程的日志级别。

用法: hadoop daemonlog -getlevel <host:port> <name> 
用法: hadoop daemonlog -setlevel <host:port> <name> <level>

COMMAND_OPTIONDescription-getlevel <host:port> <name>打印在<host:port>的守护进程运行的日志记录级别。此命http://<host:port>/logLevel?log=<name>
Prints the log level of the daemon running at <host:port>. This command internally connects to http://<host:port>/logLevel?log=<name>-setlevel <host:port> <name> <level>Sets the log level of the daemon running at <host:port>. This command internally connects to http://<host:port>/logLevel?log=<name>

datanode

运行一个 HDFS datanode.

用法: hadoop datanode [-rollback]

COMMAND_OPTIONDescription-rollback回滚数据节点到前一个版本,这个命令在停止数据节点和回复旧版本的时候使用 

dfsadmin

运行HDFS dfsadmin客户端。

Usage: hadoop dfsadmin [GENERIC_OPTIONS] [-report] [-safemode enter | leave | get | wait] [-refreshNodes] [-finalizeUpgrade] [-upgradeProgress status | details | force] [-metasave filename] [-setQuota <quota> <dirname>...<dirname>] [-clrQuota <dirname>...<dirname>] [-help [cmd]]

COMMAND_OPTIONDescription-report报告基本的文件系统信息和统计信息-safemode enter | leave | get | wait安全模式的维护命令。安全模式是namenode的一种状态:
1 只读的命名空间
2 不能复制和删除快
 namenode会在启动以后自动进入安全模式,最小复本条件满足配置的快的最小百分比时,自动离开安全模式。安全模式可以通过手工的方式进入,但是手工进入的话,必要要人工才能退出。
 -refreshNodes


重新复读 hosts和 exclude 文件,去更新能连接到namenode的数据节点,包括现役和退役的节点-finalizeUpgrade完成hdfs的升级。继namenode之后,数据节点也会删除他们的上个版本留下的目录。这些完成一个升级过程。
 -upgradeProgress status | details | force查询当前系统的升级状态,状态的细节,或进行强制升级。
 -metasave filename 保存 Namenode的主要数据结构保存到<filename>在由hadoop.log.dir 属性指定的目录中。 <filename>将包含下面每一行
1。Datanodes  发送到 Namenode的心跳
2。等待被复制的块
3。正在被复制的块
4。等待被删除的块
 -setQuota <quota> <dirname>...<dirname>Set the quota <quota> for each directory <dirname>. The directory quota is a long integer that puts a hard limit on the number of names in the directory tree.
Best effort for the directory, with faults reported if
1. N is not a positive integer, or
2. user is not an administrator, or
3. the directory does not exist or is a file, or
4. the directory would immediately exceed the new quota.-clrQuota <dirname>...<dirname>Clear the quota for each directory <dirname>.
Best effort for the directory. with fault reported if
1. the directory does not exist or is a file, or
2. user is not an administrator.
It does not fault if the directory has no quota.-help [cmd]Displays help for the given command or all commands if none is specified.
mradmin
运行MR admin 客户端。

用法: hadoop mradmin [ GENERIC_OPTIONS ] [-refreshQueueAcls]

COMMAND_OPTIONDescription-refreshQueueAclsRefresh the queue acls used by hadoop, to check access during submissions and administration of the job by the user. The properties present inmapred-queue-acls.xml is reloaded by the queue manager.

jobtracker
运行MapReduce  job Tracker  

用法: hadoop jobtracker [-dumpConfiguration]

COMMAND_OPTIONDescription-dumpConfigurationDumps the configuration used by the JobTracker alongwith queue configuration in JSON format into Standard output used by the jobtracker and exits.

namenode
运行namenode ,更多的信息 关于升级,回归和初始化的在 升级回滚

用法: hadoop namenode [-format] | [-upgrade] | [-rollback] | [-finalize] | [-importCheckpoint]

COMMAND_OPTIONDescription-formatFormats the namenode. It starts the namenode, formats it and then shut it down.-upgradeNamenode should be started with upgrade option after the distribution of new hadoop version.-rollbackRollsback the namenode to the previous version. This should be used after stopping the cluster and distributing the old hadoop version.-finalizeFinalize will remove the previous state of the files system. Recent upgrade will become permanent. Rollback option will not be available anymore. After finalization it shuts the namenode down.-importCheckpointLoads image from a checkpoint directory and save it into the current one. Checkpoint dir is read from property fs.checkpoint.dir

secondarynamenode

运行HDFS二次NameNode的。看

secondary


Namenode会 获得更多信息。

用法: hadoop secondarynamenode [-checkpoint [force]] | [-geteditsize]

COMMAND_OPTIONDescription-checkpoint [force]Checkpoints the Secondary namenode if EditLog size >= fs.checkpoint.size. If -force is used, checkpoint irrespective of EditLog size.-geteditsizePrints the EditLog size.

tasktracker

运行一个MapReduce任务跟踪节点。

用法: hadoop tasktracker

0 0
原创粉丝点击