21 Haziran 2014 Cumartesi

Hadoop - Safe Mode

I will explain some details of Hadoop safe mode and related properties/commands.

Hadoop 1.0.3. is used on Ubuntu 12.04

1. Safe Mode

When namenode first starts, it loads its image file into memory. In this state, namenode has metadata of its filesystem. However it does not have the location of blocks. When datanodes begin to check in with the block list they have, namenode builds a map that holds blocks and their locations. Until a certain percentage of block locations are informed, namenode waits for other datanodes to check in.

During this time, namenode stays in safe mode. It does not replicate blocks and does not allow write, deletion and renaming. It gives a read-only view to clients, it gives directory listing and file reads will succeed if blocks are already informed by checked in datanodes. When configured percentage is met, namenode waits for 30 seconds and leaves safe mode.

Safe mode is beneficial. For example, replication is stopped thereby preventing unnecessary replication of a file, when it is just a matter of time for datanodes to check in with that file's block locations.

2. Configuration Parameters

dfs.replication.min 
Default value: 1
Description: The minimum number of replicas that have to be written for a write to be successful.

dfs.safemode.threshold.pct 
Default value: 0.999
Description: The proportion of blocks in the system that must meet the minimum replication level defined by dfs.replication.min before the namenode will exit safe mode. Setting this value to 0 or less forces the namenode not to start in safe mode. Setting this value to more than 1 means the namenode never exits safe mode.

dfs.safemode.extension 
Default value: 30,000
Description: The time, in milliseconds, to extend safe mode by after the minimum replication condition defined by dfs.safemode.threshold.pct has been satisfied. For small clusters (tens of nodes), it can be set to 0.

3. Safe Mode Commands

Get safe mode status
hadoop dfsadmin -safemode get
Safe mode is ON

Namenode web interface also gives information about safe mode status: 

Leave safe mode
hadoop dfsadmin -safemode leave
Safe mode is OFF

Control file system status
hadoop fsck /





Hiç yorum yok:

Yorum Gönder