Hbase元数据错误“找不到表”

时间:2014-12-29 07:14:57

标签: apache hadoop hbase hdfs

我在hbase(hdfs)表中有一些数据,然后将其复制到我的本地文件系统。然后在我的第二台机器上,我使用copyFromLocal hadoop命令将数据从本地复制到hdfs。现在我在hbase中运行命令“list”(在第二台机器上)。这表明没有桌子。我将表复制到hdfs的目录中,该目录是hbase的数据目录,因此该表应该出现在hbase中。

问题出在哪里?在这两台机器上,hbase和hadoop的版本是相同的。如何将hbase表从一个集群复制到第二个集群?

2 个答案:

答案 0 :(得分:1)

有一些工具可用于管理此类任务(所有这些都记录在此:http://hbase.apache.org/book/ops_mgt.html)。


  1. HBase copyTable工具
  2. http://hbase.apache.org/book/ops_mgt.html#copytable

    $ ./bin/hbase org.apache.hadoop.hbase.mapreduce.CopyTable --help        
    /bin/hbase org.apache.hadoop.hbase.mapreduce.CopyTable --help
    Usage: CopyTable [general options] [--starttime=X] [--endtime=Y] [--new.name=NEW] [--peer.adr=ADR] <tablename>
    
    Options:
     rs.class     hbase.regionserver.class of the peer cluster, 
                  specify if different from current cluster
     rs.impl      hbase.regionserver.impl of the peer cluster,
     startrow     the start row
     stoprow      the stop row
     starttime    beginning of the time range (unixtime in millis)
                  without endtime means from starttime to forever
     endtime      end of the time range.  Ignored if no starttime specified.
     versions     number of cell versions to copy
     new.name     new table's name
     peer.adr     Address of the peer cluster given in the format
                  hbase.zookeeer.quorum:hbase.zookeeper.client.port:zookeeper.znode.parent
     families     comma-separated list of families to copy
                  To copy from cf1 to cf2, give sourceCfName:destCfName.
                  To keep the same name, just give "cfName"
     all.cells    also copy delete markers and deleted cells
    
    Args:
     tablename    Name of the table to copy
    
    Examples:
     To copy 'TestTable' to a cluster that uses replication for a 1 hour window:
     $ bin/hbase org.apache.hadoop.hbase.mapreduce.CopyTable --starttime=1265875194289 --endtime=1265878794289 --peer.adr=server1,server2,server3:2181:/hbase --families=myOldCf:myNewCf,cf2,cf3 TestTable
    

    1. HBase导出/导入工具
    2. http://hbase.apache.org/book/ops_mgt.html#export

      http://hbase.apache.org/book/ops_mgt.html#import

      a)导出数据

      $ bin/hbase org.apache.hadoop.hbase.mapreduce.Export <tablename> <outputdir> [<versions> [<starttime> [<endtime>]]]
      

      b)将数据scp到远程机器

      c)导入数据

      $ bin/hbase org.apache.hadoop.hbase.mapreduce.Import <tablename> <inputdir>
      

      1. 使用快照
      2. 推荐用于HBase 0.94.6+。您可以在此处找到所有信息:http://hbase.apache.org/book/ops.snapshots.html

答案 1 :(得分:0)

我必须添加一些信息。如果使用hadoop命令而不是hbase命令复制表,则运行follwoing命令。(假设版本相同)。基本上数据是在hdfs中但没有信息in.meta文件。所以下面将完成这项工作。

bin / hbase hbck -repairHoles

但请记住,如果您将此方法用于hbase表备份,则可能存在某些数据可能不一致的情况。