4 # * Licensed to the Apache Software Foundation (ASF) under one
5 # * or more contributor license agreements. See the NOTICE file
6 # * distributed with this work for additional information
7 # * regarding copyright ownership. The ASF licenses this file
8 # * to you under the Apache License, Version 2.0 (the
9 # * "License"); you may not use this file except in compliance
10 # * with the License. You may obtain a copy of the License at
12 # * http://www.apache.org/licenses/LICENSE-2.0
14 # * Unless required by applicable law or agreed to in writing, software
15 # * distributed under the License is distributed on an "AS IS" BASIS,
16 # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # * See the License for the specific language governing permissions and
18 # * limitations under the License.
21 # Modelled after $HADOOP_HOME/bin/stop-hbase.sh.
23 # Stop hadoop hbase daemons. Run this on master node.
25 usage
="Usage: stop-hbase.sh can only be used for shutting down entire cluster\
26 to shut down (HMaster|HRegionServer) use hbase-daemon.sh stop (master|regionserver)"
28 bin
=`dirname "${BASH_SOURCE-$0}"`
29 bin
=`cd "$bin">/dev/null; pwd`
31 .
"$bin"/hbase-config.sh
32 .
"$bin"/hbase-common.sh
38 if [ "--help" = "$1" ] ||
[ "-h" = "$1" ]; then
43 # variables needed for stop command
44 if [ "$HBASE_LOG_DIR" = "" ]; then
45 export HBASE_LOG_DIR
="$HBASE_HOME/logs"
47 mkdir
-p "$HBASE_LOG_DIR"
49 if [ "$HBASE_IDENT_STRING" = "" ]; then
50 export HBASE_IDENT_STRING
="$USER"
53 export HBASE_LOG_PREFIX
=hbase-
$HBASE_IDENT_STRING-master-$HOSTNAME
54 export HBASE_LOGFILE
=$HBASE_LOG_PREFIX.log
55 logout=$HBASE_LOG_DIR/$HBASE_LOG_PREFIX.out
56 loglog
="${HBASE_LOG_DIR}/${HBASE_LOGFILE}"
57 pid
=${HBASE_PID_DIR:-/tmp}/hbase-
$HBASE_IDENT_STRING-master.pid
59 if [[ -e $pid ]]; then
60 echo -n stopping hbase
61 echo "`date` Stopping hbase (via master)" >> $loglog
63 nohup nice
-n ${HBASE_NICENESS:-0} "$HBASE_HOME"/bin
/hbase \
64 --config "${HBASE_CONF_DIR}" \
65 master stop
--shutDownCluster "$@" > "$logout" 2>&1 < /dev
/null
&
67 waitForProcessEnd
`cat $pid` 'stop-master-command'
71 echo no hbase master found
74 # distributed == false means that the HMaster will kill ZK when it exits
75 # HBASE-6504 - only take the first line of the output in case verbose gc is on
76 distMode
=`$bin/hbase --config "$HBASE_CONF_DIR" org.apache.hadoop.hbase.util.HBaseConfTool hbase.cluster.distributed | head -n 1`
77 if [ "$distMode" == 'true' ]
79 "$bin"/hbase-daemons.sh
--config "${HBASE_CONF_DIR}" stop zookeeper