HBase集群数据迁移方案

一、静态迁移方案

1、在hbase停止的状态下进行数据的迁移。

2、采用Hadoop distcp方式,将以上目录的内容,迁移到另一个集群。
使用add_table.rb进行恢复。

缺点:不太灵活

二、动态迁移方案

-Replication备份方案
-CopyTable方案
-Export and Import方案

1.Replication备份方案

修改hbase-site.xml配置,增加hbase.replication属性,
增加表属性REPLICATION_SCOPE属性。
add_peer增加一个从集群。

2.CopyTable方案

命令:

./hbase org.apache.hadoop.hbase.mapreduce.CopyTable --peer.adr=new cluster ip:2181:/hbase_table
package org.apache.hadoop.hbase.mapreduce;
/**
 * Tool used to copy a table to another one which can be on a different setup.
 * It is also configurable with a start and time as well as a specification
 * of the region server implementation if different from the local cluster.
 */
public class CopyTable extends Configured implements Tool {
    ...
}

说明:
1、拷贝完成,不需要重启机器,在new cluster中就可以看到该表。
2、稳定性还需要考虑。

3.Export and Import方案

步骤:
(1)在old cluster上执行:

./hbase org.apache.hadoop.hbase.mapreduce.Export test  hdfs://new cluster ip:9000/xxx
/**
* Export an HBase table.
* Writes content to sequence files up in HDFS.  Use {@link Import} to read it
* back in again.
*/
public class Export {
    ...
}

(2)在new cluster上执行:

./hbase org.apache.hadoop.hbase.mapreduce.Import test hdfs://new cluster ip:9000/xxx
package org.apache.hadoop.hbase.mapreduce;
/**
 * Import data written by {@link Export}.
 */
public class Import {
    ...
}

说明:
1、一定要写绝对路径,不能写相对路径。
2、在import前,需要将表事先在new cluster中创建好。

三、手动方式

1、从源HBase集群中复制出HBase数据库表到本地目录。

[root@hadoop1 temp]# hadoop fs -get src desc

2、目标HBase导入

[root@hadoop1 temp]# hadoop fs -put  src desc

3、修复.META.

[root@hadoop1 temp]# hbase hbck -fixMeta

查看该表的meta数据:
hbase(main):001:0> scan 'hbase:meta'

4、重新分配数据到各RegionServer

[root@hadoop1 temp]# hbase hbck -fixAssignments

优势:
比较灵活,安全(因为不是执行程序的,而是用命令)。

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

吃果冻不吐果冻皮

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值