一、Phoenix简介
1、Phoenix定义 Phoenix是HBase的开源SQL皮肤。可以使用标准JDBC API代替HBase客户端API来创建表,插入数据和查询HBase数据。
2、为什么使用Phoenix 官方给的解释为:在Client和HBase之间放一个Phoenix中间层不会减慢速度,因为用户编写的数据处理代码和Phoenix编写的没有区别,不仅如此Phoenix对于用户输入的SQL同样会有大量的优化手段(就像Hive自带sql优化器一样)。
3、官方网站 https://phoenix.apache.org/ 当前安装版本为5.1.3
二、安装
1、phoenix需要匹配hbase版本,hbase版本为2.5.2
cd /tmp
wget https://dlcdn.apache.org/phoenix/phoenix-5.1.3/phoenix-hbase-2.5-5.1.3-bin.tar.gz
tar -zxvf phoenix-hbase-2.5-5.1.3-bin.tar.gz -C /appserver
cd /appserver
mv phoenix-hbase-2.5-5.1.3-bin/ phoenix
三、使用
1、phoenix本体就是几个jar包 phoenix-client-embedded-hbase-2.5-5.1.3.jar phoenix-client-hbase-2.5-5.1.3.jar phoenix-pherf-5.1.3.jar phoenix-server-hbase-2.5-5.1.3.jar
2、复制server包并拷贝到各个节点的hbase/lib cp phoenix-server-hbase-2.5-5.1.3.jar /appserver/hbase/lib/
3、配置环境变量
vi /etc/profile
添加
export PHOENIX_HOME=/appserver/phoenix
export PHOENIX_CLASSPATH=$PHOENIX_HOME
export PATH=$PATH:$PHOENIX_HOME/bin
使配置生效
source /etc/profile
4、重启HBase
stop-hbase.sh
start-hbase.sh
5、连接Phoenix
bin/sqlline.py hadoop001:2181
说明:用sqlline.py工具,连zookeeper的地址
Setting property: [incremental, false]
Setting property: [isolation, TRANSACTION_READ_COMMITTED]
issuing: !connect -p driver org.apache.phoenix.jdbc.PhoenixDriver -p user "none" -p password "none" "jdbc:phoenix:hadoop001:2181"
Connecting to jdbc:phoenix:hadoop001:2181
23/02/08 13:27:34 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
23/02/08 13:27:34 WARN impl.MetricsConfig: Cannot locate configuration: tried hadoop-metrics2-phoenix.properties,hadoop-metrics2.properties
Connected to: Phoenix (version 5.1)
Driver: PhoenixEmbeddedDriver (version 5.1)
Autocommit status: true
Transaction isolation: TRANSACTION_READ_COMMITTED
sqlline version 1.9.0
0: jdbc:phoenix:hadoop001:2181>
6、简单测试
0: jdbc:phoenix:hadoop001:2181> !tables
+-----------+-------------+------------+--------------+---------+-----------+---------------------------+----------------+-------------+----------------+--------------+--------------+----------------+
| TABLE_CAT | TABLE_SCHEM | TABLE_NAME | TABLE_TYPE | REMARKS | TYPE_NAME | SELF_REFERENCING_COL_NAME | REF_GENERATION | INDEX_STATE | IMMUTABLE_ROWS | SALT_BUCKETS | MULTI_TENANT | VIEW_STATEMENT |
+-----------+-------------+------------+--------------+---------+-----------+---------------------------+----------------+-------------+----------------+--------------+--------------+----------------+
| | SYSTEM | CATALOG | SYSTEM TABLE | | | | | | false | null | false | |
| | SYSTEM | CHILD_LINK | SYSTEM TABLE | | | | | | false | null | false | |
| | SYSTEM | FUNCTION | SYSTEM TABLE | | | | | | false | null | false | |
| | SYSTEM | LOG | SYSTEM TABLE | | | | | | true | 32 | false | |
| | SYSTEM | MUTEX | SYSTEM TABLE | | | | | | true | null | false | |
| | SYSTEM | SEQUENCE | SYSTEM TABLE | | | | | | false | null | false | |
| | SYSTEM | STATS | SYSTEM TABLE | | | | | | false | null | false | |
| | SYSTEM | TASK | SYSTEM TABLE | | | | | | false | null | false | |
+-----------+-------------+------------+--------------+---------+-----------+---------------------------+----------------+-------------+----------------+--------------+--------------+----------------+
0: jdbc:phoenix:hadoop001:2181>
相关文章
发表评论