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-05-07 15:58:53 -04:00
|
|
|
#
|
|
|
|
# The hbase command script. Based on the hadoop command script putting
|
|
|
|
# in hbase classes, libs and configurations ahead of hadoop's.
|
|
|
|
#
|
|
|
|
# TODO: Narrow the amount of duplicated code.
|
|
|
|
#
|
|
|
|
# Environment Variables:
|
|
|
|
#
|
|
|
|
# JAVA_HOME The java implementation to use. Overrides JAVA_HOME.
|
|
|
|
#
|
2008-03-03 14:18:53 -05:00
|
|
|
# HBASE_CLASSPATH Extra Java CLASSPATH entries.
|
|
|
|
#
|
2013-10-12 17:03:39 -04:00
|
|
|
# HBASE_CLASSPATH_PREFIX Extra Java CLASSPATH entries that should be
|
|
|
|
# prefixed to the system classpath.
|
|
|
|
#
|
2015-03-11 06:16:10 -04:00
|
|
|
# HBASE_HEAPSIZE The maximum amount of heap to use.
|
|
|
|
# Default is unset and uses the JVMs default setting
|
|
|
|
# (usually 1/4th of the available memory).
|
2007-05-07 15:58:53 -04:00
|
|
|
#
|
2011-03-11 01:04:18 -05:00
|
|
|
# HBASE_LIBRARY_PATH HBase additions to JAVA_LIBRARY_PATH for adding
|
2013-10-12 17:03:39 -04:00
|
|
|
# native libraries.
|
2011-03-11 01:04:18 -05:00
|
|
|
#
|
2007-05-07 15:58:53 -04:00
|
|
|
# HBASE_OPTS Extra Java runtime options.
|
|
|
|
#
|
|
|
|
# HBASE_CONF_DIR Alternate conf dir. Default is ${HBASE_HOME}/conf.
|
|
|
|
#
|
2008-02-05 01:15:44 -05:00
|
|
|
# HBASE_ROOT_LOGGER The root appender. Default is INFO,console
|
|
|
|
#
|
2012-01-22 16:57:48 -05:00
|
|
|
# JRUBY_HOME JRuby path: $JRUBY_HOME/lib/jruby.jar should exist.
|
|
|
|
# Defaults to the jar packaged with HBase.
|
|
|
|
#
|
|
|
|
# JRUBY_OPTS Extra options (eg '--1.9') passed to the hbase shell.
|
|
|
|
# Empty by default.
|
|
|
|
#
|
2014-09-19 14:06:53 -04:00
|
|
|
# HBASE_SHELL_OPTS Extra options passed to the hbase shell.
|
|
|
|
# Empty by default.
|
|
|
|
#
|
2007-05-07 15:58:53 -04:00
|
|
|
bin=`dirname "$0"`
|
2010-07-12 20:24:12 -04:00
|
|
|
bin=`cd "$bin">/dev/null; pwd`
|
2007-05-07 15:58:53 -04:00
|
|
|
|
2008-02-05 15:09:24 -05:00
|
|
|
# This will set HBASE_HOME, etc.
|
2007-05-07 15:58:53 -04:00
|
|
|
. "$bin"/hbase-config.sh
|
|
|
|
|
|
|
|
cygwin=false
|
|
|
|
case "`uname`" in
|
|
|
|
CYGWIN*) cygwin=true;;
|
|
|
|
esac
|
|
|
|
|
2010-03-12 14:59:35 -05:00
|
|
|
# Detect if we are in hbase sources dir
|
2010-12-22 18:02:42 -05:00
|
|
|
in_dev_env=false
|
|
|
|
if [ -d "${HBASE_HOME}/target" ]; then
|
|
|
|
in_dev_env=true
|
2010-03-12 14:59:35 -05:00
|
|
|
fi
|
|
|
|
|
2016-03-23 13:26:32 -04:00
|
|
|
read -d '' options_string << EOF
|
|
|
|
Options:
|
|
|
|
--config DIR Configuration direction to use. Default: ./conf
|
|
|
|
--hosts HOSTS Override the list in 'regionservers' file
|
|
|
|
--auth-as-server Authenticate to ZooKeeper using servers configuration
|
|
|
|
EOF
|
2007-05-07 15:58:53 -04:00
|
|
|
# if no args specified, show usage
|
|
|
|
if [ $# = 0 ]; then
|
2013-09-11 18:06:33 -04:00
|
|
|
echo "Usage: hbase [<options>] <command> [<args>]"
|
2016-03-23 13:26:32 -04:00
|
|
|
echo "$options_string"
|
2011-08-23 17:37:32 -04:00
|
|
|
echo ""
|
2013-09-11 18:06:33 -04:00
|
|
|
echo "Commands:"
|
|
|
|
echo "Some commands take arguments. Pass no args or -h for usage."
|
|
|
|
echo " shell Run the HBase shell"
|
|
|
|
echo " hbck Run the hbase 'fsck' tool"
|
2016-03-23 13:26:32 -04:00
|
|
|
echo " snapshot Tool for managing snapshots"
|
2014-11-18 15:12:35 -05:00
|
|
|
echo " wal Write-ahead-log analyzer"
|
2013-09-11 18:06:33 -04:00
|
|
|
echo " hfile Store file analyzer"
|
|
|
|
echo " zkcli Run the ZooKeeper shell"
|
2015-09-22 12:57:28 -04:00
|
|
|
echo " master Run an HBase HMaster node"
|
2013-09-11 18:06:33 -04:00
|
|
|
echo " regionserver Run an HBase HRegionServer node"
|
2016-05-04 16:17:43 -04:00
|
|
|
echo " zookeeper Run a ZooKeeper server"
|
2013-09-11 18:06:33 -04:00
|
|
|
echo " rest Run an HBase REST server"
|
|
|
|
echo " thrift Run the HBase Thrift server"
|
|
|
|
echo " thrift2 Run the HBase Thrift2 server"
|
|
|
|
echo " clean Run the HBase clean up script"
|
|
|
|
echo " classpath Dump hbase CLASSPATH"
|
2013-11-17 15:49:24 -05:00
|
|
|
echo " mapredcp Dump CLASSPATH entries required by mapreduce"
|
2014-08-01 13:31:27 -04:00
|
|
|
echo " pe Run PerformanceEvaluation"
|
|
|
|
echo " ltt Run LoadTestTool"
|
2016-01-06 05:47:19 -05:00
|
|
|
echo " canary Run the Canary tool"
|
2013-09-11 18:06:33 -04:00
|
|
|
echo " version Print the version"
|
|
|
|
echo " CLASSNAME Run the class named CLASSNAME"
|
2007-05-07 15:58:53 -04:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# get arguments
|
|
|
|
COMMAND=$1
|
|
|
|
shift
|
|
|
|
|
|
|
|
JAVA=$JAVA_HOME/bin/java
|
|
|
|
|
2011-11-29 00:54:59 -05:00
|
|
|
# override default settings for this command, if applicable
|
|
|
|
if [ -f "$HBASE_HOME/conf/hbase-env-$COMMAND.sh" ]; then
|
|
|
|
. "$HBASE_HOME/conf/hbase-env-$COMMAND.sh"
|
|
|
|
fi
|
|
|
|
|
2014-11-24 20:58:03 -05:00
|
|
|
add_size_suffix() {
|
|
|
|
# add an 'm' suffix if the argument is missing one, otherwise use whats there
|
|
|
|
local val="$1"
|
|
|
|
local lastchar=${val: -1}
|
|
|
|
if [[ "mMgG" == *$lastchar* ]]; then
|
|
|
|
echo $val
|
|
|
|
else
|
|
|
|
echo ${val}m
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
if [[ -n "$HBASE_HEAPSIZE" ]]; then
|
|
|
|
JAVA_HEAP_MAX="-Xmx$(add_size_suffix $HBASE_HEAPSIZE)"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -n "$HBASE_OFFHEAPSIZE" ]]; then
|
|
|
|
JAVA_OFFHEAP_MAX="-XX:MaxDirectMemorySize=$(add_size_suffix $HBASE_OFFHEAPSIZE)"
|
2007-05-07 15:58:53 -04:00
|
|
|
fi
|
|
|
|
|
2008-03-24 15:13:56 -04:00
|
|
|
# so that filenames w/ spaces are handled correctly in loops below
|
2012-05-26 01:56:04 -04:00
|
|
|
ORIG_IFS=$IFS
|
2008-03-24 15:13:56 -04:00
|
|
|
IFS=
|
|
|
|
|
2008-04-20 11:32:29 -04:00
|
|
|
# CLASSPATH initially contains $HBASE_CONF_DIR
|
2008-04-29 19:29:17 -04:00
|
|
|
CLASSPATH="${HBASE_CONF_DIR}"
|
2007-05-07 15:58:53 -04:00
|
|
|
CLASSPATH=${CLASSPATH}:$JAVA_HOME/lib/tools.jar
|
|
|
|
|
2012-05-26 01:56:04 -04:00
|
|
|
add_to_cp_if_exists() {
|
|
|
|
if [ -d "$@" ]; then
|
|
|
|
CLASSPATH=${CLASSPATH}:"$@"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2012-05-30 19:51:44 -04:00
|
|
|
# For releases, add hbase & webapps to CLASSPATH
|
|
|
|
# Webapps must come first else it messes up Jetty
|
|
|
|
if [ -d "$HBASE_HOME/hbase-webapps" ]; then
|
|
|
|
add_to_cp_if_exists "${HBASE_HOME}"
|
|
|
|
fi
|
|
|
|
#add if we are in a dev environment
|
|
|
|
if [ -d "$HBASE_HOME/hbase-server/target/hbase-webapps" ]; then
|
|
|
|
add_to_cp_if_exists "${HBASE_HOME}/hbase-server/target"
|
|
|
|
fi
|
|
|
|
|
2010-05-18 00:12:04 -04:00
|
|
|
add_maven_deps_to_classpath() {
|
2010-12-22 18:02:42 -05:00
|
|
|
f="${HBASE_HOME}/target/cached_classpath.txt"
|
2010-05-20 05:02:18 -04:00
|
|
|
if [ ! -f "${f}" ]
|
|
|
|
then
|
2013-07-09 19:09:42 -04:00
|
|
|
echo "As this is a development environment, we need ${f} to be generated from maven (command: mvn install -DskipTests)"
|
2012-11-22 09:44:38 -05:00
|
|
|
exit 1
|
2010-05-20 05:02:18 -04:00
|
|
|
fi
|
2010-05-18 00:12:04 -04:00
|
|
|
CLASSPATH=${CLASSPATH}:`cat "${f}"`
|
|
|
|
}
|
2007-05-07 15:58:53 -04:00
|
|
|
|
2012-05-26 01:56:04 -04:00
|
|
|
|
2012-05-30 19:51:44 -04:00
|
|
|
#Add the development env class path stuff
|
2010-12-22 18:02:42 -05:00
|
|
|
if $in_dev_env; then
|
2012-10-09 16:47:33 -04:00
|
|
|
add_maven_deps_to_classpath
|
2010-03-04 12:43:05 -05:00
|
|
|
fi
|
|
|
|
|
2012-05-26 01:56:04 -04:00
|
|
|
#add the hbase jars for each module
|
|
|
|
for f in $HBASE_HOME/hbase-jars/hbase*.jar; do
|
|
|
|
if [[ $f = *sources.jar ]]
|
2010-06-10 19:21:45 -04:00
|
|
|
then
|
|
|
|
: # Skip sources.jar
|
|
|
|
elif [ -f $f ]
|
|
|
|
then
|
2007-09-19 12:45:01 -04:00
|
|
|
CLASSPATH=${CLASSPATH}:$f;
|
|
|
|
fi
|
|
|
|
done
|
2007-05-07 15:58:53 -04:00
|
|
|
|
2008-05-14 15:06:52 -04:00
|
|
|
# Add libs to CLASSPATH
|
|
|
|
for f in $HBASE_HOME/lib/*.jar; do
|
|
|
|
CLASSPATH=${CLASSPATH}:$f;
|
|
|
|
done
|
|
|
|
|
2007-05-07 15:58:53 -04:00
|
|
|
# default log directory & file
|
2008-02-05 01:15:44 -05:00
|
|
|
if [ "$HBASE_LOG_DIR" = "" ]; then
|
|
|
|
HBASE_LOG_DIR="$HBASE_HOME/logs"
|
2007-05-07 15:58:53 -04:00
|
|
|
fi
|
2008-02-05 01:15:44 -05:00
|
|
|
if [ "$HBASE_LOGFILE" = "" ]; then
|
|
|
|
HBASE_LOGFILE='hbase.log'
|
2007-05-07 15:58:53 -04:00
|
|
|
fi
|
|
|
|
|
2011-03-11 01:04:18 -05:00
|
|
|
function append_path() {
|
|
|
|
if [ -z "$1" ]; then
|
|
|
|
echo $2
|
|
|
|
else
|
|
|
|
echo $1:$2
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2011-07-24 01:21:02 -04:00
|
|
|
JAVA_PLATFORM=""
|
|
|
|
|
2014-08-05 00:26:17 -04:00
|
|
|
# if HBASE_LIBRARY_PATH is defined lets use it as first or second option
|
|
|
|
if [ "$HBASE_LIBRARY_PATH" != "" ]; then
|
|
|
|
JAVA_LIBRARY_PATH=$(append_path "$JAVA_LIBRARY_PATH" "$HBASE_LIBRARY_PATH")
|
|
|
|
fi
|
|
|
|
|
2011-07-24 01:21:02 -04:00
|
|
|
#If avail, add Hadoop to the CLASSPATH and to the JAVA_LIBRARY_PATH
|
2015-02-27 19:27:40 -05:00
|
|
|
# Allow this functionality to be disabled
|
|
|
|
if [ "$HBASE_DISABLE_HADOOP_CLASSPATH_LOOKUP" != "true" ] ; then
|
|
|
|
HADOOP_IN_PATH=$(PATH="${HADOOP_HOME:-${HADOOP_PREFIX}}/bin:$PATH" which hadoop 2>/dev/null)
|
|
|
|
if [ -f ${HADOOP_IN_PATH} ]; then
|
|
|
|
HADOOP_JAVA_LIBRARY_PATH=$(HADOOP_CLASSPATH="$CLASSPATH" ${HADOOP_IN_PATH} \
|
|
|
|
org.apache.hadoop.hbase.util.GetJavaProperty java.library.path 2>/dev/null)
|
|
|
|
if [ -n "$HADOOP_JAVA_LIBRARY_PATH" ]; then
|
|
|
|
JAVA_LIBRARY_PATH=$(append_path "${JAVA_LIBRARY_PATH}" "$HADOOP_JAVA_LIBRARY_PATH")
|
|
|
|
fi
|
|
|
|
CLASSPATH=$(append_path "${CLASSPATH}" `${HADOOP_IN_PATH} classpath 2>/dev/null`)
|
2011-07-24 01:21:02 -04:00
|
|
|
fi
|
|
|
|
fi
|
2008-04-14 15:34:11 -04:00
|
|
|
|
2014-07-10 20:47:04 -04:00
|
|
|
# Add user-specified CLASSPATH last
|
|
|
|
if [ "$HBASE_CLASSPATH" != "" ]; then
|
|
|
|
CLASSPATH=${CLASSPATH}:${HBASE_CLASSPATH}
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Add user-specified CLASSPATH prefix first
|
|
|
|
if [ "$HBASE_CLASSPATH_PREFIX" != "" ]; then
|
|
|
|
CLASSPATH=${HBASE_CLASSPATH_PREFIX}:${CLASSPATH}
|
|
|
|
fi
|
|
|
|
|
|
|
|
# cygwin path translation
|
|
|
|
if $cygwin; then
|
|
|
|
CLASSPATH=`cygpath -p -w "$CLASSPATH"`
|
|
|
|
HBASE_HOME=`cygpath -d "$HBASE_HOME"`
|
|
|
|
HBASE_LOG_DIR=`cygpath -d "$HBASE_LOG_DIR"`
|
|
|
|
fi
|
|
|
|
|
2011-07-24 01:21:02 -04:00
|
|
|
if [ -d "${HBASE_HOME}/build/native" -o -d "${HBASE_HOME}/lib/native" ]; then
|
|
|
|
if [ -z $JAVA_PLATFORM ]; then
|
|
|
|
JAVA_PLATFORM=`CLASSPATH=${CLASSPATH} ${JAVA} org.apache.hadoop.util.PlatformName | sed -e "s/ /_/g"`
|
|
|
|
fi
|
2008-04-14 15:34:11 -04:00
|
|
|
if [ -d "$HBASE_HOME/build/native" ]; then
|
2011-03-11 01:04:18 -05:00
|
|
|
JAVA_LIBRARY_PATH=$(append_path "$JAVA_LIBRARY_PATH" ${HBASE_HOME}/build/native/${JAVA_PLATFORM}/lib)
|
2008-04-14 15:34:11 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -d "${HBASE_HOME}/lib/native" ]; then
|
2011-03-11 01:04:18 -05:00
|
|
|
JAVA_LIBRARY_PATH=$(append_path "$JAVA_LIBRARY_PATH" ${HBASE_HOME}/lib/native/${JAVA_PLATFORM})
|
2008-04-14 15:34:11 -04:00
|
|
|
fi
|
|
|
|
fi
|
2007-05-07 15:58:53 -04:00
|
|
|
|
|
|
|
# cygwin path translation
|
|
|
|
if $cygwin; then
|
|
|
|
JAVA_LIBRARY_PATH=`cygpath -p "$JAVA_LIBRARY_PATH"`
|
|
|
|
fi
|
|
|
|
|
|
|
|
# restore ordinary behaviour
|
|
|
|
unset IFS
|
|
|
|
|
2012-12-20 14:10:10 -05:00
|
|
|
#Set the right GC options based on the what we are running
|
2013-04-24 00:45:44 -04:00
|
|
|
declare -a server_cmds=("master" "regionserver" "thrift" "thrift2" "rest" "avro" "zookeeper")
|
2013-03-14 14:11:39 -04:00
|
|
|
for cmd in ${server_cmds[@]}; do
|
2012-12-20 14:10:10 -05:00
|
|
|
if [[ $cmd == $COMMAND ]]; then
|
2013-03-14 14:11:39 -04:00
|
|
|
server=true
|
2012-12-20 14:10:10 -05:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2013-03-14 14:11:39 -04:00
|
|
|
if [[ $server ]]; then
|
2012-12-20 14:10:10 -05:00
|
|
|
HBASE_OPTS="$HBASE_OPTS $SERVER_GC_OPTS"
|
2013-03-14 14:11:39 -04:00
|
|
|
else
|
|
|
|
HBASE_OPTS="$HBASE_OPTS $CLIENT_GC_OPTS"
|
2012-12-20 14:10:10 -05:00
|
|
|
fi
|
|
|
|
|
2016-01-26 17:43:24 -05:00
|
|
|
if [ "$AUTH_AS_SERVER" == "true" ] || [ "$COMMAND" = "hbck" ]; then
|
|
|
|
if [ -n "$HBASE_SERVER_JAAS_OPTS" ]; then
|
|
|
|
HBASE_OPTS="$HBASE_OPTS $HBASE_SERVER_JAAS_OPTS"
|
|
|
|
else
|
|
|
|
HBASE_OPTS="$HBASE_OPTS $HBASE_REGIONSERVER_OPTS"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2009-03-18 16:46:18 -04:00
|
|
|
# figure out which class to run
|
|
|
|
if [ "$COMMAND" = "shell" ] ; then
|
2012-01-22 16:57:48 -05:00
|
|
|
# eg export JRUBY_HOME=/usr/local/share/jruby
|
|
|
|
if [ "$JRUBY_HOME" != "" ] ; then
|
|
|
|
CLASSPATH="$JRUBY_HOME/lib/jruby.jar:$CLASSPATH"
|
|
|
|
HBASE_OPTS="$HBASE_OPTS -Djruby.home=$JRUBY_HOME -Djruby.lib=$JRUBY_HOME/lib"
|
2012-05-26 01:56:04 -04:00
|
|
|
fi
|
|
|
|
#find the hbase ruby sources
|
|
|
|
if [ -d "$HBASE_HOME/lib/ruby" ]; then
|
|
|
|
HBASE_OPTS="$HBASE_OPTS -Dhbase.ruby.sources=$HBASE_HOME/lib/ruby"
|
|
|
|
else
|
2013-09-23 12:40:51 -04:00
|
|
|
HBASE_OPTS="$HBASE_OPTS -Dhbase.ruby.sources=$HBASE_HOME/hbase-shell/src/main/ruby"
|
2012-01-22 16:57:48 -05:00
|
|
|
fi
|
2014-07-16 20:11:54 -04:00
|
|
|
HBASE_OPTS="$HBASE_OPTS $HBASE_SHELL_OPTS"
|
2012-01-22 16:57:48 -05:00
|
|
|
CLASS="org.jruby.Main -X+O ${JRUBY_OPTS} ${HBASE_HOME}/bin/hirb.rb"
|
2011-08-23 17:37:32 -04:00
|
|
|
elif [ "$COMMAND" = "hbck" ] ; then
|
|
|
|
CLASS='org.apache.hadoop.hbase.util.HBaseFsck'
|
2014-11-18 15:12:35 -05:00
|
|
|
# TODO remove old 'hlog' version
|
|
|
|
elif [ "$COMMAND" = "hlog" -o "$COMMAND" = "wal" ] ; then
|
|
|
|
CLASS='org.apache.hadoop.hbase.wal.WALPrettyPrinter'
|
2011-08-23 17:37:32 -04:00
|
|
|
elif [ "$COMMAND" = "hfile" ] ; then
|
2014-09-09 16:48:29 -04:00
|
|
|
CLASS='org.apache.hadoop.hbase.io.hfile.HFilePrettyPrinter'
|
2011-08-23 17:37:32 -04:00
|
|
|
elif [ "$COMMAND" = "zkcli" ] ; then
|
2013-06-19 14:37:26 -04:00
|
|
|
CLASS="org.apache.hadoop.hbase.zookeeper.ZooKeeperMainServer"
|
2013-08-22 18:46:14 -04:00
|
|
|
elif [ "$COMMAND" = "upgrade" ] ; then
|
2015-09-22 12:57:28 -04:00
|
|
|
echo "This command was used to upgrade to HBase 0.96, it was removed in HBase 2.0.0."
|
|
|
|
echo "Please follow the documentation at http://hbase.apache.org/book.html#upgrading."
|
|
|
|
exit 1
|
2015-01-21 16:49:14 -05:00
|
|
|
elif [ "$COMMAND" = "snapshot" ] ; then
|
2016-03-23 13:26:32 -04:00
|
|
|
SUBCOMMAND=$1
|
|
|
|
shift
|
|
|
|
if [ "$SUBCOMMAND" = "create" ] ; then
|
|
|
|
CLASS="org.apache.hadoop.hbase.snapshot.CreateSnapshot"
|
|
|
|
elif [ "$SUBCOMMAND" = "info" ] ; then
|
|
|
|
CLASS="org.apache.hadoop.hbase.snapshot.SnapshotInfo"
|
|
|
|
elif [ "$SUBCOMMAND" = "export" ] ; then
|
|
|
|
CLASS="org.apache.hadoop.hbase.snapshot.ExportSnapshot"
|
|
|
|
else
|
|
|
|
echo "Usage: hbase [<options>] snapshot <subcommand> [<args>]"
|
|
|
|
echo "$options_string"
|
|
|
|
echo ""
|
|
|
|
echo "Subcommands:"
|
|
|
|
echo " create Create a new snapshot of a table"
|
|
|
|
echo " info Tool for dumping snapshot information"
|
|
|
|
echo " export Export an existing snapshot"
|
|
|
|
exit 1
|
|
|
|
fi
|
2009-03-18 16:46:18 -04:00
|
|
|
elif [ "$COMMAND" = "master" ] ; then
|
|
|
|
CLASS='org.apache.hadoop.hbase.master.HMaster'
|
2013-11-26 19:52:12 -05:00
|
|
|
if [ "$1" != "stop" ] && [ "$1" != "clear" ] ; then
|
2010-01-22 14:26:09 -05:00
|
|
|
HBASE_OPTS="$HBASE_OPTS $HBASE_MASTER_OPTS"
|
|
|
|
fi
|
2009-03-18 16:46:18 -04:00
|
|
|
elif [ "$COMMAND" = "regionserver" ] ; then
|
|
|
|
CLASS='org.apache.hadoop.hbase.regionserver.HRegionServer'
|
2010-01-22 14:26:09 -05:00
|
|
|
if [ "$1" != "stop" ] ; then
|
|
|
|
HBASE_OPTS="$HBASE_OPTS $HBASE_REGIONSERVER_OPTS"
|
|
|
|
fi
|
2009-03-18 16:46:18 -04:00
|
|
|
elif [ "$COMMAND" = "thrift" ] ; then
|
|
|
|
CLASS='org.apache.hadoop.hbase.thrift.ThriftServer'
|
2010-01-22 14:26:09 -05:00
|
|
|
if [ "$1" != "stop" ] ; then
|
2013-04-24 00:45:44 -04:00
|
|
|
HBASE_OPTS="$HBASE_OPTS $HBASE_THRIFT_OPTS"
|
|
|
|
fi
|
|
|
|
elif [ "$COMMAND" = "thrift2" ] ; then
|
|
|
|
CLASS='org.apache.hadoop.hbase.thrift2.ThriftServer'
|
|
|
|
if [ "$1" != "stop" ] ; then
|
2011-11-02 00:26:26 -04:00
|
|
|
HBASE_OPTS="$HBASE_OPTS $HBASE_THRIFT_OPTS"
|
|
|
|
fi
|
2010-07-18 01:24:17 -04:00
|
|
|
elif [ "$COMMAND" = "rest" ] ; then
|
2012-12-07 12:32:52 -05:00
|
|
|
CLASS='org.apache.hadoop.hbase.rest.RESTServer'
|
2010-07-18 01:24:17 -04:00
|
|
|
if [ "$1" != "stop" ] ; then
|
|
|
|
HBASE_OPTS="$HBASE_OPTS $HBASE_REST_OPTS"
|
|
|
|
fi
|
2009-03-18 16:46:18 -04:00
|
|
|
elif [ "$COMMAND" = "zookeeper" ] ; then
|
|
|
|
CLASS='org.apache.hadoop.hbase.zookeeper.HQuorumPeer'
|
2010-01-22 14:26:09 -05:00
|
|
|
if [ "$1" != "stop" ] ; then
|
|
|
|
HBASE_OPTS="$HBASE_OPTS $HBASE_ZOOKEEPER_OPTS"
|
|
|
|
fi
|
2013-05-03 16:30:44 -04:00
|
|
|
elif [ "$COMMAND" = "clean" ] ; then
|
|
|
|
case $1 in
|
|
|
|
--cleanZk|--cleanHdfs|--cleanAll)
|
|
|
|
matches="yes" ;;
|
|
|
|
*) ;;
|
|
|
|
esac
|
|
|
|
if [ $# -ne 1 -o "$matches" = "" ]; then
|
|
|
|
echo "Usage: hbase clean (--cleanZk|--cleanHdfs|--cleanAll)"
|
|
|
|
echo "Options: "
|
|
|
|
echo " --cleanZk cleans hbase related data from zookeeper."
|
|
|
|
echo " --cleanHdfs cleans hbase related data from hdfs."
|
|
|
|
echo " --cleanAll cleans hbase related data from both zookeeper and hdfs."
|
|
|
|
exit 1;
|
|
|
|
fi
|
2013-05-30 19:11:17 -04:00
|
|
|
"$bin"/hbase-cleanup.sh --config ${HBASE_CONF_DIR} $@
|
2013-05-03 16:30:44 -04:00
|
|
|
exit $?
|
2013-11-17 15:49:24 -05:00
|
|
|
elif [ "$COMMAND" = "mapredcp" ] ; then
|
|
|
|
CLASS='org.apache.hadoop.hbase.util.MapreduceDependencyClasspathTool'
|
2010-09-20 15:13:43 -04:00
|
|
|
elif [ "$COMMAND" = "classpath" ] ; then
|
|
|
|
echo $CLASSPATH
|
|
|
|
exit 0
|
2014-08-01 13:31:27 -04:00
|
|
|
elif [ "$COMMAND" = "pe" ] ; then
|
|
|
|
CLASS='org.apache.hadoop.hbase.PerformanceEvaluation'
|
|
|
|
HBASE_OPTS="$HBASE_OPTS $HBASE_PE_OPTS"
|
|
|
|
elif [ "$COMMAND" = "ltt" ] ; then
|
|
|
|
CLASS='org.apache.hadoop.hbase.util.LoadTestTool'
|
|
|
|
HBASE_OPTS="$HBASE_OPTS $HBASE_LTT_OPTS"
|
2016-01-06 05:47:19 -05:00
|
|
|
elif [ "$COMMAND" = "canary" ] ; then
|
|
|
|
CLASS='org.apache.hadoop.hbase.tool.Canary'
|
|
|
|
HBASE_OPTS="$HBASE_OPTS $HBASE_CANARY_OPTS"
|
2011-06-07 20:06:02 -04:00
|
|
|
elif [ "$COMMAND" = "version" ] ; then
|
|
|
|
CLASS='org.apache.hadoop.hbase.util.VersionInfo'
|
2007-05-07 15:58:53 -04:00
|
|
|
else
|
2009-03-18 16:46:18 -04:00
|
|
|
CLASS=$COMMAND
|
|
|
|
fi
|
2009-01-27 13:20:09 -05:00
|
|
|
|
2009-03-18 16:46:18 -04:00
|
|
|
# Have JVM dump heap if we run out of memory. Files will be 'launch directory'
|
|
|
|
# and are named like the following: java_pid21612.hprof. Apparently it doesn't
|
|
|
|
# 'cost' to have this flag enabled. Its a 1.6 flag only. See:
|
|
|
|
# http://blogs.sun.com/alanb/entry/outofmemoryerror_looks_a_bit_better
|
|
|
|
HBASE_OPTS="$HBASE_OPTS -Dhbase.log.dir=$HBASE_LOG_DIR"
|
|
|
|
HBASE_OPTS="$HBASE_OPTS -Dhbase.log.file=$HBASE_LOGFILE"
|
|
|
|
HBASE_OPTS="$HBASE_OPTS -Dhbase.home.dir=$HBASE_HOME"
|
|
|
|
HBASE_OPTS="$HBASE_OPTS -Dhbase.id.str=$HBASE_IDENT_STRING"
|
|
|
|
HBASE_OPTS="$HBASE_OPTS -Dhbase.root.logger=${HBASE_ROOT_LOGGER:-INFO,console}"
|
|
|
|
if [ "x$JAVA_LIBRARY_PATH" != "x" ]; then
|
|
|
|
HBASE_OPTS="$HBASE_OPTS -Djava.library.path=$JAVA_LIBRARY_PATH"
|
2012-09-18 13:02:01 -04:00
|
|
|
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$JAVA_LIBRARY_PATH"
|
2009-01-27 13:20:09 -05:00
|
|
|
fi
|
2009-03-18 16:46:18 -04:00
|
|
|
|
2012-05-17 15:36:42 -04:00
|
|
|
# Enable security logging on the master and regionserver only
|
|
|
|
if [ "$COMMAND" = "master" ] || [ "$COMMAND" = "regionserver" ]; then
|
|
|
|
HBASE_OPTS="$HBASE_OPTS -Dhbase.security.logger=${HBASE_SECURITY_LOGGER:-INFO,RFAS}"
|
|
|
|
else
|
|
|
|
HBASE_OPTS="$HBASE_OPTS -Dhbase.security.logger=${HBASE_SECURITY_LOGGER:-INFO,NullAppender}"
|
|
|
|
fi
|
|
|
|
|
2014-11-24 20:58:03 -05:00
|
|
|
HEAP_SETTINGS="$JAVA_HEAP_MAX $JAVA_OFFHEAP_MAX"
|
2011-04-05 00:08:24 -04:00
|
|
|
# Exec unless HBASE_NOEXEC is set.
|
2013-08-10 00:10:03 -04:00
|
|
|
export CLASSPATH
|
2011-04-05 00:08:24 -04:00
|
|
|
if [ "${HBASE_NOEXEC}" != "" ]; then
|
2014-11-24 20:58:03 -05:00
|
|
|
"$JAVA" -Dproc_$COMMAND -XX:OnOutOfMemoryError="kill -9 %p" $HEAP_SETTINGS $HBASE_OPTS $CLASS "$@"
|
2011-04-05 00:08:24 -04:00
|
|
|
else
|
2014-11-24 20:58:03 -05:00
|
|
|
exec "$JAVA" -Dproc_$COMMAND -XX:OnOutOfMemoryError="kill -9 %p" $HEAP_SETTINGS $HBASE_OPTS $CLASS "$@"
|
2011-04-05 00:08:24 -04:00
|
|
|
fi
|