Hadoop Safe Mode Illustrated

本文详细介绍了Hadoop中NameNode启动时进入安全模式的原因及其工作原理。安全模式下,NameNode只提供文件系统的只读视图,不允许进行文件修改操作。此外,还解释了退出安全模式的条件及配置参数。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

When NameNode is started (not the first time start after formatting), it's running in safe mode, which means that it offers only a read-only view of the filesystem to clients. Strictly speaking, in safe mode, only filesystem operations that access the filesystem metadata are guaranteed to work. Reading a file will work only when the blocks are available on the current set of DataNodes in the cluster, and file modifications will always fail.

 

The locations of blocks are not persisted by the NameNode; this information resides with the DataNodes, in the form of a list of blocks it's storing. During normal operation of the system, the NameNode has a map of block locations stored in memory. Safe mode is needed to give the DataNodes time to check in to the NameNode with their block lists, so the NameNode can be informed of enough block locations to run effectively. If the NameNode didn't wait for enough DataNode's to check in, then it would start the process of replicating blocks to new DataNodes, which would be unnecessary in most cases (because it only needed to wait for the extra DataNodes to check in) and will put a great strain on the cluster's resources. Indeed, while in safe mode, the NameNode does not issue any block-replication or deletion instructions to DataNodes.

 

Safe mode is exited when the minimal replication condition is reached, plus an extension time of 30 seconds. The minimal replication condition is when 99.9% of the blocks in the whole filesystem meet their minimum replication level(set by dfs.replication.min, defaults to 1).

Property nameTypeDefault valueDescription
dfs.replication.minint1The min num of replicas that have to be written for a write to be successful.
dfs.safemode.threshold.pctfloat0.999The proportion of blocks in the system that must meet the min replication level defined by dfs.replication.min before the NameNode will leave safe mode. Setting this value to 0 or less forces the NameNode not to start in safe mode. Setting this value to 1 means the NameNode will never leave safe mode.
dfs.safemode.extensionint30000 (milliseconds)The time to extend safe mode after the min replication condition defined by dfs.safemode.threshold.pct has been satisfied. For small clusters, it can be set to 0.

 

Force Hadoop to leave safe mode, use

$hadoop dfsadmin -safemode leave
Safe mode is OFF

 Force Hadoop to enter safe mode, use

$hadoop dfsadmin -safemode enter
Safe mode is ON

 To see if the NameNode is in safe mode, use NameNode web UI or use

$hadoop dfsadmin -safemode get
Safe mode is ON

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值