hbase的replication使用

hbase-0.90.0的一个重要改进是引入了replication机制,使它的数据完整性得到了进一步的保障。虽然这一功能还不太完善,但是今后必然会变得更加重要。

hbase的replication机制很像mysql statement-based replication。它是通过WALEdit和hlog来实现的。当请求发送给master cluster时,hlog日志放入hdfs的同时进入replication队列,由slave cluster通过zookeeper获取并写入slave的表中。目前的版本仅支持一个slave cluster

[img]http://dl.iteye.com/upload/attachment/452914/c954c59a-ad2f-336f-aebf-a3319ac63489.png[/img]

具体配置如下:
1 需要保证主从cluster上有相同的table,并且结构一致,都enable
2 保证主从cluster的版本都在0.90.0以上
3 主从cluster的机器是两两互通的
4 master cluster的hbase-site.xml中需要添加以下选项:
<property>
<name>hbase.replication</name>
<value>true</value>
</property>

5 进入master cluster的shell,执行:
add_peer '1', "slave-zk-1,slave-zk-2,...:slave-2181:/slave-zk-parent"
6 开启要复制的family,进入hbase shell,执行:
    disable 'your_table'
alter 'your_table', {NAME => 'family_name', REPLICATION_SCOPE => '1'}
enable 'your_table'

此时replication己经开始了
7 要中止或继续replication,使用stop_replication或start_replication

在复制过程中,可以通过查看regionserver的日志来跟踪复制的进度:
Considering 1 rs, with ratio 0.1
Getting 1 rs from peer cluster # 0
Choosing peer yourip:62020

要检查复制的数据是否完整,可以利用hbase提供的小工具verifyrep:
hbase org.apache.hadoop.hbase.mapreduce.replication.VerifyReplication --starttime=1265875194289 --stoptime=1265878794289 1 TestTable

这里的1是上面的peer_id

更完整的说明见:[url]http://hbase.apache.org/replication.html[/url]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值