hbase 二级索引实现 hbase 二级索引实现

hbase 二级索引实现

问题导读
1.如何建立全局二级索引?
2.如何对一个表建立二级索引?

3.如何卸载二级索引?

环境:hadoop2.2+hbase0.94不过同样应该适用于hadoop2.4及hbase0.985,未测试
二级索引可以对单个表建立索引,也可以全局建立索引,也就是对所有表:

1.全局建立索引,可以修改hbase-site.xml文件

[html]  view plain  copy
  1. <property>   
  2. <name>hbase.coprocessor.region.classes</name>   
  3. <value>org.apache.hadoop.hbase.coprocessor.AggregateImplementation</value>  
  4. </property> 为所有table加载了一个cp class,可以用”,”分割加载多个class  

2.单个表建立索引
步骤:
1.首先disable ‘表名’
2.然后修改表

[html]  view plain  copy
  1. alter 'LogTable', METHOD => 'table_att_unset', NAME => 'coprocessor$1‘  
3.enable '表名'
3.卸载索引

[html]  view plain  copy
  1. alter 'LogTable', METHOD => 'table_att_unset', NAME => 'coprocessor$1‘  

4.建立索引实例:

建立二级索引,首先如下程序:

[html]  view plain  copy
  1. alter 'LogTable',METHOD=>'table_att','coprocessor'=>'hdfs:///test.jar|www.aboutyun.com.hbase.HbaseCoprocessor|1001'  

 


查看是否创建成功
 


HBaseCoprocessor pdf



转载http://www.aboutyun.com/forum.php?mod=viewthread&tid=8857&highlight=hbase%2B%B6%FE%BC%B6

猜你喜欢

转载自blog.csdn.net/wangshuminjava/article/details/80579852