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引用:

 <dependency>
<groupId>org.apache.phoenix</groupId>
<artifactId>phoenix-queryserver-client</artifactId>
<version>4.13.2-cdh5.11.2</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4</version>
</dependency>

  第三步jdbc代码实现访问:

String testSQL = "select * from HBASE_TEST";
try {
Class.forName("org.apache.phoenix.queryserver.client.Driver");
} catch (ClassNotFoundException e1) {
System.out.println("org.apache.phoenix.queryserver.client.Driver未找到");
}
List<String> resList = new ArrayList<String>();
Connection con1 = DriverManager
.getConnection("jdbc:phoenix:thin:url=http://10.1.108.65:8765;serialization=PROTOBUF", "", "");
Statement stmt = con1.createStatement();
ResultSet rset = stmt.executeQuery(testSQL);
while (rset.next()) {
String msg = String.format("S1:%s; S2:%s; S3:%s; S4:%s", rset.getString("S1"), rset.getString("S2"),
rset.getString("S3"), rset.getString("S4"));
System.out.println(msg);
} stmt.close();
con1.close();

关于Apache Phoenix和Cloudera结合的更多相关文章

  1. Apache Phoenix on CDH 5

    We are happy to announce the inclusion of Apache Phoenix in Cloudera Labs. [Update: A new package fo ...

  2. [saiku] 使用 Apache Phoenix and HBase 结合 saiku 做大数据查询分析

    saiku不仅可以对传统的RDBMS里面的数据做OLAP分析,还可以对Nosql数据库如Hbase做统计分析. 本文简单介绍下一个使用saiku去查询分析hbase数据的例子. 1.phoenix和h ...

  3. Apache Phoenix JDBC 驱动和Spring JDBCTemplate的集成

    介绍:Phoenix查询引擎会将SQL查询转换为一个或多个HBase scan,并编排运行以生成标准的JDBC结果集. 直接使用HBase API.协同处理器与自己定义过滤器.对于简单查询来说,其性能 ...

  4. phoenix 报错:type org.apache.phoenix.schema.types.PhoenixArray is not supported

    今天用phoenix报如下错误: 主要原因: hbase的表中某字段类型是array,phoenix目前不支持此类型 解决方法: 复制替换phoenix包的cursor文件 # Copyright 2 ...

  5. Mapreduce atop Apache Phoenix (ScanPlan 初探)

    利用Mapreduce/hive查询Phoenix数据时如何划分partition? PhoenixInputFormat的源码一看便知: public List<InputSplit> ...

  6. org.apache.phoenix.exception.PhoenixIOException: SYSTEM:CATALOG

    Error: SYSTEM:CATALOG (state=08000,code=101)org.apache.phoenix.exception.PhoenixIOException: SYSTEM: ...

  7. phoenix连接hbase数据库,创建二级索引报错:Error: org.apache.phoenix.exception.PhoenixIOException: Failed after attempts=36, exceptions: Tue Mar 06 10:32:02 CST 2018, null, java.net.SocketTimeoutException: callTimeou

    v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VM ...

  8. apache phoenix 安装试用

    备注:   本次安装是在hbase docker 镜像的基础上配置的,主要是为了方便学习,而hbase搭建有觉得   有点费事,用镜像简单.   1. hbase 镜像 docker pull har ...

  9. How to use DBVisualizer to connect to Hbase using Apache Phoenix

    How to use DBVisualizer to connect to Hbase using Apache Phoenix Article DB Visualizer is a popular ...

随机推荐

  1. 【转载】在block中使用weakSelf/strongSelf

    http://blog.lessfun.com/blog/2014/11/22/when-should-use-weakself-and-strongself-in-objc-block/

  2. iOS基于XMPP实现即时通讯之一、环境的搭建

    移动端访问不佳,请访问我的个人博客 使用XMPP已经有一段时间了,但是一直都没深入研究过,只是使用SDK做一些简单的操作,看了许多大神的博客,自己总结一下,准备写一系列关于XMPP的使用博客,以便于自 ...

  3. 前端人脸识别框架Tracking.js与JqueryFaceDetection

    这篇文章主要就介绍两种前端的人脸识别框架(Tracking.js和JqueryFaceDetection) 技术特点 Tracking.js是使用js封装的一个框架,使用起来需要自己配置许多的东西,略 ...

  4. 回溯和DFS效率分析

    回溯和DFS效率分析 一.心得 多组数据记得初始化 两组样例,找圆点点的个数 6 9 ....#. .....# ...... ...... ...... ...... ...... #@...# . ...

  5. za2

      程序集?生成后  一个exe,一个dll. 也可以是一个项目. vs 快速生成字段的代码段快捷键,快速生成构造函数,生成普通方法结构的快捷键   ************************* ...

  6. st表模板

    http://blog.csdn.net/insistgogo/article/details/9929103 这篇博客讲解的很详细了,求区间最大值也可以用st表,时间复杂度O(n log(n)),查 ...

  7. Pro C/C++ 编程中值得注意的问题

    1.宿主字符串存储Oracle自动补零问题. EXEC SQL BEGIN DECLARE SECTION; unsigned char liId[25]; EXEC SQL END DECLARE ...

  8. IOS-界面传值

    第二个视图控制器如何获取第一个视图控制器的部分信息 例如 :第二个界面中的lable显示第一个界面textField中的文本 这就需要用到属性传值.block传值 那么第一个视图控制器如何获的第二个视 ...

  9. Spring 自动装配;方法注入

    通过配置defalut—autowire属性,Spring IOC容器可以自动为程序注入Bean:默认是no(不启用自动装配). default—autowire的类型有: byName:通过名称自动 ...

  10. Android application testing with the Android test framework

    目录(?)[-] Android automated testing 1 How to test Android applications Tip 2 Unit tests vs functional ...