Hbase Region 故障修复

834 阅读2分钟

1 背景

近期因为网络故障导致了hbase表出现问题,执行插入语句时报了如下的错误: org.apache.hadoop.hbase.client.RetriesExhaustedWithDetailsException: Failed 1 action: NotServingRegionException 于是翻查了好多资料,以下是操作是成功有效的。

2 先介绍一下Hbase修复工具Hbck

2.1 概述

HBaseFsck(hbck)是一种命令行工具,可检查region一致性和表完整性问题并修复损坏。目前HBCK工具有两个版本,HBCK1和HBCK2。两个版本的HBCK工具在设计上已经发生的非常大的变化,在使用方式上也有比较大的差异,两个版本的工具只能使用在对应的内核版本上,无法混用。hbck1(6.5.1版本及以前)hbck1主要用于在hbase1.x版本进行检查or修复。

2.2 HBCK一致性

一致性是指Region在meta中的meta表信息、在线Regionserver的Region信息和hdfs的Regioninfo的Region信息的一致。

2.3 Hbck 一致性的检查和修复命令

一致性检查命令

hbase hbck <-details> <表名>

一致性修复

hbase hbck <-fixMeta> ,<-fixAssignments> <表名>

命令详解

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

主要以hdfs为准进行修复,hdfs存在则添加到meta中,不存在删除meta对应region。

-fixAssignments:Try to fix region assignments.  Replaces the old -fix

不同情况,动作不一样,包括下线、关闭和重新上线

3 操作命令

当发现[HBASE]的某张表无法正常访问,或scan时发现故障或业务端发现问题, 后检查hbase(以product表为例)

[hadoop@hadoop112 ~]$ hbase hbck -details product

结果重要部分如下:

Summary:
Table product is okay.
    Number of regions: 0
    Deployed on: 
Table hbase:meta is okay.
    Number of regions: 1
    Deployed on:  hadoop113,16020,1565925904060
0 inconsistencies detected.

尝试修复:

1.先禁用表
[hadoop@hadoop112 logs]$ hbase shell
hbase(main):007:0> disable 'product'
 
2.使用修复命令
[hadoop@hadoop112 logs]$ hbase hbck -fixMeta
 
3.重启启用表
[hadoop@hadoop112 logs]$ hbase shell
hbase(main):007:0> enable 'product'

然后再检查HBase:

[hadoop@hadoop112 ~]$ hbase hbck -details product

运行结果如下:

Summary:
2019-08-16 11:46:53,299 INFO  [main-EventThread] zookeeper.ClientCnxn: EventThread shut down
Table product is okay.
    Number of regions: 1
    Deployed on:  hadoop113,16020,1565925904060
Table hbase:meta is okay.
    Number of regions: 1
    Deployed on:  hadoop113,16020,1565925904060
0 inconsistencies detected.
Status: OK

恭喜你,至此就大功告成了