hadoop 管理命令dfsadmin
hadoop 管理命令dfsadmin
dfsadmin 命令用于管理HDFS集群,这些命令常用于管理员。
1. (Safemode)安全模式
| 动作 | 命令 |
| 把集群切换到安全模式 | bin/hdfs dfsadmin -safemode [enter/get/leave] |
| 数据节点状态列表 | bin/hadoop dfsadmin -report |
| 添加或删除数据节点 | bin/hadoop dfsadmin -refreshNodes |
| 打印网络拓扑 | bin/hadoop dfsadmin -printTopology |
| 官当网站 | http://hadoop.apache.org/docs/r2.8.3/hadoop-project-dist/hadoop-hdfs/HDFSCommands.html#dfsadmin |
- [hadoop@master bin]$ ./hdfs dfsadmin -safemode enter #进入安全模式
- Safe mode is ON
- [hadoop@master bin]$ ./hdfs dfsadmin -safemode get #获取当前状态
- Safe mode is ON
- [hadoop@master bin]$ ./hdfs dfsadmin -safemode leave #离开safemode状态
- Safe mode is OFF
- [hadoop@master bin]$
安全模式:On startup, the NameNode enters a special state called Safemode. Replication of data blocks does not occur when the NameNode is in the Safemode state. The NameNode receives Heartbeat and Blockreport messages from the DataNodes. A Blockreport contains the list of data blocks that a DataNode is hosting. Each block has a specified minimum number of replicas. A block is considered safely replicated when the minimum number of replicas of that data block has checked in with the NameNode. After a configurable percentage of safely replicated data blocks checks in with the NameNode (plus an additional 30 seconds), the NameNode exits the Safemode state. It then determines the list of data blocks (if any) that still have fewer than the specified number of replicas. The NameNode then replicates these blocks to other DataNodes.
hadoop启动时,会处于一种特殊的状态称做安全模式,这种模式下,数据块的复制是不能发生的,主节点会收到各数据节点的心跳(Heartbeat)和块报告(Blockreport)信息。块报告信息包含该数据节点包含的块信息,每一个数据块都有一个最小被副本数,当一个块最小副本数与NN记录的相符合时就被认为是安全的复制,在配置一个安全副本百分数与NN相符后(再加30s)(意思就是副本数*N%后与NN记录的相符就认为是安全,N可配置),NN就退出Safemode状态。之后(safemode 时是不能发生数据复制的)如果列表中仍然有少数的副本数比已备份少,NN将会把这些块复制到其他数据节点。
根据上面说明:
1.Safemode 主要是校验数据节点的块信息。
2.safemode 不能发生块复制(Replication )。
3.hadoop 的维护工作是在模式下进行的。
Safemode状态时创建目录报错:
Cannot create directory /hxw. Name node is in safe mode. It was turned on manually. Use "hdfs dfsadmin -safemode leave" to turn safe mode off.
2.集群信息状态报告
以及集群资源占用情况,以及各数据节点信息。
- [hadoop@master logs]$ hadoop dfsadmin -report
- DEPRECATED: Use of this script to execute hdfs command is deprecated.
- Instead use the hdfs command for it.
- Configured Capacity: 37492883456 (34.92 GB)
- Present Capacity: 22908968960 (21.34 GB)
- DFS Remaining: 21126250496 (19.68 GB)
- DFS Used: 1782718464 (1.66 GB)
- DFS Used%: 7.78%
- Under replicated blocks: 18
- Blocks with corrupt replicas: 0
- Missing blocks: 0
- Missing blocks (with replication factor 1): 0
- Pending deletion blocks: 0
- -------------------------------------------------
- Live datanodes (2):
- Name: 10.0.1.226:50010 (slave-2)
- Hostname: slave-2
- Decommission Status : Normal
- Configured Capacity: 18746441728 (17.46 GB)
- DFS Used: 891359232 (850.07 MB)
- Non DFS Used: 7806763008 (7.27 GB)
- DFS Remaining: 10048319488 (9.36 GB)
- DFS Used%: 4.75%
- DFS Remaining%: 53.60%
- 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: Wed Jan 17 17:09:23 CST 2018
- Name: 10.0.1.227:50010 (slave-1)
- Hostname: slave-1
- Decommission Status : Normal
- Configured Capacity: 18746441728 (17.46 GB)
- DFS Used: 891359232 (850.07 MB)
- Non DFS Used: 6777151488 (6.31 GB)
- DFS Remaining: 11077931008 (10.32 GB)
- DFS Used%: 4.75%
- DFS Remaining%: 59.09%
- 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: Wed Jan 17 17:09:24 CST 2018
3.节点刷新
当集群有新增或删除节点时使用。
- [hadoop@master bin]$ ./hdfs dfsadmin -refreshNodes
- Refresh nodes successful
- [hadoop@slave-1 sbin]$ ./hadoop-daemon.sh stop datanode
- stopping datanode
- [hadoop@master bin]$ hadoop dfsadmin -report
- DEPRECATED: Use of this script to execute hdfs command is deprecated.
- Instead use the hdfs command for it.
- Configured Capacity: 37492883456 (34.92 GB)
- Present Capacity: 22914383872 (21.34 GB)
- DFS Remaining: 21131665408 (19.68 GB)
- DFS Used: 1782718464 (1.66 GB)
- DFS Used%: 7.78%
- Under replicated blocks: 18
- Blocks with corrupt replicas: 0
- Missing blocks: 0
- Missing blocks (with replication factor 1): 0
- Pending deletion blocks: 0
- -------------------------------------------------
- Live datanodes (2):
- Name: 10.0.1.226:50010 (slave-2)
- Hostname: slave-2
- Decommission Status : Normal
- Configured Capacity: 18746441728 (17.46 GB)
- DFS Used: 891359232 (850.07 MB)
- Non DFS Used: 7801290752 (7.27 GB)
- DFS Remaining: 10053791744 (9.36 GB)
- DFS Used%: 4.75%
- DFS Remaining%: 53.63%
- 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: Wed Jan 17 18:16:06 CST 2018
- Name: 10.0.1.227:50010 (slave-1)
- Hostname: slave-1
- Decommission Status : Normal
- Configured Capacity: 18746441728 (17.46 GB)
- DFS Used: 891359232 (850.07 MB)
- Non DFS Used: 6777208832 (6.31 GB)
- DFS Remaining: 11077873664 (10.32 GB)
- DFS Used%: 4.75%
- DFS Remaining%: 59.09%
- 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: Wed Jan 17 18:13:43 CST 2018
- [hadoop@master bin]$ ./hdfs dfsadmin -refreshNodes
- Refresh nodes successful
- [hadoop@master bin]$ ./hdfs dfsadmin -refreshNodes
- Refresh nodes successful
- [hadoop@master bin]$ hadoop dfsadmin -report
- DEPRECATED: Use of this script to execute hdfs command is deprecated.
- Instead use the hdfs command for it.
- Configured Capacity: 37492883456 (34.92 GB)
- Present Capacity: 22914379776 (21.34 GB)
- DFS Remaining: 21131661312 (19.68 GB)
- DFS Used: 1782718464 (1.66 GB)
- DFS Used%: 7.78%
- Under replicated blocks: 18
- Blocks with corrupt replicas: 0
- Missing blocks: 0
- Missing blocks (with replication factor 1): 0
- Pending deletion blocks: 0
- -------------------------------------------------
- Live datanodes (2):
- Name: 10.0.1.226:50010 (slave-2)
- Hostname: slave-2
- Decommission Status : Normal
- Configured Capacity: 18746441728 (17.46 GB)
- DFS Used: 891359232 (850.07 MB)
- Non DFS Used: 7801294848 (7.27 GB)
- DFS Remaining: 10053787648 (9.36 GB)
- DFS Used%: 4.75%
- DFS Remaining%: 53.63%
- 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: Wed Jan 17 18:18:54 CST 2018
- Name: 10.0.1.227:50010 (slave-1)
- Hostname: slave-1
- Decommission Status : Normal
- Configured Capacity: 18746441728 (17.46 GB)
- DFS Used: 891359232 (850.07 MB)
- Non DFS Used: 6777208832 (6.31 GB)
- DFS Remaining: 11077873664 (10.32 GB)
- DFS Used%: 4.75%
- DFS Remaining%: 59.09%
- 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: Wed Jan 17 18:13:43 CST 2018
说明:在停止某个数据节点后,刷新节点信息仍然能看到该节点信息,状态noraml 状态,界面上看到last contact 时间是560+s。
在Namenode 的配置文件slaves 中删除该节点,然后重新刷新节点信息,则后台显示:
- [hadoop@master bin]$ ./hdfs dfsadmin -refreshNodes
- Refresh nodes successful
- [hadoop@master bin]$ hadoop dfsadmin -report
- DEPRECATED: Use of this script to execute hdfs command is deprecated.
- Instead use the hdfs command for it.
- Configured Capacity: 18746441728 (17.46 GB)
- Present Capacity: 10945093632 (10.19 GB)
- DFS Remaining: 10053734400 (9.36 GB)
- DFS Used: 891359232 (850.07 MB)
- DFS Used%: 8.14%
- Under replicated blocks: 161
- Blocks with corrupt replicas: 0
- Missing blocks: 0
- Missing blocks (with replication factor 1): 0
- Pending deletion blocks: 0
- -------------------------------------------------
- Live datanodes (1):
- Name: 10.0.1.226:50010 (slave-2)
- Hostname: slave-2
- Decommission Status : Normal
- Configured Capacity: 18746441728 (17.46 GB)
- DFS Used: 891359232 (850.07 MB)
- Non DFS Used: 7801348096 (7.27 GB)
- DFS Remaining: 10053734400 (9.36 GB)
- DFS Used%: 4.75%
- DFS Remaining%: 53.63%
- 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: Wed Jan 17 18:26:36 CST 2018
- Dead datanodes (1):
- Name: 10.0.1.227:50010 (slave-1)
- Hostname: slave-1
- Decommission Status : Normal
- Configured Capacity: 0 (0 B)
- DFS Used: 0 (0 B)
- Non DFS Used: 6777208832 (6.31 GB)
- DFS Remaining: 0 (0 B)
- DFS Used%: 100.00%
- DFS Remaining%: 0.00%
- 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: 0
- Last contact: Wed Jan 17 18:13:43 CST 2018
4.网络拓扑
- [hadoop@master ~]$ hadoop dfsadmin -printTopology
- DEPRECATED: Use of this script to execute hdfs command is deprecated.
- Instead use the hdfs command for it.
- Rack: /default-rack
- 10.0.1.226:50010 (slave-2)
- 10.0.1.227:50010 (slave-1)
总结:
- [hadoop@master bin]$ ./hdfs dfsadmin -safemode enter #进入Safemode模式
- [hadoop@master bin]$ ./hdfs dfsadmin -safemode get #获取当前运行模式
- [hadoop@master bin]$ ./hdfs dfsadmin -safemode leave #退出Safemode模式
- [hadoop@master bin]$ hadoop dfsadmin -report #当前hadoop集群状态信息
- [hadoop@master bin]$ ./hdfs dfsadmin -refreshNodes #新增删除节点更新集群信息
- [hadoop@master sbin]$ ./hadoop-daemon.sh stop datanode #停止单个数据节点
- [hadoop@master ~]$ hadoop dfsadmin -printTopology #打印集群网络拓扑
hadoop 管理命令dfsadmin的更多相关文章
- hadoop管理命令
-help 功能:输出这个命令参数手册 -ls 功能:显示目录信息 示例: hadoop fs -ls hdfs://hadoop-server01:9000/ 备注:这些参数中,所有的hdfs ...
- hadoop管理
hadoop管理工具: 一,dfsadmin工具 dfsadmin 工具用途比较广,既可以查找HDFS状态信息,又可以在HDFS上执行管理操作,以hdfs dfsadmin形式调用,且需要超级用户权限 ...
- Hadoop进阶命令使用介绍
hadoop生产环境的使用是很复杂的,有些公司是CDH或者Ambari等管理工具运维的,有些是原生的集群俗称裸奔,前者优缺点是运维,查看监控等容易,对于底层理解不友好:裸奔集群反之,裸奔集群的很多东西 ...
- 【Hadoop篇】--Hadoop常用命令总结
一.前述 分享一篇hadoop的常用命令的总结,将常用的Hadoop命令总结如下. 二.具体 1.启动hadoop所有进程start-all.sh等价于start-dfs.sh + start-yar ...
- Hadoop常用命令总结
一.前述 分享一篇hadoop的常用命令的总结,将常用的Hadoop命令总结如下. 二.具体 1.启动hadoop所有进程start-all.sh等价于start-dfs.sh + start-yar ...
- 17 RAID与mdadm管理命令
在"14 磁盘及文件系统管理详解"中,我们详细介绍了磁盘的工作原理,但是,有一点我们一定要明白,作为现在存储数据的主要设备,机械磁盘早就是上个世纪的产品,而它的读写速度与内存.CP ...
- hadoop基础----hadoop实战(七)-----hadoop管理工具---使用Cloudera Manager安装Hadoop---Cloudera Manager和CDH5.8离线安装
hadoop基础----hadoop实战(六)-----hadoop管理工具---Cloudera Manager---CDH介绍 简介 我们在上篇文章中已经了解了CDH,为了后续的学习,我们本章就来 ...
- 大数据之路week06--day07(Hadoop常用命令)
一.前述 分享一篇hadoop的常用命令的总结,将常用的Hadoop命令总结如下. 二.具体 1.启动hadoop所有进程start-all.sh等价于start-dfs.sh + start-yar ...
- Hadoop Shell命令大全
hadoop支持命令行操作HDFS文件系统,并且支持shell-like命令与HDFS文件系统交互,对于大多数程序猿/媛来说,shell-like命令行操作都是比较熟悉的,其实这也是Hadoop的极大 ...
随机推荐
- centos7下如何隐藏nginx的版本号
我们在访问nginx的时候会暴露nginx的版本号,如何将这些版本号隐藏呢? 其实隐藏版本号非常简单 在nginx的配置文件中添加一个server——tokens off:参数就可以了,下面进行操作 ...
- UVA11400-Lighting System Design(动态规划基础)
Problem UVA11400-Lighting System Design Accept: 654 Submit: 4654Time Limit: 3000 mSec Problem Descr ...
- 转://Oracle 复合压缩索引场景及性能对比
摘要:今天为什么提到这个话题,出于一个偶然,一个同事在优化新开发的系统时向我请教如何添加复合压缩索引的问题.我总结了一下,问题有三. 第一:需不需要压缩 第二:对第几列压缩 第三:性能对比,选出最优 ...
- P2089 烤鸡(搜索简单题)
题意:就是x分别是1到3的未知数,求x1+x2+x3.....+x10=n的方案数和输出每种方案.每种方案还必须按字典序输出 思路:就是简单的构建搜索树+约束条件啊,其实数据范围一点都不大,所以,我第 ...
- leetcode 74. Search a 2D Matrix 、240. Search a 2D Matrix II
74. Search a 2D Matrix 整个二维数组是有序排列的,可以把这个想象成一个有序的一维数组,然后用二分找中间值就好了. 这个时候需要将全部的长度转换为相应的坐标,/col获得x坐标,% ...
- C学习笔记-一些知识
memset可以方便的清空一个结构类型的变量或数组. 如: struct sample_struct { ]; int iSeq; int iType; }; 对于变量 struct sample_s ...
- 【原创】分布式之redis的三大衍生数据结构
引言 说起redis的数据结构,大家可能对五大基础数据类型比较熟悉:String,Hash,List,Set,Sorted Set.那么除此之外,还有三大衍生数据结构,大家平时是很少接触的,即:bit ...
- 从统计局采集最新的省市区镇数据,用js在浏览器中运行 V2
本文描述的是对国家统计局于2019-01-31发布的<2018年统计用区划代码和城乡划分代码(截止2018年10月31日)>的采集. 相对于用于和采集2016版.2017版的js代码做了比 ...
- RabbitMQ 高可用之镜像队列
如果RabbitMQ集群只有一个broker节点,那么该节点的失效将导致整个服务临时性的不可用,并且可能会导致message的丢失(尤其是在非持久化message存储于非持久化queue中的时候).可 ...
- Jmeter(三十六)_运行过程中改变负载
顾名思义,jmeter在做性能测试时,可以在不停止脚本的情况下修改负载压力,达到期望的测试效果.我们将通过Constant Throughput Timer(吞吐量计时器)和Beanshell服务器来 ...