Hadoop生态圈-phoenix(HBase)的索引配置
作者:尹正杰
版权声明:原创作品,谢绝转载!否则将追究法律责任。
创建索引是为了优化查询,我们可以在phoenix上配置索引方式。
一.修改hbase配置文件,以便支持索引
1>.xrsync.sh 脚本内容
1 [yinzhengjie@s101 ~]$ more `which xrsync.sh` 2 #!/bin/bash 3 #@author :yinzhengjie 4 #blog:http://www.cnblogs.com/yinzhengjie 5 #EMAIL:y1053419035@qq.com 6 7 #判断用户是否传参 8 if [ $# -lt 1 ];then 9 echo "请输入参数";10 exit11 fi12 13 14 #获取文件路径15 file=$@16 17 #获取子路径18 filename=`basename $file`19 20 #获取父路径21 dirpath=`dirname $file`22 23 #获取完整路径24 cd $dirpath25 fullpath=`pwd -P`26 27 #同步文件到DataNode28 for (( i=102;i<=105;i++ ))29 do30 #使终端变绿色 31 tput setaf 232 echo =========== s$i %file ===========33 #使终端变回原来的颜色,即白灰色34 tput setaf 735 #远程执行命令36 rsync -lr $filename `whoami`@s$i:$fullpath37 #判断命令是否执行成功38 if [ $? == 0 ];then39 echo "命令执行成功"40 fi41 done42 [yinzhengjie@s101 ~]$
2>.修改hbase配置文件,以便支持索引
3>.重启hbase
[yinzhengjie@s101 ~]$ stop-hbase.sh stopping hbase..................[yinzhengjie@s101 ~]$ start-hbase.sh starting master, logging to /soft/hbase/bin/../logs/hbase-yinzhengjie-master-s101.outJava HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0s102: starting regionserver, logging to /soft/hbase/bin/../logs/hbase-yinzhengjie-regionserver-s102.outs103: starting regionserver, logging to /soft/hbase/bin/../logs/hbase-yinzhengjie-regionserver-s103.outs104: starting regionserver, logging to /soft/hbase/bin/../logs/hbase-yinzhengjie-regionserver-s104.outs102: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0s102: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0s103: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0s103: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0s104: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0s104: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0[yinzhengjie@s101 ~]$
二.设置索引方式
注意:创建表的时候,如果需要创建索引,表必须在hbase默认namespace中。
1>.创建表
2>.全局索引(读多写少,局限在于影响写入性能,但是可以搜索全字段)
2>.覆盖索引(局限性在于只能搜索到name,即搜索name性能最高)
3>.本地索引(写多读少,在于通过本地维护索引,索引在每次搜索,都会用到)
4>.删除索引