天天看点

关于Apache Phoenix和Cloudera结合

1. 安装:

phoenix的官网最新版4.13.2是有parcle版本的,并不需要从cloudera的labs(实验室)中下载。

安装完成后,可以运行一下phoenix的shell来简单验证一下:/opt/cloudera/parcels/APACHE_PHOENIX/bin

2. 在实际的应用中:

  Caused by: java.lang.ClassNotFoundException: org.apache.http.config.Lookup

  添加了httpcore的jar的最新版本的引用;

  NoClassDefFoundError: org/apache/http/protocol/HttpContext

  发现不能使用最新版本(4.4.9),需要使用4.4版本,问题解决

  java.net.SocketTimeoutException: callTimeout=60000, callDuration=68229: row 'SYSTEM:CATALOG,,' on table 'hbase:meta' at region=hbase:meta,,1.1588230740, hostname=slave3,60020,1517911366463, seqNum=0

  重启了Zookeeper和HBase问题解决

  Exception in thread "main" java.sql.SQLException: ERROR 2006 (INT08): Incompatible jars detected between client and server. Ensure that phoenix.jar is put on the classpath of HBase in every region server: tried to access method com.google.common.base.Stopwatch.<init>()V from class org.apache.hadoop.hbase.zookeeper.MetaTableLocator

  这个问题没有解决,网调原因是调用端的guava的版本和服务器的版本不一致;但是我尝试了几个版本的guava都没有成功;于是切换到了高版本的phoenix,使用thin-client来进行处理。thin-client非常小,几百K,但是如果想要用原生的jdbc客户端,你需要引用整个phoenix包,100M;thin-client的引用可能就是这个原因吧。但是想要使用thin-client需要启动thin-server。

3. 关于使用thin-client:

步骤如下:

  第一步要启动thin-server,可以通过lsof -i:8765来判断是否启动成功(不过queryserver的路径比较深:/opt/cloudera/parcels/APACHE_PHOENIX/lib/phoenix/bin);

   ./queryserver.py start 

  注意,如果重复启动,将会碰到Address已经被占用的异常;

  第二步,设置maven引用:

  第三步jdbc代码实现访问: