美文网首页
Phoenix使用

Phoenix使用

作者: 诺之林 | 来源:发表于2020-12-17 20:30 被阅读0次

本文的主线 准备 => 表操作 => 数据操作 => 客户端

本文基于Phoenix搭建

准备

java -version
# openjdk version "1.8.0_272"

cp apache-phoenix-5.0.0-HBase-2.0-bin/phoenix-5.0.0-HBase-2.0-server.jar ~/Services/hbase-2.0.0/lib/

./hbase-2.0.0/bin/start-hbase.sh

jps | grep HMaster
# 2794 HMaster

表操作

python2 ~/apache-phoenix-5.0.0-HBase-2.0-bin/bin/sqlline.py localhost
CREATE TABLE IF NOT EXISTS t_gps (
    id BIGINT NOT NULL,
    longitude DOUBLE,
    latitude DOUBLE,
    city VARCHAR,
    created_ts BIGINT NOT NULL,
    CONSTRAINT pk PRIMARY KEY (id,created_ts)
);
# DROP TABLE t_gps;

!describe t_gps
./hbase-2.0.0/bin/hbase shell

describe 'T_GPS'

数据操作

python2 ~/apache-phoenix-5.0.0-HBase-2.0-bin/bin/sqlline.py localhost
UPSERT INTO t_gps VALUES(1001,118.77807441,32.0572355,'BeiJing',1608199850);

UPSERT INTO t_gps VALUES(1001,118.77807441,32.0572355,'BeiJing',1608219850);

UPSERT INTO t_gps VALUES(1002,118.77807441,32.0572355,'BeiJing',1608229850);

SELECT * FROM t_gps;

SELECT * FROM t_gps WHERE id = 1001 ORDER BY created_ts ASC;

SELECT * FROM t_gps WHERE id = 1001 ORDER BY created_ts DESC;

客户端

  • 下载SQuirrel => 双击jar包安装

  • 安装Apache Phoenix Client驱动

cp ~/Services/apache-phoenix-5.0.0-HBase-2.0-bin/phoenix-5.0.0-HBase-2.0-client.jar /Applications/SQuirreLSQL.app/Contents/Resources/Java/lib/
  • 添加Apache Phoenix Client驱动
Name: phoenix

ExampleURL: jdbc:phoenix:localhost

Class Name: org.apache.phoenix.jdbc.PhoenixDriver
  • 添加Alias别名
Name: phoenix

Driver: phoenix

URL: jdbc:phoenix:localhost
  • 连接后查看表数据效果如下
image.png

除了SQuirrel还可以使用DataGrip

参考

相关文章

网友评论

      本文标题:Phoenix使用

      本文链接:https://www.haomeiwen.com/subject/nzpagktx.html