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 exit 11 fi 12 13 14 #获取文件路径 15 file=$@ 16 17 #获取子路径 18 filename=`basename $file` 19 20 #获取父路径 21 dirpath=`dirname $file` 22 23 #获取完整路径 24 cd $dirpath 25 fullpath=`pwd -P` 26 27 #同步文件到DataNode 28 for (( i=102;i<=105;i++ )) 29 do 30 #使终端变绿色 31 tput setaf 2 32 echo =========== s$i %file =========== 33 #使终端变回原来的颜色,即白灰色 34 tput setaf 7 35 #远程执行命令 36 rsync -lr $filename `whoami`@s$i:$fullpath 37 #判断命令是否执行成功 38 if [ $? == 0 ];then 39 echo "命令执行成功" 40 fi 41 done 42 [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.out Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0 Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0 s102: starting regionserver, logging to /soft/hbase/bin/../logs/hbase-yinzhengjie-regionserver-s102.out s103: starting regionserver, logging to /soft/hbase/bin/../logs/hbase-yinzhengjie-regionserver-s103.out s104: starting regionserver, logging to /soft/hbase/bin/../logs/hbase-yinzhengjie-regionserver-s104.out s102: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0 s102: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0 s103: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0 s103: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0 s104: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0 s104: 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>.删除索引