关于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引用:
<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结合的更多相关文章
- Apache Phoenix on CDH 5
We are happy to announce the inclusion of Apache Phoenix in Cloudera Labs. [Update: A new package fo ...
- [saiku] 使用 Apache Phoenix and HBase 结合 saiku 做大数据查询分析
saiku不仅可以对传统的RDBMS里面的数据做OLAP分析,还可以对Nosql数据库如Hbase做统计分析. 本文简单介绍下一个使用saiku去查询分析hbase数据的例子. 1.phoenix和h ...
- Apache Phoenix JDBC 驱动和Spring JDBCTemplate的集成
介绍:Phoenix查询引擎会将SQL查询转换为一个或多个HBase scan,并编排运行以生成标准的JDBC结果集. 直接使用HBase API.协同处理器与自己定义过滤器.对于简单查询来说,其性能 ...
- phoenix 报错:type org.apache.phoenix.schema.types.PhoenixArray is not supported
今天用phoenix报如下错误: 主要原因: hbase的表中某字段类型是array,phoenix目前不支持此类型 解决方法: 复制替换phoenix包的cursor文件 # Copyright 2 ...
- Mapreduce atop Apache Phoenix (ScanPlan 初探)
利用Mapreduce/hive查询Phoenix数据时如何划分partition? PhoenixInputFormat的源码一看便知: public List<InputSplit> ...
- org.apache.phoenix.exception.PhoenixIOException: SYSTEM:CATALOG
Error: SYSTEM:CATALOG (state=08000,code=101)org.apache.phoenix.exception.PhoenixIOException: SYSTEM: ...
- 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 ...
- apache phoenix 安装试用
备注: 本次安装是在hbase docker 镜像的基础上配置的,主要是为了方便学习,而hbase搭建有觉得 有点费事,用镜像简单. 1. hbase 镜像 docker pull har ...
- 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 ...
随机推荐
- spring security使用哈希加密的密码
之前我们都是使用MD5 Md5PasswordEncoder 或者SHA ShaPasswordEncoder 的哈希算法进行密码加密,在spring security中依然使用只要指定使用自定义加密 ...
- JNI_Z_10_Java的数组
在Java中数组分为两种: (1).基本类型数组 (2).对象类型(Object[])的数组 (数组中存放的是指向Java对象中的引用) 一个能通用于两种不同类型数组的函数: GetArrayLeng ...
- LeetCode第[5]题(Java):Longest Palindromic Substring 标签:String、动态规划
题目中文:求最长回文子串 题目难度:Medium 题目内容: Given a string s, find the longest palindromic substring in s. You ma ...
- 关于jQuery中的offset()和position()
在jQuery中有两个获取元素位置的方法offset()和position().position()方法是在1.2.6版本之后加入的,为什么要引 入这个方法呢?这两个方法之间有什么异同?使用的时候应该 ...
- npm install 时总是报phantomjs-prebuilt@2.1.14安装失败
在npm install时总是报如下错误, 尝试单独安装:npm install phantomjs-prebuilt@2.1.14 还是报错 Please report this full log ...
- Strust2遇到的问题
前端发一次请求,后台执行execute方法多次,最后发现Acion类继承ActionSupport类,且覆盖了execute,当用户数量一上来就会出现执行多次的BUG,所以千万要注意不能给此方法加An ...
- za2
程序集?生成后 一个exe,一个dll. 也可以是一个项目. vs 快速生成字段的代码段快捷键,快速生成构造函数,生成普通方法结构的快捷键 ************************* ...
- C#和Java接口对比
C#和java的接口有很多类似之处,对于编程约束和设计模式的实现有重要作用.这里记录几个知识点. 1. C#的接口中不能有字段,但Java的接口中允许有static final修饰的字段/域(fiel ...
- ICE 中后台开发
1.https://alibaba.github.io/ice/#/block 2.https://www.zhihu.com/question/266529857/answer/309604282 ...
- Annotation: 代码的修饰符
Table of Contents 简介: 是什么, 用途, 为什么有用 使用: 一个简单例子,如@Override.系统提供的annotation,做成列表 定义新的annotation. 涉及到的 ...