hbase中查看hfile文件内容

通过查看hfile可以看到对hbase中一条记录的修改时间点和当时的值,对于查问题比较方便

直接输入 hbase org.apache.hadoop.hbase.io.hfile.HFile 就可以看到该命令的帮助信息

[baoniu@search0001 ~]$ 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

例如hbase中一张表的数据是:

hbase(main):002:0> scan 'student'
ROW                                      COLUMN+CELL                                                                                                         
 1                                       column=address:home, timestamp=1315896762114, value=hubei street                                                    
 1                                       column=address:school, timestamp=1315896782636, value=huaqianbei street                                             
 1                                       column=name:, timestamp=1315896276100, value=steven                                                                 
 1                                       column=phone:, timestamp=1315897926595, value=1398982                                                               
 1                                       column=phone:hangzhou, timestamp=1315898046474, value=1398982                                                       
1 row(s) in 0.1540 seconds

在hadoop上可以看到:

[baoniu@search0001 ~]$ hadoop fs -ls /hbase_baoniu/student/a322a8d7eaf71907c2446e5145481228
Found 5 items
drwxr-xr-x   - baoniu supergroup          0 2011-09-13 14:40 /hbase_baoniu/student/a322a8d7eaf71907c2446e5145481228/.oldlogs
-rw-r--r--   3 baoniu supergroup       1484 2011-09-13 14:40 /hbase_baoniu/student/a322a8d7eaf71907c2446e5145481228/.regioninfo
drwxr-xr-x   - baoniu supergroup          0 2012-02-07 10:19 /hbase_baoniu/student/a322a8d7eaf71907c2446e5145481228/address
drwxr-xr-x   - baoniu supergroup          0 2012-02-07 10:19 /hbase_baoniu/student/a322a8d7eaf71907c2446e5145481228/name
drwxr-xr-x   - baoniu supergroup          0 2012-02-07 10:19 /hbase_baoniu/student/a322a8d7eaf71907c2446e5145481228/phone

查看hfile内容:

[baoniu@search0001 ~]$ hbase org.apache.hadoop.hbase.io.hfile.HFile -f /hbase_baoniu/student/a322a8d7eaf71907c2446e5145481228/name/8716598438049876987 -p  
K: 1/name:/1315896276100/Put/vlen=6 V: steven
K: 1/name:/1315896197360/Put/vlen=9 V: zkb
Scanned kv count -> 2

[baoniu@search041134 ~]$ hbase org.apache.hadoop.hbase.io.hfile.HFile -f /hbase_baoniu/student/a322a8d7eaf71907c2446e5145481228/address/3353620824199902774 -p
K: 1/address:home/1315896762114/Put/vlen=12 V: hubei street
K: 1/address:school/1315896782636/Put/vlen=17 V: huaqianbei street

hbase也提供了查看hlog文件的命令,详见:http://www.rigongyizu.com/hbase-see-hlog-file/

发表评论

电子邮件地址不会被公开。 必填项已用*标注