您的位置:首页 > 运维架构

hbase数据导出导入,数据备份,数据迁移(仅解决非通信集群)

2017-05-11 10:32 567 查看
如题,只说明非通信集群,hbase版本是1.1.10,属于1.1.x系列,跨大版本这个事情另外讨论,参考官网。

面对的环境数据量较大(就是比较小没有几个PB的意思),新老集群无法通信。二步解决,export/import大量坑,在此不表,选用手动方式。

一、导出、导入数据

copyFromLocal

Usage: hadoop fs -copyFromLocal <localsrc> URI

Similar to the fs -put command, except that the source is restricted to a local file reference.

Options:

-p : Preserves access and modification times, ownership and the permissions. (assuming the permissions can be propagated across filesystems)

-f : Overwrites the destination if it already exists.

-l : Allow DataNode to lazily persist the file to disk, Forces a replication factor of 1. This flag will result in reduced durability. Use with care.

-d : Skip creation of temporary file with the suffix ._COPYING_.

copyToLocal

Usage: hadoop fs -copyToLocal [-ignorecrc] [-crc] URI <localdst>

Similar to get command, except that the destination is restricted to a local file reference.

找到你现在的hbase的数据在hdfs的位置

hadoop fs -copyToLocal  /hbase/data/default/表名 存放数据的路径


然后把数据转移到另外一个集群上去

Hadoop fs -copyFromLocal 准备导入的数据文件夹 /hbase/data/default/表名


值得注意的是如果是新集群,可能没有/hbase/data/default/这个文件夹,最好的方式是在hbase中建一个测试表,

查看确认下新的集群的hbase数据信息是否在对应位置。

二、修复数据meta与分区

因为分区信息发生了改变,元信息没有同步。

数据导入到指定的文件夹之后,修复分区和表的元信息,(没有使用rbuy的各种脚本,0.9之后就D了,)

hbase hbck -fixTableOrphans  表名

hbase hbck -fixMeta  表名

hbase hbck -fixAssignments  表名

hbase hbck -repair  表名

list 、scan和get命令,测试数据在新集群中时候可用
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息