zoukankan      html  css  js  c++  java
  • [转]HBase hbck——检察HBase集群的一致性

     Hbase提供了hbck命令来检查各种不一致问题。hbck的名字仿效了HDFS的fsck命令,后者是一个用于检查HDFS中不一致问题的工具。下面这段非常易懂的介绍出自于hbck的源程序。

           检查数据在Master及RegionServer的内存中状态与数据在HDFS中的状态之间的一致性。

           HBase的hbck不仅能够检查不一致问题,而且还能够修复不一致问题。

           在生产环境中,应当经常运行hbck,以便及早发现不一致问题并更容易地解决问题。

    一、问题

           首先,在HBase上创建一张表usertable。

           然后,在HDFS上直接删除usertable表的目录/hbase/usertable来删除表的数据(错误的做法)。

    二、解决方法

           1.hbase hbck

                  Status:OK,表示没有发现不一致问题。

                  Status:INCONSISTENT,表示有不一致问题。

           2.hbase hbck -fixAssignments

                  Try to fix region assignments.  Replaces the old -fix

                  [zk: 192.168.147.15:2181(CONNECTED) 3] ls /hbase/unassigned

           3.hbase hbck -fixMeta

                  Try to fix meta problems.  This assumes HDFS region info is good.

                  hbase(main):007:0>  scan '.META.'

           4.hbase(main):015:0> create 'usertable','f1'

                  ERROR: Table already exists: usertable!

                  

                  [zk: 192.168.147.15:2181(CONNECTED) 4] ls /hbase/table

                  [usertable]

                  [zk: 192.168.147.15:2181(CONNECTED) 5] get /hbase/table/usertable

                  ENABLING

                  [zk: 192.168.147.15:2181(CONNECTED) 6] rmr /hbase/table/usertable

                  [zk: 192.168.147.15:2181(CONNECTED) 7] get /hbase/table/usertable

                  Node does not exist: /hbase/table/usertable

                  

                  此时,create 'usertable','f1',依然提示同样的错误。

                  查看ZKTable源码:

    [java] view plain copy
     
     在CODE上查看代码片派生到我的代码片
    1. /** 
    2.  * Cache of what we found in zookeeper so we don't have to go to zk ensemble 
    3.  * for every query.  Synchronize access rather than use concurrent Map because 
    4.  * synchronization needs to span query of zk. 
    5.  */  
    6. private final Map<String, TableState> cache =  
    7.   new HashMap<String, TableState>();  
    8.   
    9.  this.cache.put(tableName, state);  

                  把ZK中的数据缓存在本地内存中,以加速访问,减少访问时间。

                  为了让本地内存中的数据失效,必须重启HBase集群。

                  

                  重启HBase集群。

                  此时,create 'usertable','f1',没有提示错误,表创建成功。

    三、hbck

    [java] view plain copy
     
     在CODE上查看代码片派生到我的代码片
    1. [bigdata@tbe192168147015 ~]$ hbase hbck -h  
    2. Usage: fsck [opts] {only tables}  
    3.  where [opts] are:  
    4.    -help Display help options (this)  
    5.    -details Display full report of all regions.  
    6.    -timelag {timeInSeconds}  Process only regions that  have not experienced any metadata updates in the last  {{timeInSeconds} seconds.  
    7.    -sleepBeforeRerun {timeInSeconds} Sleep this many seconds before checking if the fix worked if run with -fix  
    8.    -summary Print only summary of the tables and status.  
    9.    -metaonly Only check the state of ROOT and META tables.  
    10.   Repair options: (expert features, use with caution!)  
    11.    -fix              Try to fix region assignments.  This is for backwards compatiblity  
    12.    -fixAssignments   Try to fix region assignments.  Replaces the old -fix  
    13.    -fixMeta          Try to fix meta problems.  This assumes HDFS region info is good.  
    14.    -fixHdfsHoles     Try to fix region holes in hdfs.  
    15.    -fixHdfsOrphans   Try to fix region dirs with no .regioninfo file in hdfs  
    16.    -fixHdfsOverlaps  Try to fix region overlaps in hdfs.  
    17.    -fixVersionFile   Try to fix missing hbase.version file in hdfs.  
    18.    -maxMerge <n>     When fixing region overlaps, allow at most <n> regions to merge. (n=5 by default)  
    19.    -sidelineBigOverlaps  When fixing region overlaps, allow to sideline big overlaps  
    20.    -maxOverlapsToSideline <n>  When fixing region overlaps, allow at most <n> regions to sideline per group. (n=2 by default)  
    21.   
    22.    -repair           Shortcut for -fixAssignments -fixMeta -fixHdfsHoles -fixHdfsOrphans -fixHdfsOverlaps -fixVersionFile -sidelineBigOverlaps  
    23.    -repairHoles      Shortcut for -fixAssignments -fixMeta -fixHdfsHoles -fixHdfsOrphans  
  • 相关阅读:
    java spring boot 跳转
    了解什么是 redis 的雪崩、穿透和击穿
    小白学k8s(12)-k8s中PV和PVC理解
    小白学k8s(11)-k8s中Secret理解
    小白学k8s(10)-k8s中ConfigMap理解
    小白学k8s(9)-gitlab-runner实现go项目的自动化发布
    小白学k8s(8)-Bazel部署go应用
    记go中一次http超时引发的事故
    小白学k8s(7)helm[v3]使用了解
    小白学k8s(6)使用kubespray部署k8s
  • 原文地址:https://www.cnblogs.com/jasonHome/p/6873949.html
Copyright © 2011-2022 走看看