$ ${HBASE_HOME}/bin/hbase --config /etc/hbase-conf hbck -j ~/hbase-operator-tools/hbase-hbck2/target/hbase-hbck2-1.0.0-SNAPSHOT.jar
usage: HBCK2 [OPTIONS] COMMAND <ARGS>
Options:
-d,--debug run with debug output
-h,--help output this help message
-p,--hbase.zookeeper.property.clientPort <arg> port of hbase ensemble
-q,--hbase.zookeeper.quorum <arg> hbase ensemble
-s,--skip skip hbase version check
(PleaseHoldException)
-v,--version this hbck2 version
-z,--zookeeper.znode.parent <arg> parent znode of hbase ensemble
使用方法
reportMissingRegionsInMeta [<NAMESPACE|NAMESPACE:TABLENAME>...|
-i <INPUT_FILE>...]
Options:
-i,--inputFiles take one or more files of namespace or table names
使用方法
addFsRegionsMissingInMeta [OPTIONS] [<NAMESPACE|NAMESPACE:TABLENAME>...|-i <INPUTFILES>...]
Options:
-i,--inputFiles take one or more files of namespace or table names
-o,--outputFile name/prefix of the file(s) to dump region names
-n,--numLines number of lines to be written to each output file
HBCK2 addFsRegionsMissingInMeta default:tbl_1 n1:tbl_2 n2
HBCK2 addFsRegionsMissingInMeta -i fileName1 fileName2
如果指定-o选项,则该输出文件可以在后续assign命令的-i选项中直接当传入参数使用
使用方法
assigns [OPTIONS] [<ENCODED_REGIONNAME>...|-i <INPUT_FILE>...]
Options:
-o,--override override ownership by another procedure
-i,--inputFiles take one or more files of encoded region names
-b,--batchSize number of regions to process in a batch
使用方法
unassigns [OPTIONS] [<ENCODED_REGIONNAME>...|-i <INPUT_FILE>...]
Options:
-o,--override override ownership by another procedure
-i,--inputFiles take one or more input files of encoded region names
-b,--batchSize number of regions to process in a batch
使用方法
extraRegionsInMeta [<NAMESPACE|NAMESPACE:TABLENAME>...|
-i <INPUT_FILE>...]
Options:
-f, --fix fix meta by removing all extra regions found.
-i,--inputFiles take one or more input files of namespace or
table names
使用方法
filesystem [OPTIONS] [<TABLENAME>...|-i <INPUT_FILE>...]
Options:
-f, --fix sideline corrupt hfiles, bad links, and references.
-i,--inputFiles take one or more input files of table names
设置region状态。修改成功则返回0,失败则返回1。
典型场景:因为region在hbase:meta表中状态不一致,导致无法unassigns或者assigns。但比如 region只有在SPLITTING|SPLIT|MERGING|OPEN|CLOSING状态才可以unassigns。
注意:
1.该操作为高危操作,作为最后手段使用。
2.在执行命令之前,确保regon没有其他正在运行的procedure,如assign、split等。可以通过list_procedure命令查看。
region的状态有OFFLINE, OPENING, OPEN, CLOSING, CLOSED, SPLITTING, SPLIT,
FAILED_OPEN, FAILED_CLOSE, MERGING, MERGED, SPLITTING_NEW,
MERGING_NEW, ABNORMALLY_CLOSED
使用方法
setRegionState [<ENCODED_REGIONNAME> <STATE>|-i <INPUT_FILE>...]
Options:
-i,--inputFiles take one or more input files of encoded region names
and states.
setTableState [<TABLENAME> <STATE>|-i <INPUT_FILE>...]
Options:
-i,--inputFiles take one or more files of table names and states
使用方法
bypass [OPTIONS] [<PID>...|-i <INPUT_FILE>...]
Options:
-o,--override override if procedure is running/stuck
-r,--recursive bypass parent and its children. SLOW! EXPENSIVE!
-w,--lockWait milliseconds to wait before giving up; default=1
-i,--inputFiles take one or more input files of PID's
-b,--batchSize number of procedures to process in a batch
使用方法
generateMissingTableDescriptorFile [OPTIONS] [<TABLENAME>...]
regionInfoMismatch
Options:
-f,--fix Update hbase:meta with the corrections
使用方法
replication [OPTIONS] [<TABLENAME>...|-i <INPUT_FILE>...]
Options:
-f, --fix fix any replication issues found.
-i,--inputFiles take one or more input files of table names
使用方法
scheduleRecoveries [<SERVERNAME>...|-i <INPUT_FILE>...]
Options:
-i,--inputFiles take one or more input files of server names
Master负责所有region的分配,regionserver的崩溃处理,集群启停。所有这些都是以Procedures的形式在状态机上运行。每个Procedure都有Procedure id,即pid。通过pid可以在日志中跟踪所有的过程。
比如以下就是一个stuck procedure的例子
2018-09-12 15:29:06,558 WARN org.apache.hadoop.hbase.master.assignment.AssignmentManager: STUCK Region-In-Transition rit=OPENING, location=va1001.example.org,22101,1536173230599, table=IntegrationTestBigLinkedList_20180626110336, region=dbdb56242f17610c46ea044f7a42895b
$ echo "list_locks"| hbase shell &> /tmp/locks.txt
$ echo "list_procedures"| hbase shell &> /tmp/procedures.txt