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 # The hbase command script. Based on the hadoop command script putting
22 # in hbase classes, libs and configurations ahead of hadoop's.
24 # TODO: Narrow the amount of duplicated code.
26 # Environment Variables:
28 # JAVA_HOME The java implementation to use. Overrides JAVA_HOME.
30 # HBASE_CLASSPATH Extra Java CLASSPATH entries.
32 # HBASE_CLASSPATH_PREFIX Extra Java CLASSPATH entries that should be
33 # prefixed to the system classpath.
35 # HBASE_HEAPSIZE The maximum amount of heap to use.
36 # Default is unset and uses the JVMs default setting
37 # (usually 1/4th of the available memory).
39 # HBASE_LIBRARY_PATH HBase additions to JAVA_LIBRARY_PATH for adding
42 # HBASE_OPTS Extra Java runtime options.
44 # HBASE_CONF_DIR Alternate conf dir. Default is ${HBASE_HOME}/conf.
46 # HBASE_ROOT_LOGGER The root appender. Default is INFO,console
48 # JRUBY_HOME JRuby path: $JRUBY_HOME/lib/jruby.jar should exist.
49 # Defaults to the jar packaged with HBase.
51 # JRUBY_OPTS Extra options (eg '--1.9') passed to hbase.
54 # HBASE_SHELL_OPTS Extra options passed to the hbase shell.
58 bin
=`cd "$bin">/dev/null; pwd`
60 read -d '' options_string
<< EOF
62 --config DIR Configuration direction to use. Default: ./conf
63 --hosts HOSTS Override the list in 'regionservers' file
64 --auth-as-server Authenticate to ZooKeeper using servers configuration
65 --internal-classpath Skip attempting to use client facing jars (WARNING: unstable results between versions)
66 --help or -h Print this help message
69 echo "Usage: hbase [<options>] <command> [<args>]"
70 echo "$options_string"
73 echo "Some commands take arguments. Pass no args or -h for usage."
74 echo " shell Run the HBase shell"
75 echo " hbck Run the HBase 'fsck' tool. Defaults read-only hbck1."
76 echo " Pass '-j /path/to/HBCK2.jar' to run hbase-2.x HBCK2."
77 echo " snapshot Tool for managing snapshots"
78 if [ "${in_omnibus_tarball}" = "true" ]; then
79 echo " wal Write-ahead-log analyzer"
80 echo " hfile Store file analyzer"
81 echo " zkcli Run the ZooKeeper shell"
82 echo " master Run an HBase HMaster node"
83 echo " regionserver Run an HBase HRegionServer node"
84 echo " zookeeper Run a ZooKeeper server"
85 echo " rest Run an HBase REST server"
86 echo " thrift Run the HBase Thrift server"
87 echo " thrift2 Run the HBase Thrift2 server"
88 echo " clean Run the HBase clean up script"
90 echo " classpath Dump hbase CLASSPATH"
91 echo " mapredcp Dump CLASSPATH entries required by mapreduce"
92 echo " pe Run PerformanceEvaluation"
93 echo " ltt Run LoadTestTool"
94 echo " canary Run the Canary tool"
95 echo " version Print the version"
96 echo " completebulkload Run BulkLoadHFiles tool"
97 echo " regionsplitter Run RegionSplitter tool"
98 echo " rowcounter Run RowCounter tool"
99 echo " cellcounter Run CellCounter tool"
100 echo " pre-upgrade Run Pre-Upgrade validator tool"
101 echo " hbtop Run HBTop tool"
102 echo " CLASSNAME Run the class named CLASSNAME"
105 if [ "--help" = "$1" ] ||
[ "-h" = "$1" ]; then
110 # This will set HBASE_HOME, etc.
111 .
"$bin"/hbase-config.sh
115 CYGWIN
*) cygwin
=true
;;
118 # Detect if we are in hbase sources dir
120 if [ -d "${HBASE_HOME}/target" ]; then
124 # Detect if we are in the omnibus tarball
125 in_omnibus_tarball
="false"
126 if [ -f "${HBASE_HOME}/bin/hbase-daemons.sh" ]; then
127 in_omnibus_tarball
="true"
130 # if no args specified, show usage
140 JAVA
=$JAVA_HOME/bin
/java
142 # override default settings for this command, if applicable
143 if [ -f "$HBASE_HOME/conf/hbase-env-$COMMAND.sh" ]; then
144 .
"$HBASE_HOME/conf/hbase-env-$COMMAND.sh"
147 # establish a default value for HBASE_OPTS if it's not already set. For now,
148 # all we set is the garbage collector.
149 if [ -z "${HBASE_OPTS}" ] ; then
150 major_version_number
="$(parse_java_major_version "$
(read_java_version
)")"
151 case "$major_version_number" in
153 HBASE_OPTS
="-XX:+UseConcMarkSweepGC"
156 HBASE_OPTS
="-XX:+UseG1GC"
163 # add an 'm' suffix if the argument is missing one, otherwise use whats there
165 local lastchar
=${val: -1}
166 if [[ "mMgG" == *$lastchar* ]]; then
173 if [[ -n "$HBASE_HEAPSIZE" ]]; then
174 JAVA_HEAP_MAX
="-Xmx$(add_size_suffix $HBASE_HEAPSIZE)"
177 if [[ -n "$HBASE_OFFHEAPSIZE" ]]; then
178 JAVA_OFFHEAP_MAX
="-XX:MaxDirectMemorySize=$(add_size_suffix $HBASE_OFFHEAPSIZE)"
181 # so that filenames w/ spaces are handled correctly in loops below
185 # CLASSPATH initially contains $HBASE_CONF_DIR
186 CLASSPATH
="${HBASE_CONF_DIR}"
187 CLASSPATH
=${CLASSPATH}:$JAVA_HOME/lib
/tools.jar
189 add_to_cp_if_exists
() {
191 CLASSPATH
=${CLASSPATH}:"$@"
195 # For releases, add hbase & webapps to CLASSPATH
196 # Webapps must come first else it messes up Jetty
197 if [ -d "$HBASE_HOME/hbase-webapps" ]; then
198 add_to_cp_if_exists
"${HBASE_HOME}"
200 #add if we are in a dev environment
201 if [ -d "$HBASE_HOME/hbase-server/target/hbase-webapps" ]; then
202 if [ "$COMMAND" = "thrift" ] ; then
203 add_to_cp_if_exists
"${HBASE_HOME}/hbase-thrift/target"
204 elif [ "$COMMAND" = "thrift2" ] ; then
205 add_to_cp_if_exists
"${HBASE_HOME}/hbase-thrift/target"
206 elif [ "$COMMAND" = "rest" ] ; then
207 add_to_cp_if_exists
"${HBASE_HOME}/hbase-rest/target"
209 add_to_cp_if_exists
"${HBASE_HOME}/hbase-server/target"
210 # Needed for GetJavaProperty check below
211 add_to_cp_if_exists
"${HBASE_HOME}/hbase-server/target/classes"
215 #If avail, add Hadoop to the CLASSPATH and to the JAVA_LIBRARY_PATH
216 # Allow this functionality to be disabled
217 if [ "$HBASE_DISABLE_HADOOP_CLASSPATH_LOOKUP" != "true" ] ; then
218 HADOOP_IN_PATH
=$
(PATH
="${HADOOP_HOME:-${HADOOP_PREFIX}}/bin:$PATH" which hadoop
2>/dev
/null
)
221 # Add libs to CLASSPATH
224 if [ "${INTERNAL_CLASSPATH}" != "true" ]; then
225 # find our shaded jars
226 declare shaded_client
227 declare shaded_client_byo_hadoop
228 declare shaded_mapreduce
229 for f
in "${HBASE_HOME}"/lib
/shaded-clients
/hbase-shaded-client
*.jar
; do
230 if [[ "${f}" =~ byo-hadoop
]]; then
231 shaded_client_byo_hadoop
="${f}"
236 for f
in "${HBASE_HOME}"/lib
/shaded-clients
/hbase-shaded-mapreduce
*.jar
; do
237 shaded_mapreduce
="${f}"
240 # If command can use our shaded client, use it
241 declare -a commands_in_client_jar
=("classpath" "version" "hbtop")
242 for c
in "${commands_in_client_jar[@]}"; do
243 if [ "${COMMAND}" = "${c}" ]; then
244 if [ -n "${HADOOP_IN_PATH}" ] && [ -f "${HADOOP_IN_PATH}" ]; then
245 # If we didn't find a jar above, this will just be blank and the
246 # check below will then default back to the internal classpath.
247 shaded_jar
="${shaded_client_byo_hadoop}"
249 # If we didn't find a jar above, this will just be blank and the
250 # check below will then default back to the internal classpath.
251 shaded_jar
="${shaded_client}"
257 # If command needs our shaded mapreduce, use it
258 # N.B "mapredcp" is not included here because in the shaded case it skips our built classpath
259 declare -a commands_in_mr_jar
=("hbck" "snapshot" "regionsplitter" "pre-upgrade")
260 for c
in "${commands_in_mr_jar[@]}"; do
261 if [ "${COMMAND}" = "${c}" ]; then
262 # If we didn't find a jar above, this will just be blank and the
263 # check below will then default back to the internal classpath.
264 shaded_jar
="${shaded_mapreduce}"
269 # Some commands specifically only can use shaded mapreduce when we'll get a full hadoop classpath at runtime
270 if [ -n "${HADOOP_IN_PATH}" ] && [ -f "${HADOOP_IN_PATH}" ]; then
271 declare -a commands_in_mr_need_hadoop
=("backup" "restore" "rowcounter" "cellcounter")
272 for c
in "${commands_in_mr_need_hadoop[@]}"; do
273 if [ "${COMMAND}" = "${c}" ]; then
274 # If we didn't find a jar above, this will just be blank and the
275 # check below will then default back to the internal classpath.
276 shaded_jar
="${shaded_mapreduce}"
284 if [ -n "${shaded_jar}" ] && [ -f "${shaded_jar}" ]; then
285 CLASSPATH
="${CLASSPATH}:${shaded_jar}"
286 # fall through to grabbing all the lib jars and hope we're in the omnibus tarball
288 # N.B. shell specifically can't rely on the shaded artifacts because RSGroups is only
289 # available as non-shaded
291 # N.B. pe and ltt can't easily rely on shaded artifacts because they live in hbase-mapreduce:test-jar
292 # and need some other jars that haven't been relocated. Currently enumerating that list
293 # is too hard to be worth it.
296 for f
in $HBASE_HOME/lib
/*.jar
; do
297 CLASSPATH
=${CLASSPATH}:$f;
299 # make it easier to check for shaded/not later on.
302 for f
in "${HBASE_HOME}"/lib
/client-facing-thirdparty
/*.jar
; do
303 if [[ ! "${f}" =~ ^.
*/htrace-core-3.
*\.jar$
]] && \
304 [ "${f}" != "htrace-core.jar$" ] && \
305 [[ ! "${f}" =~ ^.
*/slf4j-log4j.
*$
]]; then
306 CLASSPATH
="${CLASSPATH}:${f}"
309 # redirect java.util.logging to slf4j
310 HBASE_OPTS
="$HBASE_OPTS -Djava.util.logging.config.class=org.apache.hadoop.hbase.logging.JulToSlf4jInitializer"
312 # default log directory & file
313 if [ "$HBASE_LOG_DIR" = "" ]; then
314 HBASE_LOG_DIR
="$HBASE_HOME/logs"
316 if [ "$HBASE_LOGFILE" = "" ]; then
317 HBASE_LOGFILE
='hbase.log'
320 function append_path
() {
330 # if HBASE_LIBRARY_PATH is defined lets use it as first or second option
331 if [ "$HBASE_LIBRARY_PATH" != "" ]; then
332 JAVA_LIBRARY_PATH
=$
(append_path
"$JAVA_LIBRARY_PATH" "$HBASE_LIBRARY_PATH")
335 #If configured and available, add Hadoop to the CLASSPATH and to the JAVA_LIBRARY_PATH
336 if [ -n "${HADOOP_IN_PATH}" ] && [ -f "${HADOOP_IN_PATH}" ]; then
337 # If built hbase, temporarily add hbase-server*.jar to classpath for GetJavaProperty
338 # Exclude hbase-server*-tests.jar
340 for f
in "${HBASE_HOME}"/lib
/hbase-server
*.jar
; do
341 if [[ ! "${f}" =~ ^.
*\
-tests\.jar$
]]; then
345 HADOOP_JAVA_LIBRARY_PATH
=$
(HADOOP_CLASSPATH
="$CLASSPATH${temporary_cp}" "${HADOOP_IN_PATH}" \
346 org.apache.hadoop.hbase.util.GetJavaProperty java.library.path
)
347 if [ -n "$HADOOP_JAVA_LIBRARY_PATH" ]; then
348 JAVA_LIBRARY_PATH
=$
(append_path
"${JAVA_LIBRARY_PATH}" "$HADOOP_JAVA_LIBRARY_PATH")
350 CLASSPATH
=$
(append_path
"${CLASSPATH}" "$(${HADOOP_IN_PATH} classpath 2>/dev/null)")
352 # Otherwise, if we're providing Hadoop we should include htrace 3 if we were built with a version that needs it.
353 for f
in "${HBASE_HOME}"/lib
/client-facing-thirdparty
/htrace-core-3
*.jar
"${HBASE_HOME}"/lib
/client-facing-thirdparty
/htrace-core.jar
; do
354 if [ -f "${f}" ]; then
355 CLASSPATH
="${CLASSPATH}:${f}"
359 # Some commands require special handling when using shaded jars. For these cases, we rely on hbase-shaded-mapreduce
360 # instead of hbase-shaded-client* because we make use of some IA.Private classes that aren't in the latter. However,
361 # we don't invoke them using the "hadoop jar" command so we need to ensure there are some Hadoop classes available
362 # when we're not doing runtime hadoop classpath lookup.
364 # luckily the set of classes we need are those packaged in the shaded-client.
365 for c
in "${commands_in_mr_jar[@]}"; do
366 if [ "${COMMAND}" = "${c}" ] && [ -n "${shaded_jar}" ]; then
367 CLASSPATH
="${CLASSPATH}:${shaded_client:?We couldn\'t find the shaded client jar even though we did find the shaded MR jar. for command ${COMMAND} we need both. please use --internal-classpath as a workaround.}"
373 # Add user-specified CLASSPATH last
374 if [ "$HBASE_CLASSPATH" != "" ]; then
375 CLASSPATH
=${CLASSPATH}:${HBASE_CLASSPATH}
378 # Add user-specified CLASSPATH prefix first
379 if [ "$HBASE_CLASSPATH_PREFIX" != "" ]; then
380 CLASSPATH
=${HBASE_CLASSPATH_PREFIX}:${CLASSPATH}
383 # cygwin path translation
385 CLASSPATH
=`cygpath -p -w "$CLASSPATH"`
386 HBASE_HOME
=`cygpath -d "$HBASE_HOME"`
387 HBASE_LOG_DIR
=`cygpath -d "$HBASE_LOG_DIR"`
390 if [ -d "${HBASE_HOME}/build/native" -o -d "${HBASE_HOME}/lib/native" ]; then
391 if [ -z $JAVA_PLATFORM ]; then
392 JAVA_PLATFORM
=`CLASSPATH=${CLASSPATH} ${JAVA} org.apache.hadoop.util.PlatformName | sed -e "s/ /_/g"`
394 if [ -d "$HBASE_HOME/build/native" ]; then
395 JAVA_LIBRARY_PATH
=$
(append_path
"$JAVA_LIBRARY_PATH" "${HBASE_HOME}/build/native/${JAVA_PLATFORM}/lib")
398 if [ -d "${HBASE_HOME}/lib/native" ]; then
399 JAVA_LIBRARY_PATH
=$
(append_path
"$JAVA_LIBRARY_PATH" "${HBASE_HOME}/lib/native/${JAVA_PLATFORM}")
403 # cygwin path translation
405 JAVA_LIBRARY_PATH
=`cygpath -p "$JAVA_LIBRARY_PATH"`
408 # restore ordinary behaviour
411 #Set the right GC options based on the what we are running
412 declare -a server_cmds
=("master" "regionserver" "thrift" "thrift2" "rest" "avro" "zookeeper")
413 for cmd
in ${server_cmds[@]}; do
414 if [[ $cmd == $COMMAND ]]; then
420 if [[ $server ]]; then
421 HBASE_OPTS
="$HBASE_OPTS $SERVER_GC_OPTS"
423 HBASE_OPTS
="$HBASE_OPTS $CLIENT_GC_OPTS"
426 if [ "$AUTH_AS_SERVER" == "true" ] ||
[ "$COMMAND" = "hbck" ]; then
427 if [ -n "$HBASE_SERVER_JAAS_OPTS" ]; then
428 HBASE_OPTS
="$HBASE_OPTS $HBASE_SERVER_JAAS_OPTS"
430 HBASE_OPTS
="$HBASE_OPTS $HBASE_REGIONSERVER_OPTS"
434 # check if the command needs jline
435 declare -a jline_cmds
=("zkcli" "org.apache.hadoop.hbase.zookeeper.ZKMainServer")
436 for cmd
in "${jline_cmds[@]}"; do
437 if [[ $cmd == "$COMMAND" ]]; then
444 # (1) for the commands which need jruby (see jruby_cmds defined below)
445 # A. when JRUBY_HOME is specified explicitly, eg. export JRUBY_HOME=/usr/local/share/jruby
446 # CLASSPATH and HBASE_OPTS are updated according to JRUBY_HOME specified
447 # B. when JRUBY_HOME is not specified explicitly
448 # add jruby packaged with HBase to CLASSPATH
449 # (2) for other commands, do nothing
451 # check if the commmand needs jruby
452 declare -a jruby_cmds
=("shell" "org.jruby.Main")
453 for cmd
in "${jruby_cmds[@]}"; do
454 if [[ $cmd == "$COMMAND" ]]; then
460 add_maven_deps_to_classpath
() {
461 f
="${HBASE_HOME}/hbase-build-configuration/target/$1"
463 if [ ! -f "${f}" ]; then
464 echo "As this is a development environment, we need ${f} to be generated from maven (command: mvn install -DskipTests)"
467 CLASSPATH
=${CLASSPATH}:$
(cat "${f}")
470 add_jdk11_deps_to_classpath
() {
471 for f
in ${HBASE_HOME}/lib
/jdk11
/*; do
472 if [ -f "${f}" ]; then
473 CLASSPATH
="${CLASSPATH}:${f}"
478 #Add the development env class path stuff
480 add_maven_deps_to_classpath
"cached_classpath.txt"
482 if [[ $jline_needed ]]; then
483 add_maven_deps_to_classpath
"cached_classpath_jline.txt"
484 elif [[ $jruby_needed ]]; then
485 add_maven_deps_to_classpath
"cached_classpath_jruby.txt"
489 # the command needs jruby
490 if [[ $jruby_needed ]]; then
491 if [ "$JRUBY_HOME" != "" ]; then # JRUBY_HOME is specified explicitly, eg. export JRUBY_HOME=/usr/local/share/jruby
492 # add jruby.jar into CLASSPATH
493 CLASSPATH
="$JRUBY_HOME/lib/jruby.jar:$CLASSPATH"
495 # add jruby to HBASE_OPTS
496 HBASE_OPTS
="$HBASE_OPTS -Djruby.home=$JRUBY_HOME -Djruby.lib=$JRUBY_HOME/lib"
498 else # JRUBY_HOME is not specified explicitly
499 if ! $in_dev_env; then # not in dev environment
500 # add jruby packaged with HBase to CLASSPATH
501 JRUBY_PACKAGED_WITH_HBASE
="$HBASE_HOME/lib/ruby/*.jar"
502 for jruby_jar
in $JRUBY_PACKAGED_WITH_HBASE; do
503 CLASSPATH
=$jruby_jar:$CLASSPATH;
509 # figure out which class to run
510 if [ "$COMMAND" = "shell" ] ; then
511 #find the hbase ruby sources
512 # assume we are in a binary install if lib/ruby exists
513 if [ -d "$HBASE_HOME/lib/ruby" ]; then
514 # We want jruby to consume these things rather than our bootstrap script;
515 # jruby will look for the env variable 'JRUBY_OPTS'.
516 JRUBY_OPTS
="${JRUBY_OPTS} -X+O"
518 # hbase-shell.jar contains a 'jar-bootstrap.rb'
520 # https://github.com/jruby/jruby/wiki/StandaloneJarsAndClasses#standalone-executable-jar-files
521 CLASS
="org.jruby.JarBootstrapMain"
522 # otherwise assume we are running in a source checkout
524 HBASE_OPTS
="$HBASE_OPTS -Dhbase.ruby.sources=$HBASE_HOME/hbase-shell/src/main/ruby"
525 CLASS
="org.jruby.Main -X+O ${JRUBY_OPTS} ${HBASE_HOME}/hbase-shell/src/main/ruby/jar-bootstrap.rb"
527 HBASE_OPTS
="$HBASE_OPTS $HBASE_SHELL_OPTS"
528 elif [ "$COMMAND" = "hbck" ] ; then
529 # Look for the -j /path/to/HBCK2.jar parameter. Else pass through to hbck.
532 # Found -j parameter. Add arg to CLASSPATH and set CLASS to HBCK2.
535 if [ ! -f "${JAR}" ]; then
536 echo "${JAR} file not found!"
537 echo "Usage: hbase [<options>] hbck -jar /path/to/HBCK2.jar [<args>]"
540 CLASSPATH
="${JAR}:${CLASSPATH}";
541 CLASS
="org.apache.hbase.HBCK2"
542 shift # past argument=value
545 CLASS
='org.apache.hadoop.hbase.util.HBaseFsck'
548 elif [ "$COMMAND" = "wal" ] ; then
549 CLASS
='org.apache.hadoop.hbase.wal.WALPrettyPrinter'
550 elif [ "$COMMAND" = "hfile" ] ; then
551 CLASS
='org.apache.hadoop.hbase.io.hfile.HFilePrettyPrinter'
552 elif [ "$COMMAND" = "zkcli" ] ; then
553 CLASS
="org.apache.hadoop.hbase.zookeeper.ZKMainServer"
554 for f
in $HBASE_HOME/lib
/zkcli
/*.jar
; do
555 CLASSPATH
="${CLASSPATH}:$f";
557 elif [ "$COMMAND" = "upgrade" ] ; then
558 echo "This command was used to upgrade to HBase 0.96, it was removed in HBase 2.0.0."
559 echo "Please follow the documentation at http://hbase.apache.org/book.html#upgrading."
561 elif [ "$COMMAND" = "snapshot" ] ; then
564 if [ "$SUBCOMMAND" = "create" ] ; then
565 CLASS
="org.apache.hadoop.hbase.snapshot.CreateSnapshot"
566 elif [ "$SUBCOMMAND" = "info" ] ; then
567 CLASS
="org.apache.hadoop.hbase.snapshot.SnapshotInfo"
568 elif [ "$SUBCOMMAND" = "export" ] ; then
569 CLASS
="org.apache.hadoop.hbase.snapshot.ExportSnapshot"
571 echo "Usage: hbase [<options>] snapshot <subcommand> [<args>]"
572 echo "$options_string"
575 echo " create Create a new snapshot of a table"
576 echo " info Tool for dumping snapshot information"
577 echo " export Export an existing snapshot"
580 elif [ "$COMMAND" = "master" ] ; then
581 CLASS
='org.apache.hadoop.hbase.master.HMaster'
582 if [ "$1" != "stop" ] && [ "$1" != "clear" ] ; then
583 HBASE_OPTS
="$HBASE_OPTS $HBASE_MASTER_OPTS"
585 elif [ "$COMMAND" = "regionserver" ] ; then
586 CLASS
='org.apache.hadoop.hbase.regionserver.HRegionServer'
587 if [ "$1" != "stop" ] ; then
588 HBASE_OPTS
="$HBASE_OPTS $HBASE_REGIONSERVER_OPTS"
590 elif [ "$COMMAND" = "thrift" ] ; then
591 CLASS
='org.apache.hadoop.hbase.thrift.ThriftServer'
592 if [ "$1" != "stop" ] ; then
593 HBASE_OPTS
="$HBASE_OPTS $HBASE_THRIFT_OPTS"
595 elif [ "$COMMAND" = "thrift2" ] ; then
596 CLASS
='org.apache.hadoop.hbase.thrift2.ThriftServer'
597 if [ "$1" != "stop" ] ; then
598 HBASE_OPTS
="$HBASE_OPTS $HBASE_THRIFT_OPTS"
600 elif [ "$COMMAND" = "rest" ] ; then
601 CLASS
='org.apache.hadoop.hbase.rest.RESTServer'
602 if [ "$1" != "stop" ] ; then
603 HBASE_OPTS
="$HBASE_OPTS $HBASE_REST_OPTS"
605 elif [ "$COMMAND" = "zookeeper" ] ; then
606 CLASS
='org.apache.hadoop.hbase.zookeeper.HQuorumPeer'
607 if [ "$1" != "stop" ] ; then
608 HBASE_OPTS
="$HBASE_OPTS $HBASE_ZOOKEEPER_OPTS"
610 elif [ "$COMMAND" = "clean" ] ; then
612 --cleanZk|
--cleanHdfs|
--cleanAll)
616 if [ $# -ne 1 -o "$matches" = "" ]; then
617 echo "Usage: hbase clean (--cleanZk|--cleanHdfs|--cleanAll)"
619 echo " --cleanZk cleans hbase related data from zookeeper."
620 echo " --cleanHdfs cleans hbase related data from hdfs."
621 echo " --cleanAll cleans hbase related data from both zookeeper and hdfs."
624 "$bin"/hbase-cleanup.sh
--config ${HBASE_CONF_DIR} $@
626 elif [ "$COMMAND" = "mapredcp" ] ; then
627 # If we didn't find a jar above, this will just be blank and the
628 # check below will then default back to the internal classpath.
629 shaded_jar
="${shaded_mapreduce}"
630 if [ "${INTERNAL_CLASSPATH}" != "true" ] && [ -f "${shaded_jar}" ]; then
631 echo -n "${shaded_jar}"
632 for f
in "${HBASE_HOME}"/lib
/client-facing-thirdparty
/*.jar
; do
633 if [[ ! "${f}" =~ ^.
*/htrace-core-3.
*\.jar$
]] && \
634 [ "${f}" != "htrace-core.jar$" ] && \
635 [[ ! "${f}" =~ ^.
*/slf4j-log4j.
*$
]]; then
642 CLASS
='org.apache.hadoop.hbase.util.MapreduceDependencyClasspathTool'
643 elif [ "$COMMAND" = "classpath" ] ; then
646 elif [ "$COMMAND" = "pe" ] ; then
647 CLASS
='org.apache.hadoop.hbase.PerformanceEvaluation'
648 HBASE_OPTS
="$HBASE_OPTS $HBASE_PE_OPTS"
649 elif [ "$COMMAND" = "ltt" ] ; then
650 CLASS
='org.apache.hadoop.hbase.util.LoadTestTool'
651 HBASE_OPTS
="$HBASE_OPTS $HBASE_LTT_OPTS"
652 elif [ "$COMMAND" = "canary" ] ; then
653 CLASS
='org.apache.hadoop.hbase.tool.CanaryTool'
654 HBASE_OPTS
="$HBASE_OPTS $HBASE_CANARY_OPTS"
655 elif [ "$COMMAND" = "version" ] ; then
656 CLASS
='org.apache.hadoop.hbase.util.VersionInfo'
657 elif [ "$COMMAND" = "regionsplitter" ] ; then
658 CLASS
='org.apache.hadoop.hbase.util.RegionSplitter'
659 elif [ "$COMMAND" = "rowcounter" ] ; then
660 CLASS
='org.apache.hadoop.hbase.mapreduce.RowCounter'
661 elif [ "$COMMAND" = "cellcounter" ] ; then
662 CLASS
='org.apache.hadoop.hbase.mapreduce.CellCounter'
663 elif [ "$COMMAND" = "pre-upgrade" ] ; then
664 CLASS
='org.apache.hadoop.hbase.tool.PreUpgradeValidator'
665 elif [ "$COMMAND" = "completebulkload" ] ; then
666 CLASS
='org.apache.hadoop.hbase.tool.BulkLoadHFilesTool'
667 elif [ "$COMMAND" = "hbtop" ] ; then
668 CLASS
='org.apache.hadoop.hbase.hbtop.HBTop'
669 if [ -n "${shaded_jar}" ] ; then
670 for f
in "${HBASE_HOME}"/lib
/hbase-hbtop
*.jar
; do
671 if [ -f "${f}" ]; then
672 CLASSPATH
="${CLASSPATH}:${f}"
676 for f
in "${HBASE_HOME}"/lib
/commons-lang3
*.jar
; do
677 if [ -f "${f}" ]; then
678 CLASSPATH
="${CLASSPATH}:${f}"
684 if [ -f "${HBASE_HOME}/conf/log4j-hbtop.properties" ] ; then
685 HBASE_HBTOP_OPTS
="${HBASE_HBTOP_OPTS} -Dlog4j.configuration=file:${HBASE_HOME}/conf/log4j-hbtop.properties"
687 HBASE_OPTS
="${HBASE_OPTS} ${HBASE_HBTOP_OPTS}"
692 # Add lib/jdk11 jars to the classpath
694 if [ "${DEBUG}" = "true" ]; then
695 echo "Deciding on addition of lib/jdk11 jars to the classpath"
700 if [ "${HBASE_JDK11}" != "" ]; then
701 # Use the passed Environment Variable HBASE_JDK11
702 if [ "${HBASE_JDK11}" = "include" ]; then
704 if [ "${DEBUG}" = "true" ]; then
705 echo "HBASE_JDK11 set as 'include' hence adding JDK11 jars to classpath."
707 elif [ "${HBASE_JDK11}" = "exclude" ]; then
708 if [ "${DEBUG}" = "true" ]; then
709 echo "HBASE_JDK11 set as 'exclude' hence skipping JDK11 jars to classpath."
712 echo "[HBASE_JDK11] contains unsupported value(s) - ${HBASE_JDK11}. Ignoring passed value."
713 echo "[HBASE_JDK11] supported values: [include, exclude]."
717 version
="$(read_java_version)"
718 major_version_number
="$(parse_java_major_version "$version")"
720 if [ "${DEBUG}" = "true" ]; then
721 echo "HBASE_JDK11 not set hence using JDK detection."
722 echo "Extracted JDK version - ${version}, major_version_number - ${major_version_number}"
725 if [[ "$major_version_number" -ge "11" ]]; then
726 if [ "${DEBUG}" = "true" ]; then
727 echo "Version ${version} is greater-than/equal to 11 hence adding JDK11 jars to classpath."
730 elif [ "${DEBUG}" = "true" ]; then
731 echo "Version ${version} is lesser than 11 hence skipping JDK11 jars from classpath."
735 if [ "${addJDK11Jars}" = "true" ]; then
736 add_jdk11_deps_to_classpath
737 if [ "${DEBUG}" = "true" ]; then
738 echo "Added JDK11 jars to classpath."
740 elif [ "${DEBUG}" = "true" ]; then
741 echo "JDK11 jars skipped from classpath."
744 # Have JVM dump heap if we run out of memory. Files will be 'launch directory'
745 # and are named like the following: java_pid21612.hprof. Apparently it doesn't
746 # 'cost' to have this flag enabled. Its a 1.6 flag only. See:
747 # http://blogs.sun.com/alanb/entry/outofmemoryerror_looks_a_bit_better
748 HBASE_OPTS
="$HBASE_OPTS -Dhbase.log.dir=$HBASE_LOG_DIR"
749 HBASE_OPTS
="$HBASE_OPTS -Dhbase.log.file=$HBASE_LOGFILE"
750 HBASE_OPTS
="$HBASE_OPTS -Dhbase.home.dir=$HBASE_HOME"
751 HBASE_OPTS
="$HBASE_OPTS -Dhbase.id.str=$HBASE_IDENT_STRING"
752 HBASE_OPTS
="$HBASE_OPTS -Dhbase.root.logger=${HBASE_ROOT_LOGGER:-INFO,console}"
753 if [ "x$JAVA_LIBRARY_PATH" != "x" ]; then
754 HBASE_OPTS
="$HBASE_OPTS -Djava.library.path=$JAVA_LIBRARY_PATH"
755 export LD_LIBRARY_PATH
="$LD_LIBRARY_PATH:$JAVA_LIBRARY_PATH"
758 # Enable security logging on the master and regionserver only
759 if [ "$COMMAND" = "master" ] ||
[ "$COMMAND" = "regionserver" ]; then
760 HBASE_OPTS
="$HBASE_OPTS -Dhbase.security.logger=${HBASE_SECURITY_LOGGER:-INFO,RFAS}"
762 HBASE_OPTS
="$HBASE_OPTS -Dhbase.security.logger=${HBASE_SECURITY_LOGGER:-INFO,NullAppender}"
765 HEAP_SETTINGS
="$JAVA_HEAP_MAX $JAVA_OFFHEAP_MAX"
766 # by now if we're running a command it means we need logging
767 for f
in ${HBASE_HOME}/lib
/client-facing-thirdparty
/slf4j-log4j
*.jar
; do
768 if [ -f "${f}" ]; then
769 CLASSPATH
="${CLASSPATH}:${f}"
774 # Exec unless HBASE_NOEXEC is set.
776 if [ "${DEBUG}" = "true" ]; then
777 echo "classpath=${CLASSPATH}" >&2
778 HBASE_OPTS
="${HBASE_OPTS} -Xdiag"
781 if [ "${HBASE_NOEXEC}" != "" ]; then
782 "$JAVA" -Dproc_$COMMAND -XX:OnOutOfMemoryError
="kill -9 %p" $HEAP_SETTINGS $HBASE_OPTS $CLASS "$@"
785 exec "$JAVA" -Dproc_$COMMAND -XX:OnOutOfMemoryError
="kill -9 %p" $HEAP_SETTINGS $HBASE_OPTS $CLASS "$@"