Skip to content

Instantly share code, notes, and snippets.

@carlessanagustin
Last active December 9, 2016 13:32
Show Gist options
  • Save carlessanagustin/c041ee71d8457425a58e738863b97c46 to your computer and use it in GitHub Desktop.
Save carlessanagustin/c041ee71d8457425a58e738863b97c46 to your computer and use it in GitHub Desktop.
HADOOP: Fix HDFS under replicated blocks
#!/usr/bin/bash
HDFSUSER=hdfs
URFILES=/tmp/under_replicated_files
sudo -u $HDFSUSER hdfs fsck / | grep 'Under replicated' | awk -F':' '{print $1}' >> $URFILES
sudo -u $HDFSUSER for hdfsfile in `cat $URFILES`; do echo "Fixing $hdfsfile :" ; hdfs dfs -setrep 3 $hdfsfile; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment