2007-08-22 22:19:18 -04:00
|
|
|
#!/usr/bin/env bash
|
2007-07-12 18:08:25 -04:00
|
|
|
#
|
|
|
|
#/**
|
|
|
|
# * Licensed to the Apache Software Foundation (ASF) under one
|
|
|
|
# * or more contributor license agreements. See the NOTICE file
|
|
|
|
# * distributed with this work for additional information
|
|
|
|
# * regarding copyright ownership. The ASF licenses this file
|
|
|
|
# * to you under the Apache License, Version 2.0 (the
|
|
|
|
# * "License"); you may not use this file except in compliance
|
|
|
|
# * with the License. You may obtain a copy of the License at
|
|
|
|
# *
|
|
|
|
# * http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
# *
|
|
|
|
# * Unless required by applicable law or agreed to in writing, software
|
|
|
|
# * distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# * See the License for the specific language governing permissions and
|
|
|
|
# * limitations under the License.
|
|
|
|
# */
|
|
|
|
|
2007-06-14 18:08:56 -04:00
|
|
|
# Modelled after $HADOOP_HOME/bin/stop-hbase.sh.
|
|
|
|
|
|
|
|
# Stop hadoop hbase daemons. Run this on master node.
|
|
|
|
|
2020-11-27 05:30:09 -05:00
|
|
|
usage="Usage: stop-hbase.sh can only be used for shutting down entire cluster\
|
|
|
|
to shut down (HMaster|HRegionServer) use hbase-daemon.sh stop (master|regionserver)"
|
|
|
|
|
2010-07-27 17:50:05 -04:00
|
|
|
bin=`dirname "${BASH_SOURCE-$0}"`
|
2010-07-12 20:24:12 -04:00
|
|
|
bin=`cd "$bin">/dev/null; pwd`
|
2007-06-14 18:08:56 -04:00
|
|
|
|
|
|
|
. "$bin"/hbase-config.sh
|
2013-02-22 06:33:11 -05:00
|
|
|
. "$bin"/hbase-common.sh
|
2007-06-14 18:08:56 -04:00
|
|
|
|
2020-11-27 05:30:09 -05:00
|
|
|
show_usage() {
|
|
|
|
echo "$usage"
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ "--help" = "$1" ] || [ "-h" = "$1" ]; then
|
|
|
|
show_usage
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2010-08-04 01:27:09 -04:00
|
|
|
# variables needed for stop command
|
|
|
|
if [ "$HBASE_LOG_DIR" = "" ]; then
|
|
|
|
export HBASE_LOG_DIR="$HBASE_HOME/logs"
|
|
|
|
fi
|
|
|
|
mkdir -p "$HBASE_LOG_DIR"
|
|
|
|
|
|
|
|
if [ "$HBASE_IDENT_STRING" = "" ]; then
|
|
|
|
export HBASE_IDENT_STRING="$USER"
|
|
|
|
fi
|
|
|
|
|
2011-11-17 17:53:42 -05:00
|
|
|
export HBASE_LOG_PREFIX=hbase-$HBASE_IDENT_STRING-master-$HOSTNAME
|
|
|
|
export HBASE_LOGFILE=$HBASE_LOG_PREFIX.log
|
2022-05-01 10:15:04 -04:00
|
|
|
logout=$HBASE_LOG_DIR/$HBASE_LOG_PREFIX.out
|
2010-08-04 01:27:09 -04:00
|
|
|
loglog="${HBASE_LOG_DIR}/${HBASE_LOGFILE}"
|
|
|
|
pid=${HBASE_PID_DIR:-/tmp}/hbase-$HBASE_IDENT_STRING-master.pid
|
|
|
|
|
2018-01-12 09:34:49 -05:00
|
|
|
if [[ -e $pid ]]; then
|
|
|
|
echo -n stopping hbase
|
|
|
|
echo "`date` Stopping hbase (via master)" >> $loglog
|
2010-08-04 01:27:09 -04:00
|
|
|
|
2018-01-12 09:34:49 -05:00
|
|
|
nohup nice -n ${HBASE_NICENESS:-0} "$HBASE_HOME"/bin/hbase \
|
|
|
|
--config "${HBASE_CONF_DIR}" \
|
2020-11-27 05:30:09 -05:00
|
|
|
master stop --shutDownCluster "$@" > "$logout" 2>&1 < /dev/null &
|
2010-08-04 01:27:09 -04:00
|
|
|
|
2018-01-12 09:34:49 -05:00
|
|
|
waitForProcessEnd `cat $pid` 'stop-master-command'
|
2013-02-22 06:33:11 -05:00
|
|
|
|
2018-01-12 09:34:49 -05:00
|
|
|
rm -f $pid
|
|
|
|
else
|
|
|
|
echo no hbase master found
|
|
|
|
fi
|
2010-08-04 01:27:09 -04:00
|
|
|
|
|
|
|
# distributed == false means that the HMaster will kill ZK when it exits
|
2012-09-15 03:32:52 -04:00
|
|
|
# HBASE-6504 - only take the first line of the output in case verbose gc is on
|
|
|
|
distMode=`$bin/hbase --config "$HBASE_CONF_DIR" org.apache.hadoop.hbase.util.HBaseConfTool hbase.cluster.distributed | head -n 1`
|
2022-05-01 10:15:04 -04:00
|
|
|
if [ "$distMode" == 'true' ]
|
2010-05-18 15:24:36 -04:00
|
|
|
then
|
|
|
|
"$bin"/hbase-daemons.sh --config "${HBASE_CONF_DIR}" stop zookeeper
|
|
|
|
fi
|