From fe2ae809d1542ae85eb65e30fdcbf76af740a5e7 Mon Sep 17 00:00:00 2001 From: Baiqiang Zhao Date: Sun, 5 Jul 2020 19:30:22 +0530 Subject: [PATCH] HBASE-24671 Add excludefile and designatedfile options to graceful_stop.sh Closes #2013 Signed-off-by: Viraj Jasani --- bin/graceful_stop.sh | 26 ++++++++++++++++++++---- src/main/asciidoc/_chapters/ops_mgt.adoc | 20 +++++++++++------- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/bin/graceful_stop.sh b/bin/graceful_stop.sh index 89e3dd939c21..a2b4efeada18 100755 --- a/bin/graceful_stop.sh +++ b/bin/graceful_stop.sh @@ -22,7 +22,8 @@ # Turn off the balancer before running this script. function usage { echo "Usage: graceful_stop.sh [--config ] [-e] [--restart [--reload]] [--thrift] \ -[--rest] [-nob |--nobalancer ] " +[--rest] [-n |--noack] [--maxthreads ] [--movetimeout ] \ +[-nob |--nobalancer] [-d |--designatedfile ] [-x |--excludefile ] " 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 " restart If we should restart after graceful stop" @@ -34,8 +35,11 @@ moving regions" exit with error. Default value is INT_MAX." 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 " nob| nobalancer Do not manage balancer states. This is only used as optimization in \ + 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" + echo " d|designatedfile xx Designated file with per line as unload targets" + echo " x|excludefile xx Exclude file should have per line. We do not unload \ +regions to hostnames given in exclude file" exit 1 } @@ -57,6 +61,8 @@ movetimeout=2147483647 maxthreads=1 failfast= nob=false +designatedfile= +excludefile= while [ $# -gt 0 ] do case "$1" in @@ -69,6 +75,8 @@ do --maxthreads) shift; maxthreads=$1; shift;; --movetimeout) shift; movetimeout=$1; shift;; --nobalancer | -nob) nob=true; shift;; + --designatedfile | -d) shift; designatedfile=$1; shift;; + --excludefile | -x) shift; excludefile=$1; shift;; --) shift; break;; -*) usage ;; *) break;; # terminate while loop @@ -110,10 +118,20 @@ else log "Previous balancer state was $HBASE_BALANCER_STATE" fi +unload_args="--filename $filename --maxthreads $maxthreads $noack --operation unload \ +--timeout $movetimeout --regionserverhost $hostname" + +if [ "$designatedfile" != "" ]; then + unload_args="$unload_args --designatedfile $designatedfile" +fi + +if [ "$excludefile" != "" ]; then + unload_args="$unload_args --excludefile $excludefile" +fi + log "Unloading $hostname region(s)" HBASE_NOEXEC=true "$bin"/hbase --config ${HBASE_CONF_DIR} org.apache.hadoop.hbase.util.RegionMover \ ---filename $filename --maxthreads $maxthreads $noack --operation "unload" --timeout $movetimeout \ ---regionserverhost $hostname +$unload_args log "Unloaded $hostname region(s)" # Stop the server(s). Have to put hostname into its own little file for hbase-daemons.sh diff --git a/src/main/asciidoc/_chapters/ops_mgt.adoc b/src/main/asciidoc/_chapters/ops_mgt.adoc index 85ad4e833711..d1bc2cf8e0cb 100644 --- a/src/main/asciidoc/_chapters/ops_mgt.adoc +++ b/src/main/asciidoc/_chapters/ops_mgt.adoc @@ -1385,13 +1385,19 @@ Here is its usage: ---- $ ./bin/graceful_stop.sh -Usage: graceful_stop.sh [--config &conf-dir>] [--restart] [--reload] [--thrift] [--rest] &hostname> - thrift If we should stop/start thrift before/after the hbase stop/start - rest If we should stop/start rest before/after the hbase stop/start - restart If we should restart after graceful stop - reload Move offloaded regions back on to the stopped server - debug Move offloaded regions back on to the stopped server - hostname Hostname of server we are to stop +Usage: graceful_stop.sh [--config ] [-e] [--restart [--reload]] [--thrift] [--rest] [-n |--noack] [--maxthreads ] [--movetimeout ] [-nob |--nobalancer] [-d |--designatedfile ] [-x |--excludefile ] + thrift If we should stop/start thrift before/after the hbase stop/start + rest If we should stop/start rest before/after the hbase stop/start + restart If we should restart after graceful stop + reload Move offloaded regions back on to the restarted server + n|noack Enable noAck mode in RegionMover. This is a best effort mode for moving regions + maxthreads xx Limit the number of threads used by the region mover. Default value is 1. + movetimeout xx Timeout for moving regions. If regions are not moved by the timeout value,exit with error. Default value is INT_MAX. + hostname Hostname of server we are to stop + e|failfast Set -e so exit immediately if any command exits with non-zero status + nob|nobalancer Do not manage balancer states. This is only used as optimization in rolling_restart.sh to avoid multiple calls to hbase shell + d|designatedfile xx Designated file with per line as unload targets + x|excludefile xx Exclude file should have per line. We do not unload regions to hostnames given in exclude file ---- To decommission a loaded RegionServer, run the following: +$