1. 集群环境
Master 192.168.40.130
Slave1 192.168.40.131
Slave2 192.168.40.132
2. 下载软件包
#Masterwget http://mirror.bit.edu.cn/apache/phoenix/apache-phoenix-4.14.0-HBase-1.3/bin/apache-phoenix-4.14.0-HBase-1.3-bin.tar.gz tar zxvf apache-phoenix-4.14.0-HBase-1.3-bin.tar.gz
3. 配置环境变量
#vim /etc/profile#set phoenix environmentexport PHOENIX_HOME=/usr/local/src/apache-phoenix-4.14.0-HBase-1.3-bin PATH=${PHOENIX_HOME}/bin:$PATH#安装 python-argparse 解析模块yum install python-argparse
4. 分发phoenix的驱动
参考:https://phoenix.apache.org/Phoenix-in-15-minutes-or-less.html
image
#master#phoenix-4.14.0-HBase-1.3-server.jarcd /usr/local/src/apache-phoenix-4.14.0-HBase-1.3-bin cp phoenix-4.14.0-HBase-1.3-server.jar /usr/local/src/hbase-1.3.1/lib/ scp phoenix-4.14.0-HBase-1.3-server.jar root@slave1:/usr/local/src/hbase-1.3.1/lib/ scp phoenix-4.14.0-HBase-1.3-server.jar root@slave2:/usr/local/src/hbase-1.3.1/lib/
5.重启Hbase
cd /usr/local/src/hbase-1.3.1/bin ./stop-hbase.sh ./start-hbase.sh
6.验证
6.1 hbase建表
cd usr/local/src/hbase-1.3.1/bin hbase shell create 'person','basicinfo'put 'person','1', 'basicinfo:name', 'uwoer'put 'person','1', 'basicinfo:age', '24'scan 'person'
image
6.2 phoenix登录
cd /usr/local/src/apache-phoenix-4.14.0-HBase-1.3-bin/bin sqlline.py localhost 或 sqlline.py master,slave1,slave2:2181
6.3 创建 view
create view "person" ("ROW" varchar primary key,"basicinfo"."name" varchar,"basicinfo"."age" varchar); select * from "person";
image
创建完视图后再次查看hbase中表的信息
image
view只读验证
UPSERT INTO "person" VALUES('1','uwo','30');
image
phoenix 中删除视图drop view "person";
再次查看hbase中表的信息 person 依然存在
image
7.创建table
phoenix 中创建映射表
create table "person" ("ROW" varchar primary key,"basicinfo"."name" varchar,"basicinfo"."age" varchar); select * from "person";
image
创建完表后再次查看hbase中表的信息
image
多了一个映射信息:column=basicinfo:_0
phoenix 中写验证
UPSERT INTO "person" VALUES('1','uwo','30'); select * from "person";
image
这个时候如果在phoenix 删除表会同时删除hbase中的表
总结: view无法upsert ,table可以upsert
作者:中国HBase技术社区
链接:https://www.jianshu.com/p/4e6233dd2ba4