解决Hadoop启动后一直处于安全模式的问题

本文详细介绍了Hadoop启动后处于安全模式的原因,分析了由于缺少blocks导致的安全模式。通过查看namenode和datanode的日志,发现是因为部分blocks副本不足。通过`hdfs fsck /`命令确认了数据丢失的情况。解决方案包括调整安全模式阀值,手动脱离安全模式,以及使用`hdfs debug recoverLease`命令尝试恢复丢失的blocks。
摘要由CSDN通过智能技术生成

Hadoop退出安全模式

  1. 在HDFS配置文件中修改安全模式阀值

在hdfs-site.xml中设置安全阀值属性,属性值默认为0.999f,如果设为1则不进行安全检查

<property>
  <name>dfs.safemode.threshold.pct</name>
  <value>0.999f</value>
  <description>
Specifies the percentage of blocks that should satisfy
the minimal replication requirement defined by dfs.replication.min.
Values less than or equal to 0 mean not to wait for any particular
percentage of blocks before exiting safemode.
Values greater than 1 will make safe mode permanent.
  </description>
</property>

因为是在配置文件中进行硬修改,不利于管理员操作和修改,因此不推荐此方式

  1. 直接在bash输入指令脱离安全模式(推荐)

在安全模式下输入指令:

hadoop dfsadmin -safemode leave

即可退出安全模式。

hadoop dfsadmin -safemode enter

即可进入安全模式.

问题:HDFS启动后一直处于安全状态

解决过程:
1.查看hadoop namenode的启动日志

STARTUP_MSG: Starting NameNode
STARTUP_MSG: host = hadoop001/192.168.137.141
STARTUP_MSG: args = []
STARTUP_MSG: version = 2.6.0-cdh5.7.0
STARTUP_MSG: classpath = …
The number of live datanodes 1 has reached the minimum number 0. Safe mode will be turned off automatically once the thresholds have been reached.
2019-01-16 21:23:02,807 INFO org.apache.hadoop.hdfs.server.blockmanagement.CacheReplicationMonitor: Rescanning after 30001 milliseconds
2019-01-16 21:23:02,807 INFO org.apache.hadoop.hdfs.server.blockmanagement.CacheReplicationMonitor: Scanned 0 directive(s) and 0 block(s) in 0 millisecond(s).
2019-01-16 21:23:32,808 INFO org.apache.hadoop.hdfs.server.blockmanagement.CacheReplicationMonitor: Rescanning after 30001 milliseconds
2019-01-16 21:23:32,808 INFO org.apache.hadoop.hdfs.server.blockmanagement.CacheReplicationMonitor: Scanned 0 directive(s) and 0 block(s) in 0 millisecond(s).
2019-01-16 21:23:48,686 WARN org.apache.hadoop.security.UserGroupInformation: PriviledgedActionException as:hadoop (auth:SIMPLE) cause:org.apache.hadoop.hdfs.server.name
node.SafeModeException: Log not rolled. Name node is in safe mode.
The reported blocks 549 needs additional 4 blocks to reach the threshold 0.9990 of total blocks 553.
The number of live datanodes 1 has reached the minimum number 0. Safe mode will be turned off automatically once the thresholds have been reached.
2019-01-16 21:23:48,687 INFO org.apache.hadoop.ipc.Server: IPC Server handler 4 on 9000, call org.apache.hadoop.hdfs.server.protocol.NamenodeProtocol.rollEditLog from 19
2.168.137.141:53271 Call#84 Retry#0: org.apache.hadoop.hdfs.server.namenode.SafeModeException: Log not rolled. Name node is in safe mode.
The reported blocks 549 needs additional 4 blocks to reach the threshold 0.9990 of total blocks 553.
The number of live datanodes 1 has reached the minimum number 0. Safe mode will be turned off automatically once the thresholds have been reached.
2019-01-16 21:23:51,355 WARN org.apache.hadoop.security.UserGroupInformation: PriviledgedActionException as:hadoop (auth:SIMPLE) cause:org.apache.hadoop.hdfs.server.name
node.SafeModeException: Cannot create directory /tmp/hive/hadoop/b8d6b3ec-3b4b-4e3c-8b9e-6d8d328203aa. Name node is in safe mode.
The reported blocks 549 needs additional 4 blocks to reach the threshold 0.9990 of total blocks 553.
The number of live datanodes 1 has reached the minimum number 0. Safe mode will be turned off automatically once the thresholds have been reached.
2019-01-16 21:23:51,355 INFO org.apache.hadoop.ipc.Server: IPC Server handler 9 on 9000, call org.apache.hadoop.hdfs.protocol.ClientProtocol.mkdirs from 192.168.137.141:
53272 Call#4 Retry#0: org.apache.hadoop.hdfs.server.namenode.SafeModeException: Cannot create directory /tmp/hive/hadoop/b8d6b3ec-3b4b-4e3c-8b9e-6d8d328203aa. Name node
is in safe mode.
The reported blocks 549 needs additional 4 blocks to reach the threshold 0.9990 of total blocks 553.
The number of live datanodes 1 has reached the minimum number 0. Safe mode will be turned off automatically once the thresholds have been reached.
2019-01-16 21:24:02,809 INFO org.apache.hadoop.hdfs.server.blockmanagement.CacheReplicationMonitor: Rescanning after 30001 milliseconds
2019-01-16 21:24:02,811 INFO org.apache.hadoop.hdfs.server.blockmanagement.CacheReplicationMonitor: Scanned 0 directive(s) and 0 block(s) in 2 millisecond(s).
2019-01-16 21:24:30,425 INFO org.apache.hadoop.hdfs.server.namenode.FSNamesystem: initializing replication queues

发现是因为缺少blocks,block数量没有达到所有块的0.9990的阈值(needs additional 4 blocks to reach the threshold 0.9990 of total blocks 553)
为什么会丢块呢?

2.查看hadoop namenode的启动日志

/************************************************************
STARTUP_MSG: Starting DataNode
STARTUP_MSG: host = hadoop001/192.168.137.141
STARTUP_MSG: args = []
STARTUP_MSG: version = 2.6.0-cdh5.7.0
STARTUP_MSG: classpath = …
2019-01-16 20:14:33,776 INFO org.apache.hadoop.hdfs.server.common.Storage: Locking is disabled for /home/hadoop/app/tmp/dfs/data/current/BP-848574762-192.168.137.141-152
8737264517
2019-01-16 20:14:33,780 INFO org.apache.hadoop.hdfs.server.datanode.DataNode: Setting up storage: nsid=1759064178;bpid=BP-848574762-192.168.137.141-1528737264517;lv=-56;
nsInfo=lv=-60;cid=CID-2ccbdca6-0244-4b19-8107-f20a1a74cfe0;nsid=1759064178;c=0;bpid=BP-848574762-192.168.137.141-1528737264517;dnuuid=3d4c88f5-6ffd-4b12-a90f-bba9b8e65b7
4
2019-01-16 20:14:34,167 INFO org.apache.hadoop.hdfs.server.datanode.fsdataset.impl.FsDatasetImpl: Added new volum

  • 2
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值