1.官网地址
http://phoenix.apache.org/http://phoenix.apache.org/
2.Phoenix部署
2.1 上传并解压
解压
tar -zxvf apache-phoenix-5.0.0-HBase-2.0-bin.tar.gz -C /opt/install/
修改文件名
mv apache-phoenix-5.0.0-HBase-2.0-bin phoenix-5.0.0
2.2 复制server包并拷贝到各个节点的hbase/lib
[root@node01 phoenix-5.0.0]# cp phoenix-5.0.0-HBase-2.0-server.jar /opt/install/hbase-2.2.7/lib/
[root@node01 phoenix-5.0.0]# scp phoenix-5.0.0-HBase-2.0-server.jar node02:/opt/install/hbase-2.2.7/lib/
[root@node01 phoenix-5.0.0]# scp phoenix-5.0.0-HBase-2.0-server.jar node03:/opt/install/hbase-2.2.7/lib/
2.3 配置环境变量
#phoenix
export PHOENIX_HOME=/opt/install/phoenix-5.0.0
export PHOENIX_CLASSPATH=$PHOENIX_HOME
export PATH=$PATH:$PHOENIX_HOME/bin
2.4 修改hbase-site.xml 添加如下配置
<!-- 注意:为了开启hbase的namespace和phoenix的schema的映射,在程序中需要加这个配置文件,另外在linux服务上,也需要在hbase以及phoenix的hbase-site.xml配置文件中,加上以上两个配置,并使用xsync进行同步(本节1中文档已有说明)。-->
<property>
<name>phoenix.schema.isNamespaceMappingEnabled</name>
<value>true</value>
</property>
<property>
<name>phoenix.schema.mapSystemTablesToNamespace</name>
<value>true</value>
</property>
2.5 分发hbase-site.xml
[root@node01 conf]# scp hbase-site.xml node02:
pwd
[root@node01 conf]# scp hbase-site.xml node03:
pwd
2.6 替换phoenix/bin 目录下的hbase-site.xml
[root@node01 conf]# cp hbase-site.xml /opt/install/phoenix-5.0.0/bin/
2.7 重启HBase
stop-hbase.sh
start-hbase.sh
2.8 连接Phoenix
[root@node01 phoenix-5.0.0]# bin/sqlline.py
另一种连接方式
[root@node01 phoenix-5.0.0]# bin/sqlline.py node01,node02,node03:2181
3.连接phoenix过程中遇到的问题:
3.1 如果不替换phoenix/bin下面的hbase-site.xml 报错如下:
phoenix连接hbase报错:Inconsistent namespace mapping properties. Ensure that config phoenix.schema.isName
问题原因:在修改hbase-site.xml文件中的Phoenix的配置时没有同步到Phoenix/bin中的hbase-site.xml文件
解决办法:把修改后的hbase-site.xml文件重新拷贝到Phoenix集群中的bin目录下
3.2 报错:Caused by: java.lang.NoClassDefFoundError: org/apache/htrace/Trace
[root@node01 phoenix-5.0.0]# bin/sqlline.py
Setting property: [incremental, false]
Setting property: [isolation, TRANSACTION_READ_COMMITTED]
issuing: !connect jdbc:phoenix: none none org.apache.phoenix.jdbc.PhoenixDriver
Connecting to jdbc:phoenix:
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/install/phoenix-5.0.0/phoenix-5.0.0-HBase-2.0-client.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/install/hadoop-3.1.1/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
23/05/16 16:21:49 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Error: org.apache.phoenix.exception.PhoenixIOException: org.apache.hadoop.hbase.DoNotRetryIOException: java.lang.NoClassDefFoundError: org/apache/htrace/Trace
at org.apache.hadoop.hbase.ipc.RpcServer.call(RpcServer.java:474)
at org.apache.hadoop.hbase.ipc.CallRunner.run(CallRunner.java:133)
at org.apache.hadoop.hbase.ipc.RpcExecutor$Handler.run(RpcExecutor.java:338)
at org.apache.hadoop.hbase.ipc.RpcExecutor$Handler.run(RpcExecutor.java:318)
Caused by: java.lang.NoClassDefFoundError: org/apache/htrace/Trace
at org.apache.phoenix.coprocessor.BaseScannerRegionObserver$RegionScannerHolder.overrideDelegate(BaseScannerRegionObserver.java:222)
at org.apache.phoenix.coprocessor.BaseScannerRegionObserver$RegionScannerHolder.nextRaw(BaseScannerRegionObserver.java:273)
at org.apache.hadoop.hbase.regionserver.RSRpcServices.scan(RSRpcServices.java:3239)
at org.apache.hadoop.hbase.regionserver.RSRpcServices.scan(RSRpcServices.java:3484)
at org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos$ClientService$2.callBlockingMethod(ClientProtos.java:42278)
at org.apache.hadoop.hbase.ipc.RpcServer.call(RpcServer.java:418)
... 3 more (state=08000,code=101)
org.apache.phoenix.exception.PhoenixIOException: org.apache.phoenix.exception.PhoenixIOException: org.apache.hadoop.hbase.DoNotRetryIOException: java.lang.NoClassDefFoundError: org/apache/htrace/Trace
at org.apache.hadoop.hbase.ipc.RpcServer.call(RpcServer.java:474)
at org.apache.hadoop.hbase.ipc.CallRunner.run(CallRunner.java:133)
at org.apache.hadoop.hbase.ipc.RpcExecutor$Handler.run(RpcExecutor.java:338)
at org.apache.hadoop.hbase.ipc.RpcExecutor$Handler.run(RpcExecutor.java:318)
Caused by: java.lang.NoClassDefFoundError: org/apache/htrace/Trace
原因:找不到类
解决办法:查看/opt/install/hbase-2.2.7/lib 下面是否有htrace-core-3.2.0-incubating.jar
如果没有下载htrace-core-3.2.0-incubating.jar 包,将该包放到/opt/install/hbase-2.2.7/lib下面,hbase每一个节点都要放,然后重启hbase
扩展:
查看某个jar包下面有哪些类以及方法
for i in /opt/install/hbase-2.2.7/lib/htrace-core-3.2.0-incubating.jar; do jar -tvf "$i" | grep -Hsi org.apache.htrace.Trace && echo "$i"; done
[root@node01 lib]# for i in /opt/install/hbase-2.2.7/lib/htrace-core-3.2.0-incubating.jar; do jar -tvf "$i" | grep -Hsi org.apache.htrace.Trace && echo "$i"; done
(standard input): 5672 Thu Apr 30 16:55:44 CST 2015 org/apache/htrace/Trace.class
(standard input): 1025 Thu Apr 30 16:55:44 CST 2015 org/apache/htrace/TraceInfo.class
(standard input): 645 Thu Apr 30 16:55:44 CST 2015 org/apache/htrace/Tracer$1.class
(standard input): 590 Thu Apr 30 16:55:44 CST 2015 org/apache/htrace/Tracer$TracerHolder.class
(standard input): 4558 Thu Apr 30 16:55:44 CST 2015 org/apache/htrace/Tracer.class
(standard input): 2287 Thu Apr 30 16:55:44 CST 2015 org/apache/htrace/TraceScope.class
(standard input): 1083 Thu Apr 30 16:55:44 CST 2015 org/apache/htrace/TraceTree$SpansByParent$1.class
(standard input): 2933 Thu Apr 30 16:55:44 CST 2015 org/apache/htrace/TraceTree$SpansByParent.class
(standard input): 1269 Thu Apr 30 16:55:44 CST 2015 org/apache/htrace/TraceTree$SpansByProcessId$1.class
(standard input): 2766 Thu Apr 30 16:55:44 CST 2015 org/apache/htrace/TraceTree$SpansByProcessId.class
(standard input): 2234 Thu Apr 30 16:55:44 CST 2015 org/apache/htrace/TraceTree.class
/opt/install/hbase-2.2.7/lib/htrace-core-3.2.0-incubating.jar
版权归原作者 mht14208 所有, 如有侵权,请联系我们删除。