◆构建在apachehbase之上的一个sql中间层
可以在apachehbase上执行sql查询,性能强劲
较完善的查询支持,支持二级索引,查询效率较高
·简介:·优势:
put the sql backin nosql,程序员熟知sql语句
◆具有完整acid事务功能的标准sql和idbcapi的强大功能
◆完全可以和其他hadoop产品例如sparkhivepig、flume以及
mapreduce集成
图中展示了,通过phoenix和hive对基于hdfs和hbase的数据记性查询的时候,随着数据量的增长,查询时间的变化曲线
-
phoenix的性能是如何提高的?
通过hbase协处理器,在服务端进行操作,从而最大限度的减少客
户端和服务器的数据传输
通过定制的过滤器对数据进行处理
◆使用本地的hbaseapi而不是通过mapreduce框架,这样能最大限
度的降低启动成本
-
phoenix特性
-
多租户
-
二级索引
-
用户定义函数(分临时函数和永久函数)
-
行时间戳列
-
分页查询
-
视图
-
phoenix安装
下载对应版本的安装包
配置与现有hbase集群集成
重新启动hbase环境,并测试环境是否可以正常使用
1:tar zxf apache-phoenix-4.13.1-hbase-1.2-bin.tar.gz
2:cd apache-phoenix-4.13.1-hbase-1.2-bin
cp phoenix-core-4.13.1-hbase-1.2.jar ../hbase-1.2.4/lib/
cp phoenix-4.13.1-hbase-1.2-server.jar ../hbase-1.2.4/lib/
3:cd bin
./sqlline.py
[root@test bin]# ./sqlline.py
setting property: [incremental, false]
setting property: [isolation, transaction_read_committed]
issuing: !connect jdbc:phoenix:localhost:2181:/hbase none none org.apache.phoenix.jdbc.phoenixdriver
connecting to jdbc:phoenix:localhost:2181:/hbase
21/05/11 21:38:14 warn util.nativecodeloader: unable to load native-hadoop library for your platform... using builtin-java classes where applicable
connected to: phoenix (version 4.13)
driver: phoenixembeddeddriver (version 4.13)
autocommit status: true
transaction isolation: transaction_read_committed
building list of tables and columns for tab-completion (set fastconnect to true to skip)...
92/92 (100%) done
done
sqlline version 1.2.0
0: jdbc:phoenix:localhost:2181:/hbase> help
-
通过shell操作phoenix
-
通过java jdbc操作phoenix
<dependency>
<groupid>org.apache.phoenix</groupid>
<artifactid>phoenix-core</artifactid>
<version>4.13.1-hbase-1.2</version>
</dependency>
public static void main(string[] args) throws exception{
class.forname("org.apache.phoenix.jdbc.phoenixdriver");
connection connection = drivermanager.getconnection("jdbc:phoenix:10.0.0.174:2181");
preparedstatement preparedstatement = connection.preparestatement("select * from person");
resultset resultset = preparedstatement.executequery();
while (resultset.next()){
system.out.println(resultset.getstring("name"));
}
preparedstatement.close();
connection.close();
}
发表评论