From 004899dae9e5f9c0d6e65dc29a8716bf31c1f02b Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Wed, 24 Oct 2018 11:32:22 -0700 Subject: [PATCH] HBASE-21215 Figure how to invoke hbck2; make it easy to find Adds option parameter to the bin/hbase hbck command that allows passing the hbck2 jar. Signed-off-by: Sean Busbey --- bin/hbase | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/bin/hbase b/bin/hbase index 7fe61b40eb..bac829d546 100755 --- a/bin/hbase +++ b/bin/hbase @@ -92,7 +92,8 @@ if [ $# = 0 ]; then 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" + echo " hbck Run the HBase 'fsck' tool. Defaults read-only hbck1." + echo " Pass --jar=/path/to/HBCK2.jar to run hbase-2.x HBCK2." echo " snapshot Tool for managing snapshots" if [ "${in_omnibus_tarball}" = "true" ]; then echo " wal Write-ahead-log analyzer" @@ -480,7 +481,25 @@ if [ "$COMMAND" = "shell" ] ; then HBASE_OPTS="$HBASE_OPTS $HBASE_SHELL_OPTS" CLASS="org.jruby.Main -X+O ${JRUBY_OPTS} ${HBASE_HOME}/bin/hirb.rb" elif [ "$COMMAND" = "hbck" ] ; then - CLASS='org.apache.hadoop.hbase.util.HBaseFsck' + # Look for the --jar=/path/to/HBCK2.jar parameter. Else pass through to hbck. + case "${1}" in + --jar*) + # Found --jar parameter. Add it to CLASSPATH and set CLASS to HBCK2. + JAR="${1#*=}" + JAR="${JAR/#\~/$HOME}" + if [ ! -f "${JAR}" ]; then + echo "${JAR} file not found!" + echo "Usage: hbase [] hbck --jar=/path/to/HBCK2.jar []" + exit 1 + fi + CLASSPATH="${JAR}:${CLASSPATH}"; + CLASS="org.apache.hbase.HBCK2" + shift # past argument=value + ;; + *) + CLASS='org.apache.hadoop.hbase.util.HBaseFsck' + ;; + esac elif [ "$COMMAND" = "wal" ] ; then CLASS='org.apache.hadoop.hbase.wal.WALPrettyPrinter' elif [ "$COMMAND" = "hfile" ] ; then -- 2.16.3