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的极大 ...
随机推荐
- [ZJOI2012]灾难
嘟嘟嘟 偶尔翻到的一道题. 50分暴力很好想,对于每一个点进行一次拓扑排序,然后每一次别memset,只清空走过的点,能拿到70分. 正解好像也挺好想,是一个叫"灭绝树"的东西. ...
- ORACLE直方图(10g)
为什么需要直方图 ?当表中一列数据比较的值分布比较均匀时,optimzer可以很好的通过最大值,最小值和NDV(唯一值的个数),就可以判断出cardinality.对于cardinality越精确,o ...
- 【转】Chrome 控制台新玩法-console显示图片以及为文字加样式
在正常模式下,一般只能向console 控制台输出简单的文字信息.但为了把信息输出得更优雅更便于阅读,除了cosole.log()方法外还可以调用 cosole.warn() 来输出警告信息,在控制台 ...
- 【css】max-height,min-height,height一起使用时,优先级问题
MDN说法: max-height 这个属性会阻止 height 属性的设置值变得比 max-height 更大. max-height 属性用来设置给定元素的最大高度. 如果height 属性设置的 ...
- ASP.Net:Javascript 通过PageMethods 调用后端WebMethod方法 + 多线程数据处理 示例
ASP.Net:Javascript 通过PageMethods 调用后端WebMethod方法 + 多线程数据处理 示例 2012年04月27日 16:59:16 奋斗的小壁虎 阅读数:4500 ...
- hyperledge工具-cryptogen
参考:http://baijiahao.baidu.com/s?id=1596614770784685300&wfr=spider&for=pc cryptogen是Hyperledg ...
- 解决Nginx+Tomcat下客户端https请求跳转成http的问题
Nginx上开启https, 后端使用Tomcat, 两者间走http协议, 但发现如果tomcat应用存在跳转时, 则客户端浏览器会出现400 Bad Request的错误, 通过抓包发现原因是 ...
- jenkins忘记管理员密码之解决方案
jenkins忘记管理员密码怎么办? 通常有这么几种解决方案,如下所示: (1)进入对应的用户目录文件夹,以ubuntu16.04为例,jenkins安装目录为/var/lib/jenkins进入到该 ...
- switch and checkbox
import 'package:flutter/material.dart'; void main()=>runApp(MyApp()); class MyApp extends Statele ...
- C# — Socket通信实现
昨天晚上在网上查找资料,简单实现了C#开发的Socket通信,以下是具体的开发流程,我使用的是VS2017进行开发的: 一.服务器端: 1.新建一个项目,Windows控制台程序 2.重命名cs文件 ...