HBase 应用平台 Replication 效能
一、稳定性测试
二、功能扩展
1.ReplicationAdmin
org.apache.hadoop.hbase.client.replication.ReplicationAdmin
This class provides the administrative interface to HBase cluster replication.
2.表启用复制,范围是表级别。
主从集群需要同时启用或禁用
2.1.原因
主集群挂了,表的描述信息就无法获取,从集群恢复时就不知道哪些表已经启用,所以需要同时启用,保证两个集群一致;
从集群有很多个表(100以上)需要启用,启用处理时间就会很长,从而影响从集群恢复启动时间。
2.2.参考
/hbase-0.94.6-cdh4.3.2/bin/replication/copy_tables_desc.rb
Script to recreate all tables from one cluster to another.To see usage for this script, run:
${HBASE_HOME}/bin/hbase org.jruby.Main copy_tables_desc.rb
2.3.实现
2.3.1.HBase Shell
enable_table_replication/disable_table_replication
新增
ReplicationHTableDescriptor
/hbase/src/main/ruby/shell/commands/enable_table_replication.rb
/hbase/src/main/ruby/shell/commands/disable_table_replication.rb
修改
ReplicationAdmin
/hbase/src/main/ruby/hbase/replication_admin.rb(编译后的目录/hbase-0.94.6-cdh4.3.2/lib/ruby/hbase/replication_admin.rb)
/hbase/src/main/ruby/shell.rb
源码
见附件。
2.3.2.OM
列出所有表;
增加“启用表复制”和“禁用表复制”按钮。
三、判断主从集群数据一致性
复制数据是否完全同步?
从两种情况分开考虑:离线offline和在线online。
1.检查复制的数据是否完整verifyrep(离线)
hbase org.apache.hadoop.hbase.mapreduce.replication.VerifyReplication --starttime=1265875194289 --stoptime=1265878794289 1 TestTable
2.实时监控复制进展和状态(在线)
复制指标Metrics
以下的一些有用的度量指标,可以用来检查复制的进展:
source.sizeOfLogQueue:处理HLogs数(不包括一个正在处理的)在复制源
source.shippedOps:被运的突变数
source.logEditsRead:读HLogs突变数在复制源
source.ageOfLastShippedOp:通过复制源被运的最后一批的年龄
请注意,上述指标是在global水平在这RegionServer。在0.95.0起,这些指标也是暴露在每个peer的水平。
根据应用需要,扩展一些新的复制指标。
四、手动切换
1.域名、多IP(类似于Zookeeper)
2.主从集群角色互换,配置主从集群切换
维护peers和启用复制的tables
主集群:删除peers和禁用复制的tables
从集群:新增peers和启用复制的tables
五、只读权限控制
信任列表
只读集群列表;
RPC扩展,拦截请求,进行信任处理,控制只读权限。
六、参考资料
1.HBase Replication
1.hbase的replication使用
2.Hbase Replication 介绍