hbase集群之间数据迁移_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_table11

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

2

3

4

5

6

7

8

91

2

3

4

5

6

7

8

9

说明:

1、拷贝完成,不需要重启机器,在new cluster中就可以看到该表。

2、稳定性还需要考虑。

3.Export and Import方案

步骤:

(1)在old cluster上执行:

./hbase org.apache.hadoop.hbase.mapreduce.Export test hdfs://new cluster ip:9000/xxx11

/**

* Export an HBase table.

* Writes content to sequence files up in HDFS. Use {@link Import} to read it

* back in again.

*/

public class Export {

...

}1

2

3

4

5

6

7

81

2

3

4

5

6

7

8

(2)在new cluster上执行:

./hbase org.apache.hadoop.hbase.mapreduce.Import test hdfs://new cluster ip:9000/xxx11

package org.apache.hadoop.hbase.mapreduce;

/**

* Import data written by {@link Export}.

*/

public class Import {

...

}1

2

3

4

5

6

71

2

3

4

5

6

7

说明:

1、一定要写绝对路径,不能写相对路径。

2、在import前,需要将表事先在new cluster中创建好。

三、手动方式

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

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

2、目标HBase导入

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

3、修复.META.表

[root@hadoop1 temp]# hbase hbck -fixMeta

查看该表的meta数据:

hbase(main):001:0> scan 'hbase:meta'1

2

3

41

2

3

4

4、重新分配数据到各RegionServer

[root@hadoop1 temp]# hbase hbck -fixAssignments11

优势:

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值