问题导读
1.Phoenix 4.3.0 与 Hbase0.98.10-hadoop2如何整合?
2.Phoenix 4.3.0 与 Hbase0.98.10-hadoop2本文是如何解决的?
3.重新编译Phoenix包含哪些步骤?
介绍:Phoenix查询引擎会将SQL查询转换为一个或多个HBase scan,并编排执行以生成标准的JDBC结果集。直接使用HBase API、协同处理器与自定义过滤器,对于简单查询来说,其性能量级是毫秒,对于百万级别的行数来说,其性能量级是秒。更多参考官网:http://phoenix.apache.org/
本文主要详细介绍Phoenix 4.3.0 与 Hbase0.98.10-hadoop2的整合过程
下载最新的Phoenix包
- http://apache.mesi.com.ar/phoenix/phoenix-4.3.0/bin/phoenix-4.3.0-bin.tar.gz
复制代码
拷贝到需要做测试的服务器上,并对其解压缩
- tar -xvf phoenix-4.3.0-bin.tar.gz
复制代码
替换phoenix-4.3.0-server.jar
替换RegionServer以及hmaster中的Phoenix依赖包,替换为新的版本
- RegisonServer部署在hadoop104,hadoop108上,Hmaster部署在hadoop107上
复制代码
- [root@hadoop105 hadoop]# scp phoenix-4.3.0-bin/phoenix-4.3.0-server.jar root@hadoop104:/root/hadoop/hbase-0.98.10-hadoop2/lib
复制代码
- [root@hadoop105 hadoop]# scp phoenix-4.3.0-bin/phoenix-4.3.0-server.jar root@hadoop108:/root/hadoop/hbase-0.98.10-hadoop2/lib
复制代码
- [root@hadoop105 hadoop]# scp phoenix-4.3.0-bin/phoenix-4.3.0-server.jar root@hadoop107:/root/hadoop/hbase-0.98.10-hadoop2/lib
复制代码
重启RegionServer
登录到Hmaster节点(hadoop107),重启Hbase服务
- [root@hadoop107 hbase-0.98.10-hadoop2]# cd bin/
- [root@hadoop107 bin]# ./stop-hbase.sh
- stopping hbase...............
- hadoop107: stopping zookeeper.
- hadoop104: stopping zookeeper.
- hadoop108: stopping zookeeper.
- [root@hadoop107 bin]# ./start-hbase.sh
- hadoop107: starting zookeeper, logging to /root/hadoop/hbase-0.98.10-hadoop2/logs/hbase-root-zookeeper-hadoop107.out
- hadoop108: starting zookeeper, logging to /root/hadoop/hbase-0.98.10-hadoop2/logs/hbase-root-zookeeper-hadoop108.out
- hadoop104: starting zookeeper, logging to /root/hadoop/hbase-0.98.10-hadoop2/logs/hbase-root-zookeeper-hadoop104.out
- starting master, logging to /root/hadoop/hbase-0.98.10-hadoop2/logs/hbase-root-master-hadoop107.out
- hadoop104: starting regionserver, logging to /root/hadoop/hbase-0.98.10-hadoop2/logs/hbase-root-regionserver-hadoop104.out
- hadoop108: starting regionserver, logging to /root/hadoop/hbase-0.98.10-hadoop2/logs/hbase-root-regionserver-hadoop108.out
复制代码
配置Client的CLASSPATH
登录安装phoenix的机器(hadoop105).配置客户机的CLASSPATH,包含phoenix-4.3.0-client.jar,配置/etc/profile文件
- export PHOENIX_HOME=/root/hadoop/phoenix-4.3.0-bin
- export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:/PHOENIX_HOME/phoenix-4.3.0-client.jar
复制代码
执行sqlline
进入phoenix 的bin目录,执行./sqlline.py hadoop107,hadoop108,hadoop104命令
出现以下异常:
- 15/03/10 10:14:08 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
-
- 15/03/10 10:14:10 WARN ipc.CoprocessorRpcChannel: Call failed on IOException
-
- org.apache.hadoop.hbase.DoNotRetryIOException: org.apache.hadoop.hbase.DoNotRetryIOException: SYSTEM.CATALOG: org.apache.hadoop.hbase.regionserver.HRegion.mutateRowsWithLocks(Ljava/util/Collection;Ljava/util/Collection;)V
-
- at org.apache.phoenix.util.ServerUtil.createIOException(ServerUtil.java:84)
-
- at org.apache.phoenix.coprocessor.MetaDataEndpointImpl.createTable(MetaDataEndpointImpl.java:820)
-
- at org.apache.phoenix.coprocessor.generated.MetaDataProtos$MetaDataService.callMethod(MetaDataProtos.java:7763)
-
- at org.apache.hadoop.hbase.regionserver.HRegion.execService(HRegion.java:5890)
-
- at org.apache.hadoop.hbase.regionserver.HRegionServer.execServiceOnRegion(HRegionServer.java:3433)
-
- at org.apache.hadoop.hbase.regionserver.HRegionServer.execService(HRegionServer.java:3415)
-
- at org.apache.hadoop.hbase.protobuf.generated.ClientProtos$ClientService$2.callBlockingMethod(ClientProtos.java:30812)
-
- at org.apache.hadoop.hbase.ipc.RpcServer.call(RpcServer.java:2029)
-
- at org.apache.hadoop.hbase.ipc.CallRunner.run(CallRunner.java:107)
-
- at org.apache.hadoop.hbase.ipc.RpcExecutor.consumerLoop(RpcExecutor.java:130)
-
- at org.apache.hadoop.hbase.ipc.RpcExecutor$1.run(RpcExecutor.java:107)
-
- at java.lang.Thread.run(Thread.java:744)
-
- Caused by: java.lang.NoSuchMethodError: org.apache.hadoop.hbase.regionserver.HRegion.mutateRowsWithLocks(Ljava/util/Collection;Ljava/util/Collection;)V
-
- at org.apache.phoenix.coprocessor.MetaDataEndpointImpl.createTable(MetaDataEndpointImpl.java:800)
-
- ... 10 more
复制代码
原因是该版本与Hbase0.98.10-hadoop2不兼容,网上给出的解决方案是:
- " You will need to upgrade to HBase 0.98.10.1 to resolve this issue. Or,you can recompile Phoenix from source with -Dhbase.version=0.98.10 (or
- 0.98.10.1) "
- 考虑到集群环境的复杂,打算通过重新编译Phoenix
复制代码
重新编译Phoenix
1 首先下载Phoenix 4.3.0 的源码:http://apache.spinellicreations.com/phoenix/phoenix-4.3.0/src/
2 解压后修改pom.xml文件中的hbase版本为0.98.10,hadoop-two.version的版本为2.5.2
- <hbase.version>0.98.10-hadoop2</hbase.version>
- <hadoop-two.version>2.5.2</hadoop-two.version>
复制代码
3 执行mvn进行编译
$ mvn install -DskipTests
$ mvn process-sources
$ mvn package -DskipTests
4 编译完成后,将phoenix-4.3.0-src\phoenix-assembly\target 目录下的
phoenix-4.3.0-server.jar替换掉HMaster,HRegionServer中的phoenix-4.3.0-server.jar
phoenix-4.3.0-client.jar替换掉Hadoop105中的phoenix-4.3.0-client.jar
替换完后重启Hbase
验证安装
此时执行sqlline.py命令,并查询所有表:
测试安装
默认包含一些测试脚本,可以通过执行这些测试脚本来观察数据的变化
./psql.py hadoop107,hadoop108,hadoop104 ../examples/WEB_STAT.sql ../examples/WEB_STAT.csv ../examples/WEB_STAT_QUERIES.sql
查询WEB_STAT的数据
- 0: jdbc:phoenix:hadoop107,hadoop108,hadoop104> select * from WEB_STAT;
-
- +------+------------------------------------------+------------------------------------------+-------------------------+------------------------------------------+------------------------------------------+---+
-
- | HOST | DOMAIN | FEATURE | DATE | CORE | DB | |
-
- +------+------------------------------------------+------------------------------------------+-------------------------+------------------------------------------+------------------------------------------+---+
-
- | EU | Apple.com | Mac | 2013-01-01 01:01:01.000 | 35 | 22 | 3 |
-
- | EU | Apple.com | Store | 2013-01-03 01:01:01.000 | 345 | 722 | 1 |
-
- | EU | Google.com | Analytics | 2013-01-13 08:06:01.000 | 25 | 2 | 6 |
-
- | EU | Google.com | Search | 2013-01-09 01:01:01.000 | 395 | 922 | 1 |
-
- | EU | Salesforce.com | Dashboard | 2013-01-06 05:04:05.000 | 12 | 22 | 4 |
-
- | EU | Salesforce.com | Login | 2013-01-12 01:01:01.000 | 5 | 62 | 1 |
-
- | EU | Salesforce.com | Reports | 2013-01-02 12:02:01.000 | 25 | 11
复制代码
|