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

Posted

技术标签:

【中文标题】Hbase 元数据错误“找不到表”【英文标题】:Hbase metadata error "tables no found" 【发布时间】:2014-12-29 07:14:56 【问题描述】:

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

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

【问题讨论】:

在您提到的第二台机器上是独立设置吗?如果是,那么简单地复制到 hdfs 只会更新 hdfs 元数据条目。对于 Hbase,您需要创建一个表并将数据导入其中。 【参考方案1】:

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


    HBase 复制表工具

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

    HBase 导出/导入工具

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>

    使用快照

推荐用于 HBase 0.94.6+。您可以在这里找到所有信息:http://hbase.apache.org/book/ops.snapshots.html

【讨论】:

【参考方案2】:

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

bin/hbase hbck -repairHoles

但请记住,如果您使用此方法进行 hbase 表备份,则可能会出现某些数据不一致的情况。

【讨论】:

以上是关于Hbase 元数据错误“找不到表”的主要内容,如果未能解决你的问题,请参考以下文章

项目部署操作linux数据库mysql出现表找不到

在CentOS7上面部署项目,报出找不到表的错误

从 EMR 迁移到 AWS Glue 后在 Spark SQL 中找不到表

Hibernate、Spring 和 HSQL:找不到表异常

水晶报表 Crystal Report 调用存储过程时出错 找不到表 ,解决方法。

php/mysql:在手机上找不到表