`

hbase hbck流程

阅读更多

 

HBaseFsck类的hbase hbck流程;hbck是一个很重的管理工具,他会访问所有rs,扫描整个meta表,以及读取所有table region里的regioninfo,所以不要频繁使用hbck,会给hbase带来压力

 

 /**
   * This repair method requires the cluster to be online since it contacts
   * region servers and the masters.  It makes each region's state in HDFS, in
   * hbase:meta, and deployments consistent.
   *
   * @return If > 0 , number of errors detected, if < 0 there was an unrecoverable
   * error.  If 0, we have a clean hbase.
   */
  public int onlineConsistencyRepair() throws IOException, KeeperException,
    InterruptedException {
    clearState();

    // get regions according to what is online on each RegionServer
    //加载每个regionserver上的region,将regioninfo放入map中,regioninfo中没有metainfo
    loadDeployedRegions();
    // check whether hbase:meta is deployed and online
    //加载meta表的regioninfo,并检查meta表的regioninfo
    recordMetaRegion();
    // Check if hbase:meta is found only once and in the right place
    //检查meta表,有且只有一个region
    if (!checkMetaRegion()) {
      String errorMsg = "hbase:meta table is not consistent. ";
      if (shouldFixAssignments()) {
        errorMsg += "HBCK will try fixing it. Rerun once hbase:meta is back to consistent state.";
      } else {
        errorMsg += "Run HBCK with proper fix options to fix hbase:meta inconsistency.";
      }
      errors.reportError(errorMsg + " Exiting...");
      return -2;
    }
    // Not going with further consistency check for tables when hbase:meta itself is not consistent.
    LOG.info("Loading regionsinfo from the hbase:meta table");
    //扫描meta表,将regioninfo放入map中,添加metainfo信息
    boolean success = loadMetaEntries();
    if (!success) return -1;

    // Empty cells in hbase:meta?
    reportEmptyMetaCells();

    // Check if we have to cleanup empty REGIONINFO_QUALIFIER rows from hbase:meta
    if (shouldFixEmptyMetaCells()) {
      fixEmptyMetaCells();
    }

    // get a list of all tables that have not changed recently.
    if (!checkMetaOnly) {
      reportTablesInFlux();
    }

    // load regiondirs and regioninfos from HDFS
    if (shouldCheckHdfs()) {//唯一一个默认是true的
      loadHdfsRegionDirs();//获得所有hbase table region dir,将regioninfo hbckinfo上添加hdfsentry对象,表示region在hdfs上的信息
      loadHdfsRegionInfos();//获得所有hbase table region hfile,检查region是否存在(meta region存在,hdfs region不存在)
    }

    // Get disabled tables from ZooKeeper
    loadDisabledTables();

    // fix the orphan tables
    fixOrphanTables();

    // Check and fix consistency
    checkAndFixConsistency();//默认流程,检查meta和hdfs上的region丢失

    // Check integrity (does not fix)
    checkIntegrity();//默认流程,检查region漏洞
    return errors.getErrorList().size();
  }

 

分享到:
评论
1 楼 qindongliang1922 2016-02-16  
楼主对hbase的掌握的不错啊, 

相关推荐

Global site tag (gtag.js) - Google Analytics