Hadoop生态圈-phoenix完全分布式部署
作者:尹正杰
版权声明:原创作品,谢绝转载!否则将追究法律责任。
phoenix只是一个插件,我们可以用hive给hbase套上一个JDBC壳,但是你有没有体会到Hive执行SQL语句是很慢的,因此我们采用phoenix插件的方式给hbase套上JDBC的壳。
一.Phoenix简介
1>.其实Phoenix可以看成是在hbase的hive,它是使用SQL方式访问HBase数据;
2>.内置多种协处理器实现,轻松实现二级索引和聚合查询;
二.部署phoenix
1>.下载phoenix插件
下载地址:http://www.apache.org/dyn/closer.lua/phoenix/
2>.解压
[yinzhengjie@s101 data]$ tar zxf apache-phoenix-4.10.0-HBase-1.2-bin.tar.gz -C /soft/ [yinzhengjie@s101 data]$
3>.创建软连接
[yinzhengjie@s101 data]$ ln -s /soft/apache-phoenix-4.10.0-HBase-1.2-bin/ /soft/phoenix [yinzhengjie@s101 data]$
4>.配置环境变量并使之生效
[yinzhengjie@s101 data]$ sudo vi /etc/profile [sudo] password for yinzhengjie: [yinzhengjie@s101 data]$ [yinzhengjie@s101 data]$ tail -3 /etc/profile #ADD PHOENIX PHOENIX_HOME=/soft/phoenix PATH=$PATH:$PHOENIX_HOME/bin [yinzhengjie@s101 data]$ [yinzhengjie@s101 data]$ source /etc/profile [yinzhengjie@s101 data]$
5>.将phoenix类库放置在hbase的lib目录,分发,并重启hbase
[yinzhengjie@s101 ~]$ cp /soft/phoenix/phoenix-4.10.0-HBase-1.2-client.jar /soft/hbase/lib/ [yinzhengjie@s101 ~]$ xrsync.sh /soft/hbase/lib/phoenix-4.10.0-HBase-1.2-client.jar =========== s102 %file =========== 命令执行成功 =========== s103 %file =========== 命令执行成功 =========== s104 %file =========== 命令执行成功 =========== s105 %file =========== 命令执行成功 [yinzhengjie@s101 ~]$ more `which xrsync.sh` #!/bin/bash #@author :yinzhengjie #blog:http://www.cnblogs.com/yinzhengjie #EMAIL:y1053419035@qq.com #判断用户是否传参 if [ $# -lt 1 ];then echo "请输入参数"; exit fi #获取文件路径 file=$@ #获取子路径 filename=`basename $file` #获取父路径 dirpath=`dirname $file` #获取完整路径 cd $dirpath fullpath=`pwd -P` #同步文件到DataNode for (( i=102;i<=105;i++ )) do #使终端变绿色 tput setaf 2 echo =========== s$i %file =========== #使终端变回原来的颜色,即白灰色 tput setaf 7 #远程执行命令 rsync -lr $filename `whoami`@s$i:$fullpath #判断命令是否执行成功 if [ $? == 0 ];then echo "命令执行成功" fi done [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 s103: starting regionserver, logging to /soft/hbase/bin/../logs/hbase-yinzhengjie-regionserver-s103.out 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: starting regionserver, logging to /soft/hbase/bin/../logs/hbase-yinzhengjie-regionserver-s104.out s102: starting regionserver, logging to /soft/hbase/bin/../logs/hbase-yinzhengjie-regionserver-s102.out s104: 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 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 s102: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0 [yinzhengjie@s101 ~]$
6>.启动phoenix
三.phoenix的常用命令介绍
Phoenix的数据类型请参考官网:http://phoenix.apache.org/language/datatypes.html
Phoenix的分析函数请参考官网:http://phoenix.apache.org/language/functions.html
1>.启动phoenix的命令行
1 [yinzhengjie@s101 shell]$ sqlline.py s102,s103,s104 2 Setting property: [incremental, false] 3 Setting property: [isolation, TRANSACTION_READ_COMMITTED] 4 issuing: !connect jdbc:phoenix:s102,s103,s104 none none org.apache.phoenix.jdbc.PhoenixDriver 5 Connecting to jdbc:phoenix:s102,s103,s104 6 SLF4J: Class path contains multiple SLF4J bindings. 7 SLF4J: Found binding in [jar:file:/soft/apache-phoenix-4.10.0-HBase-1.2-bin/phoenix-4.10.0-HBase-1.2-client.jar!/org/slf4j/impl/StaticLoggerBinder.class] 8 SLF4J: Found binding in [jar:file:/soft/hadoop-2.7.3/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class] 9 SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. 10 18/06/13 18:16:44 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable 11 Connected to: Phoenix (version 4.10) 12 Driver: PhoenixEmbeddedDriver (version 4.10) 13 Autocommit status: true 14 Transaction isolation: TRANSACTION_READ_COMMITTED 15 Building list of tables and columns for tab-completion (set fastconnect to true to skip)... 16 91/91 (100%) Done 17 Done 18 sqlline version 1.2.0 19 0: jdbc:phoenix:s102,s103,s104>