Skip to content

Instantly share code, notes, and snippets.

@xman1980
Created July 1, 2015 01:36
Show Gist options
  • Save xman1980/cf8f2d88d2185176d81d to your computer and use it in GitHub Desktop.
Save xman1980/cf8f2d88d2185176d81d to your computer and use it in GitHub Desktop.
Fix the under replicated blocks
#!/bin/bash
#
# $Author:$
# $Id:$
#
# Fix the under replicated blocks by setting the replication factor for all of the
# under replicated blocks
#
# Nikhil Mulley
#
HADOOP_CMD="/usr/bin/hadoop"
HADOOP_REP_FACTOR=3
for hdfsfile in $($HADOOP_CMD fsck / | grep 'Under replicated' | awk -F':' '{print $1}')
do
echo "Fixing $hdfsfile :" ;
${HADOOP_CMD} fs -setrep ${HADOOP_REP_FACTOR} $hdfsfile;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment