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源码:

  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. this.cache.put(tableName, state);

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

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

重启HBase集群。

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

三、hbck

  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. -repair           Shortcut for -fixAssignments -fixMeta -fixHdfsHoles -fixHdfsOrphans -fixHdfsOverlaps -fixVersionFile -sidelineBigOverlaps
  22. -repairHoles      Shortcut for -fixAssignments -fixMeta -fixHdfsHoles -fixHdfsOrphans

[转]HBase hbck——检察HBase集群的一致性的更多相关文章

  1. HBase HA的分布式集群部署(适合3、5节点)

    本博文的主要内容有: .HBase的分布模式(3.5节点)安装    .HBase的分布模式(3.5节点)的启动 .HBase HA的分布式集群的安装 .HBase HA的分布式集群的启动    .H ...

  2. HBase的多节点集群详细启动步骤(3或5节点)(分为Zookeeper自带还是外装)

    HBase的多节点集群详细启动步骤(3或5节点)分为: 1.HBASE_MANAGES_ZK的默认值是false(zookeeper外装)(推荐) 2.HBASE_MANAGES_ZK的默认值是tru ...

  3. HBase 2.1.3 集群 web 报错InvalidProtocolBufferException 解决方法

    搭建好HBase 集群后,各种后台进程都正常,搭建手册参考: Hbase 2.1.3 集群搭建手册https://www.cndba.cn/dave/article/3322 但是通过web访问,却报 ...

  4. HBase+Phoenix整合入门--集群搭建

    环境:CentOS 6.6 64位    hbase 1.1.15  phoenix-4.7.0-HBase-1.1 一.前置环境: 已经安装配置好Hadoop 2.6和jdk 1.7 二.安装hba ...

  5. hbase 0.98.1集群安装

    本文将基于hbase 0.98.1解说其在linux集群上的安装方法,并对一些重要的设置项进行解释,本文原文链接:http://blog.csdn.net/bluishglc/article/deta ...

  6. YCSB测试HBase远程完全分布式集群

    写在前面 本文只讲一个很简单的问题,YCSB对HBase集群的测试.虽然网上有很多介绍YCSB测试HBase的文章,但都是针对本地HBase伪分布式集群的.大家都知道,稍微正式一些的压测都会要求测试客 ...

  7. HBase体系架构和集群安装

    大家好,今天分享的是HBase体系架构和HBase集群安装.承接上两篇文章<HBase简介>和<HBase数据模型>,点击回顾这2篇文章,有助于更好地理解本文. 一.HBase ...

  8. HBase混布MapReduce集群学习记录

    一.准备工作 1.1 部署环境 集群规模大概260多台,TSC10机型,机型参数如下: > 1个8核CPU(E5-2620v4) > 64G内存 > HBA,12*4T SATA,1 ...

  9. HBase的单节点集群详细启动步骤(分为Zookeeper自带还是外装)

    伪分布模式下,如(weekend110)hbase-env.sh配置文档中的HBASE_MANAGES_ZK的默认值是true,它表示HBase使用自身自带的Zookeeper实例.但是,该实例只能为 ...

随机推荐

  1. 目标跟踪之卡尔曼滤波---理解Kalman滤波的使用

    http://www.cnblogs.com/jcchen1987/p/4371439.html

  2. CH Round #54 - Streaming #5 (NOIP模拟赛Day1)(被虐瞎)

    http://ch.ezoj.tk/contest/CH%20Round%20%2354%20-%20Streaming%20%235%20%28NOIP%E6%A8%A1%E6%8B%9F%E8%B ...

  3. ubuntu 自动清理/tmp目录

    在Ubuntu系统中,在/tmp文件夹里面的内容,每次开机都会被清空,如果不想让他自动清理的话,只需要更改rcS文件中的TMPTIME的值. 我们看如何来修改 sudo vi /etc/default ...

  4. Android多线程分析之中的一个:使用Thread异步下载图像

    Android多线程分析之中的一个:使用Thread异步下载图像 罗朝辉 (http://blog.csdn.net/kesalin) CC 许可.转载请注明出处 打算整理一下对 Android Fr ...

  5. iOS7中弹簧式列表的制作

    本文转载至 http://www.devdiv.com/forum.php?mod=viewthread&tid=208170&extra=page%3D1%26filter%3Dty ...

  6. AndroidManifest.xml文件详解(activity)(一)

    <activity android:allowTaskReparenting=["true" | "false"] android:alwaysRetai ...

  7. script跨域之360搜索

    思考: 布局: 1,flex元素上下左右居中,内部元素横向排列: div{ /* 100vh = viewport height*/ display: flex; justify-content: c ...

  8. Codevs (3657括号序列 )

    题目链接:传送门 题目大意:中文题,略 题目思路:区间DP 这个题是问需要添加多少个括号使之成为合法括号序列,那么我们可以先求有多少合法的括号匹配,然后用字符串长度减去匹配的括号数就行 状态转移方程主 ...

  9. <pre>标签让<textarea>标签的内容原样输出

    当通过<textarea>插数据进数据的库,取出来后都变成一行变成,用这个<pre>标签能原样输入插入时的格式. 当时要对<pre>加一些CSS样式才行啦. 以下为 ...

  10. iOS 百度地图获取当前地理位置

    // // ViewController.m // BaiDuDemo // // Created by Chocolate. on 15-3-2. // Copyright (c) 2015年 re ...