HBASE-23198 Update ref guide for distributed MOB compaction.
[hbase.git] / bin / stop-hbase.sh
blob4a1968145890a9e01b4f8eedd5cb53712659a7c0
1 #!/usr/bin/env bash
3 #/**
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
11 # *
12 # * http://www.apache.org/licenses/LICENSE-2.0
13 # *
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.
19 # */
21 # Modelled after $HADOOP_HOME/bin/stop-hbase.sh.
23 # Stop hadoop hbase daemons. Run this on master node.
25 bin=`dirname "${BASH_SOURCE-$0}"`
26 bin=`cd "$bin">/dev/null; pwd`
28 . "$bin"/hbase-config.sh
29 . "$bin"/hbase-common.sh
31 # variables needed for stop command
32 if [ "$HBASE_LOG_DIR" = "" ]; then
33 export HBASE_LOG_DIR="$HBASE_HOME/logs"
35 mkdir -p "$HBASE_LOG_DIR"
37 if [ "$HBASE_IDENT_STRING" = "" ]; then
38 export HBASE_IDENT_STRING="$USER"
41 export HBASE_LOG_PREFIX=hbase-$HBASE_IDENT_STRING-master-$HOSTNAME
42 export HBASE_LOGFILE=$HBASE_LOG_PREFIX.log
43 logout=$HBASE_LOG_DIR/$HBASE_LOG_PREFIX.out
44 loglog="${HBASE_LOG_DIR}/${HBASE_LOGFILE}"
45 pid=${HBASE_PID_DIR:-/tmp}/hbase-$HBASE_IDENT_STRING-master.pid
47 if [[ -e $pid ]]; then
48 echo -n stopping hbase
49 echo "`date` Stopping hbase (via master)" >> $loglog
51 nohup nice -n ${HBASE_NICENESS:-0} "$HBASE_HOME"/bin/hbase \
52 --config "${HBASE_CONF_DIR}" \
53 master stop "$@" > "$logout" 2>&1 < /dev/null &
55 waitForProcessEnd `cat $pid` 'stop-master-command'
57 rm -f $pid
58 else
59 echo no hbase master found
62 # distributed == false means that the HMaster will kill ZK when it exits
63 # HBASE-6504 - only take the first line of the output in case verbose gc is on
64 distMode=`$bin/hbase --config "$HBASE_CONF_DIR" org.apache.hadoop.hbase.util.HBaseConfTool hbase.cluster.distributed | head -n 1`
65 if [ "$distMode" == 'true' ]
66 then
67 "$bin"/hbase-daemons.sh --config "${HBASE_CONF_DIR}" stop zookeeper