Last active
January 4, 2016 20:29
-
-
Save SteveCooling/8674729 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # | |
| # Quick and dirty script for resolving split-brained files on GlusterFS bricks. | |
| # Use only at your own risk! | |
| # | |
| HOST=$1 | |
| BRICK=$2 | |
| MOUNT=$3 | |
| VOLUME=$4 | |
| FORCE=$5 | |
| REGEXP=`echo $HOST:$BRICK | perl -pe 's/([\.\/])/\\\\\1/g'` | |
| #echo $REGEXP | |
| echo -n "getting GlusterFS heal-info..." | |
| GFIDS=`gluster volume heal $VOLUME info | awk "/$REGEXP/,/^$/" | grep -v '^Brick\|^Number of' | sed 's/[<>]//g' | cut -d':' -f2` | |
| echo "done." | |
| for gfid in $GFIDS | |
| do | |
| if | |
| echo "$gfid" |grep '^\/' | |
| then | |
| file=$BRICK$gfid | |
| echo $file | |
| # MUST LOOKUP GFID | |
| GFID=$(getfattr -n trusted.gfid --absolute-names -e hex "$file" | grep 0x | cut -d'x' -f2) | |
| gfid=${GFID:0:8}-${GFID:8:4}-${GFID:12:4}-${GFID:16:4}-${GFID:20:12} | |
| else | |
| echo -n "$gfid : " | |
| file=`gfid-resolver.sh $BRICK $gfid -q` | |
| echo $file | |
| fi | |
| gfidfile=${BRICK}/.glusterfs/${gfid:0:2}/${gfid:2:2}/${gfid} | |
| stat "$gfidfile" | |
| mountfile=$MOUNT`echo $file|perl -pe "s|$BRICK||"` | |
| echo '' | |
| echo '*******************' | |
| echo $file | |
| echo $mountfile | |
| echo '' | |
| if [ "$FORCE" == 'force' ] | |
| then | |
| confirm='y' | |
| else | |
| echo -n "unlink file on local brick and self-heal? " | |
| read confirm | |
| fi | |
| if [ $confirm == 'y' ] | |
| then | |
| echo HEALING | |
| unlink "$file" | |
| unlink "$gfidfile" | |
| stat "$mountfile" | |
| stat "$file" | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment