|
有时候需要绕过HBase直接访问HFile,比如健康检查,dump文件内容。HFile.main()提供了一些工具来完成这些事情:- $
- ./bin/hbase org.apache.hadoop.hbase.io.hfile.HFile
- usage: HFile [-a] [-b] [-e] [-f <arg>] [-k] [-m] [-p] [-r <arg>] [-v]
- -a,--checkfamily Enable family check
- -b,--printblocks Print block index meta data
- -e,--printkey Print keys
- -f,--file <arg> File to scan. Pass full-path; e.g.
- hdfs://a:9000/hbase/.META./12/34
- -k,--checkrow Enable row order check; looks for out-of-order keys
- -m,--printmeta Print meta data of file
- -p,--printkv Print key/value pairs
- -r,--region <arg> Region to scan. Pass region name; e.g. '.META.,,1'
- -v,--verbose Verbose output; emits file and meta data delimiters
复制代码 Here is an example of what the output will look like (shortened):- $
- ./bin/hbase org.apache.hadoop.hbase.io.hfile.HFile -f \
- /hbase/testtable/de27e14ffc1f3fff65ce424fcf14ae42/colfam1/2518469459313898451 \
- -v -m -p
- Scanning -> /hbase/testtable/de27e14ffc1f3fff65ce424fcf14ae42/colfam1/2518469459313898451
- K: row-550/colfam1:50/1309813948188/Put/vlen=2 V: 50
- K: row-550/colfam1:50/1309812287166/Put/vlen=2 V: 50
- K: row-551/colfam1:51/1309813948222/Put/vlen=2 V: 51
- K: row-551/colfam1:51/1309812287200/Put/vlen=2 V: 51
- K: row-552/colfam1:52/1309813948256/Put/vlen=2 V: 52
- ...
- K: row-698/colfam1:98/1309813953680/Put/vlen=2 V: 98
- K: row-698/colfam1:98/1309812292594/Put/vlen=2 V: 98
- K: row-699/colfam1:99/1309813953720/Put/vlen=2 V: 99
- K: row-699/colfam1:99/1309812292635/Put/vlen=2 V: 99
- Scanned kv count -> 300
- Block index size as per heapsize: 208
- reader=/hbase/testtable/de27e14ffc1f3fff65ce424fcf14ae42/colfam1/ \
- 2518469459313898451, compression=none, inMemory=false, \
- firstKey=row-550/colfam1:50/1309813948188/Put, \
- lastKey=row-699/colfam1:99/1309812292635/Put, avgKeyLen=28, avgValueLen=2, \
- entries=300, length=11773
- fileinfoOffset=11408, dataIndexOffset=11664, dataIndexCount=1, \
- metaIndexOffset=0, metaIndexCount=0, totalBytes=11408, entryCount=300, \
- version=1
- Fileinfo:
- MAJOR_COMPACTION_KEY = \xFF
- MAX_SEQ_ID_KEY = 2020
- TIMERANGE = 1309812287166....1309813953720
- hfile.AVG_KEY_LEN = 28
- hfile.AVG_VALUE_LEN = 2
- hfile.COMPARATOR = org.apache.hadoop.hbase.KeyValue$KeyComparator
- hfile.LASTKEY = \x00\x07row-699\x07colfam199\x00\x00\x010\xF6\xE5|\x1B\x04
- Could not get bloom data from meta block
复制代码 |
|