본문 바로가기

카테고리 없음

Hadoop CDH5 HDFS_UNDER_REPLICATED_BLOCKS

CDH로 hadoop cluster 구성 후 HDFS_UNDER_REPLICATED_BLOCKS라는 메시지가 hdfs cluster에 떠있어서 확인해보니, 

기본적으로 dfs.replication이 3인데 장비 2대에 깔았으므로 복제가 2개만 존재하는 파일들이 존재했다. 


확인 

$ hdfs fsck 

결과 

/user/hadoop/data/1987.csv: Under replicated blk_4089892973365100866_1613. Target Replicas is 3 but found 2 replica(s). 

/user/hadoop/data/1987.csv: Under replicated blk_-8012340995855654662_1613. Target Replicas is 3 but found 2 replica(s).


해결 방법은 아래 링크를 참고 했다. 

현재는 test용도로 replication이 2개면 충분하니까 해당 파일들의 replication factor를 2로 바꿔줘버리면 에러가 사라진다. 


https://community.hortonworks.com/articles/4427/fix-under-replicated-blocks-in-hdfs-manually.html

  1. su - <$hdfs_user>
  2.  
  3. bash-4.1$ hdfs fsck / | grep 'Under replicated' | awk -F':' '{print $1}' >> /tmp/under_replicated_files
  4.  
  5. -bash-4.1$ for hdfsfile in `cat /tmp/under_replicated_files`; do echo "Fixing $hdfsfile :" ; hadoop fs -setrep 2 $hdfsfile; done