diff --git a/bin/graceful_stop.sh b/bin/graceful_stop.sh index 89446532101e..bcd1b6847593 100755 --- a/bin/graceful_stop.sh +++ b/bin/graceful_stop.sh @@ -18,8 +18,7 @@ # * limitations under the License. # */ -# Move regions off a server then stop it. Optionally restart and reload. -# Turn off the balancer before running this script. +# Move regions off a server then stop it. Optionally restart and reload. function usage { echo "Usage: graceful_stop.sh [--config ] [-e] [--restart [--reload]] [--thrift] \ [--rest] [-n |--noack] [--maxthreads ] [--movetimeout ] \ @@ -33,7 +32,7 @@ moving regions" echo " maxthreads xx Limit the number of threads used by the region mover. Default value is 1." echo " movetimeout xx Timeout for moving regions. If regions are not moved by the timeout value,\ exit with error. Default value is INT_MAX." - echo " hostname Hostname of server we are to stop" + echo " hostname Hostname to stop; match what HBase uses; pass 'localhost' if local to avoid ssh" 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" @@ -102,13 +101,6 @@ fi hostname=$1 filename="/tmp/$hostname" -local= -localhostname=`/bin/hostname -f` - -if [ "$localhostname" == "$hostname" ]; then - local=true -fi - if [ "$nob" == "true" ]; then log "[ $0 ] skipping disabling balancer -nob argument is used" HBASE_BALANCER_STATE=false @@ -118,8 +110,13 @@ else log "Previous balancer state was $HBASE_BALANCER_STATE" fi +unload_hostname="$hostname" +if [[ "$hostname" == "localhost" ]]; then + # Need fqdn to remove the host Region server from target Region Servers list + unload_hostname=`/bin/hostname -f` +fi unload_args="--filename $filename --maxthreads $maxthreads $noack --operation unload \ ---timeout $movetimeout --regionserverhost $hostname" + --timeout $movetimeout --regionserverhost $unload_hostname" if [ "$designatedfile" != "" ]; then unload_args="$unload_args --designatedfile $designatedfile" @@ -139,49 +136,25 @@ hosts="/tmp/$(basename $0).$$.tmp" echo $hostname >> $hosts if [ "$thrift" != "" ]; then log "Stopping thrift server on $hostname" - if [ "$local" == true ]; then - "$bin"/hbase-daemon.sh --config ${HBASE_CONF_DIR} stop thrift - else - "$bin"/hbase-daemons.sh --config ${HBASE_CONF_DIR} --hosts ${hosts} stop thrift - fi + "$bin"/hbase-daemons.sh --config ${HBASE_CONF_DIR} --hosts ${hosts} stop thrift fi if [ "$rest" != "" ]; then log "Stopping rest server on $hostname" - if [ "$local" == true ]; then - "$bin"/hbase-daemon.sh --config ${HBASE_CONF_DIR} stop rest - else - "$bin"/hbase-daemons.sh --config ${HBASE_CONF_DIR} --hosts ${hosts} stop rest - fi + "$bin"/hbase-daemons.sh --config ${HBASE_CONF_DIR} --hosts ${hosts} stop rest fi log "Stopping regionserver on $hostname" -if [ "$local" == true ]; then - "$bin"/hbase-daemon.sh --config ${HBASE_CONF_DIR} stop regionserver -else - "$bin"/hbase-daemons.sh --config ${HBASE_CONF_DIR} --hosts ${hosts} stop regionserver -fi +"$bin"/hbase-daemons.sh --config ${HBASE_CONF_DIR} --hosts ${hosts} stop regionserver if [ "$restart" != "" ]; then log "Restarting regionserver on $hostname" - if [ "$local" == true ]; then - "$bin"/hbase-daemon.sh --config ${HBASE_CONF_DIR} start regionserver - else - "$bin"/hbase-daemons.sh --config ${HBASE_CONF_DIR} --hosts ${hosts} start regionserver - fi + "$bin"/hbase-daemons.sh --config ${HBASE_CONF_DIR} --hosts ${hosts} start regionserver if [ "$thrift" != "" ]; then log "Restarting thrift server on $hostname" # -b 0.0.0.0 says listen on all interfaces rather than just default. - if [ "$local" == true ]; then - "$bin"/hbase-daemon.sh --config ${HBASE_CONF_DIR} start thrift -b 0.0.0.0 - else - "$bin"/hbase-daemons.sh --config ${HBASE_CONF_DIR} --hosts ${hosts} start thrift -b 0.0.0.0 - fi + "$bin"/hbase-daemons.sh --config ${HBASE_CONF_DIR} --hosts ${hosts} start thrift -b 0.0.0.0 fi if [ "$rest" != "" ]; then log "Restarting rest server on $hostname" - if [ "$local" == true ]; then - "$bin"/hbase-daemon.sh --config ${HBASE_CONF_DIR} start rest - else - "$bin"/hbase-daemons.sh --config ${HBASE_CONF_DIR} --hosts ${hosts} start rest - fi + "$bin"/hbase-daemons.sh --config ${HBASE_CONF_DIR} --hosts ${hosts} start rest fi if [ "$reload" != "" ]; then log "Reloading $hostname region(s)"