HBASE-15486 Avoid multiple disable/enable balancer calls while running rolling-restart.sh --graceful (Samir Ahmic)
This commit is contained in:
parent
db3ba652f8
commit
52fd70500e
|
@ -22,7 +22,7 @@
|
||||||
# Turn off the balancer before running this script.
|
# Turn off the balancer before running this script.
|
||||||
function usage {
|
function usage {
|
||||||
echo "Usage: graceful_stop.sh [--config <conf-dir>] [-e] [--restart [--reload]] [--thrift] \
|
echo "Usage: graceful_stop.sh [--config <conf-dir>] [-e] [--restart [--reload]] [--thrift] \
|
||||||
[--rest] <hostname>"
|
[--rest] [-nob |--nobalancer ] <hostname>"
|
||||||
echo " thrift If we should stop/start thrift before/after the hbase stop/start"
|
echo " thrift If we should stop/start thrift before/after the hbase stop/start"
|
||||||
echo " rest If we should stop/start rest before/after the hbase stop/start"
|
echo " rest If we should stop/start rest before/after the hbase stop/start"
|
||||||
echo " restart If we should restart after graceful stop"
|
echo " restart If we should restart after graceful stop"
|
||||||
|
@ -34,6 +34,8 @@ moving regions"
|
||||||
exit with error. Default value is INT_MAX."
|
exit with error. Default value is INT_MAX."
|
||||||
echo " hostname Hostname of server we are to stop"
|
echo " hostname Hostname of server we are to stop"
|
||||||
echo " e|failfast Set -e so exit immediately if any command exits with non-zero status"
|
echo " e|failfast Set -e so exit immediately if any command exits with non-zero status"
|
||||||
|
echo " nob| nobalancer Do not manage balancer states. This is only used as optimization in \
|
||||||
|
rolling_restart.sh to avoid multiple calls to hbase shell"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,6 +56,7 @@ rest=
|
||||||
movetimeout=2147483647
|
movetimeout=2147483647
|
||||||
maxthreads=1
|
maxthreads=1
|
||||||
failfast=
|
failfast=
|
||||||
|
nob=false
|
||||||
while [ $# -gt 0 ]
|
while [ $# -gt 0 ]
|
||||||
do
|
do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
@ -65,6 +68,7 @@ do
|
||||||
--noack | -n) noack="--noack"; shift;;
|
--noack | -n) noack="--noack"; shift;;
|
||||||
--maxthreads) shift; maxthreads=$1; shift;;
|
--maxthreads) shift; maxthreads=$1; shift;;
|
||||||
--movetimeout) shift; movetimeout=$1; shift;;
|
--movetimeout) shift; movetimeout=$1; shift;;
|
||||||
|
--nobalancer | -nob) nob=true; shift;;
|
||||||
--) shift; break;;
|
--) shift; break;;
|
||||||
-*) usage ;;
|
-*) usage ;;
|
||||||
*) break;; # terminate while loop
|
*) break;; # terminate while loop
|
||||||
|
@ -97,9 +101,14 @@ if [ "$localhostname" == "$hostname" ]; then
|
||||||
local=true
|
local=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ $nob == "true" ]; then
|
||||||
|
log "[ $0 ] skipping disabling balancer -nob argument is used"
|
||||||
|
HBASE_BALANCER_STATE=false
|
||||||
|
else
|
||||||
log "Disabling load balancer"
|
log "Disabling load balancer"
|
||||||
HBASE_BALANCER_STATE=`echo 'balance_switch false' | "$bin"/hbase --config ${HBASE_CONF_DIR} shell | tail -3 | head -1`
|
HBASE_BALANCER_STATE=$(echo 'balance_switch false' | "$bin"/hbase --config "${HBASE_CONF_DIR}" shell | tail -3 | head -1)
|
||||||
log "Previous balancer state was $HBASE_BALANCER_STATE"
|
log "Previous balancer state was $HBASE_BALANCER_STATE"
|
||||||
|
fi
|
||||||
|
|
||||||
log "Unloading $hostname region(s)"
|
log "Unloading $hostname region(s)"
|
||||||
HBASE_NOEXEC=true "$bin"/hbase --config ${HBASE_CONF_DIR} org.apache.hadoop.hbase.util.RegionMover \
|
HBASE_NOEXEC=true "$bin"/hbase --config ${HBASE_CONF_DIR} org.apache.hadoop.hbase.util.RegionMover \
|
||||||
|
@ -166,9 +175,11 @@ if [ "$restart" != "" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Restore balancer state
|
# Restore balancer state
|
||||||
if [ $HBASE_BALANCER_STATE != "false" ]; then
|
if [ $HBASE_BALANCER_STATE != "false" ] && [ $nob != "true" ]; then
|
||||||
log "Restoring balancer state to $HBASE_BALANCER_STATE"
|
log "Restoring balancer state to $HBASE_BALANCER_STATE"
|
||||||
echo "balance_switch $HBASE_BALANCER_STATE" | "$bin"/hbase --config ${HBASE_CONF_DIR} shell &> /dev/null
|
echo "balance_switch $HBASE_BALANCER_STATE" | "$bin"/hbase --config ${HBASE_CONF_DIR} shell &> /dev/null
|
||||||
|
else
|
||||||
|
log "[ $0 ] skipping restoring balancer"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Cleanup tmp files.
|
# Cleanup tmp files.
|
||||||
|
|
|
@ -188,6 +188,10 @@ else
|
||||||
if [ "$zkrs" == "null" ]; then zkrs="rs"; fi
|
if [ "$zkrs" == "null" ]; then zkrs="rs"; fi
|
||||||
zkrs="$zparent/$zkrs"
|
zkrs="$zparent/$zkrs"
|
||||||
online_regionservers=`$bin/hbase zkcli ls $zkrs 2>&1 | tail -1 | sed "s/\[//" | sed "s/\]//"`
|
online_regionservers=`$bin/hbase zkcli ls $zkrs 2>&1 | tail -1 | sed "s/\[//" | sed "s/\]//"`
|
||||||
|
echo "Disabling load balancer"
|
||||||
|
HBASE_BALANCER_STATE=$(echo 'balance_switch false' | "$bin"/hbase --config "${HBASE_CONF_DIR}" shell | tail -3 | head -1)
|
||||||
|
echo "Previous balancer state was $HBASE_BALANCER_STATE"
|
||||||
|
|
||||||
for rs in $online_regionservers
|
for rs in $online_regionservers
|
||||||
do
|
do
|
||||||
rs_parts=(${rs//,/ })
|
rs_parts=(${rs//,/ })
|
||||||
|
@ -198,10 +202,14 @@ else
|
||||||
continue
|
continue
|
||||||
else
|
else
|
||||||
echo "Gracefully restarting: $hostname"
|
echo "Gracefully restarting: $hostname"
|
||||||
"$bin"/graceful_stop.sh --config ${HBASE_CONF_DIR} --restart --reload --maxthreads \
|
"$bin"/graceful_stop.sh --config ${HBASE_CONF_DIR} --restart --reload -nob --maxthreads \
|
||||||
${RR_MAXTHREADS} ${RR_NOACK} --movetimeout ${RR_MOVE_TIMEOUT} $hostname
|
${RR_MAXTHREADS} ${RR_NOACK} --movetimeout ${RR_MOVE_TIMEOUT} $hostname
|
||||||
sleep 1
|
sleep 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
if [ "$HBASE_BALANCER_STATE" != "false" ]; then
|
||||||
|
echo "Restoring balancer state to $HBASE_BALANCER_STATE"
|
||||||
|
echo "balance_switch $HBASE_BALANCER_STATE" | "$bin"/hbase --config "${HBASE_CONF_DIR}" shell &> /dev/null
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue