HBase二级索引之异步方式
1.创建索引表
create index my_index on cn_population(population) include(province,city) async;
2.激活索引
hbase org.apache.phoenix.mapreduce.index.IndexTool --schema mydb --data-table cn_population --index-table my_index --output-path /data
注意点:若是执行IndexTool的话,就需要phoenix-5.0.0-HBase-2.0-client.jar包
因为是client,所以不能在有HMaster进程上面的集群节点上操作。
所以:上面一步需要在无HMaster进程上进行操作
3.拷贝jar包
phoenix-5.0.0-HBase-2.0-client.jar
只需要将这个jar包拷贝至需要执行IndexTool的虚拟机的hbase安装目录下的lib目录就行
然后,执行激活索引的指令
hbase org.apache.phoenix.mapreduce.index.IndexTool --schema mydb --data-table cn_population --index-table my_index --output-path /data
4.确认
在phoenix客户端,便可以进行查询索引表
5.弊端
执行操偶做的虚拟机会掉一个HRegionServer的进程,只需要再将hbase目录下的lib目录的jar删除即可。