Apache Phoenix 官方站点: https://phoenix.apache.org/
Phoenix支持的sql语句: https://phoenix.apache.org/language/index.html
Phoenix 支持的DataTypes: https://phoenix.apache.org/language/datatypes.html
Phoenix 支持的函数: https://phoenix.apache.org/language/functions.html
0. 软件版本下载
http://archive.apache.org/dist/phoenix/
1. 集群环境
Master 192.168.40.130
Slave1 192.168.40.131
Slave2 192.168.40.132
2. 下载软件包
#Master
]# wget 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 environment
export 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
#master
#分发phoenix-4.14.0-HBase-1.3-server.jar
]# cd /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.验证
- 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'
- 进入phoenix命令行
]# cd /usr/local/src/apache-phoenix-4.14.0-HBase-1.3-bin/bin
sqlline.py localhost 或 sqlline.py master,slave1,slave2:2181
- phoenix中创建视图映射(view 只读)
create view "person" ("ROW" varchar primary key,"basicinfo"."name" varchar,"basicinfo"."age" varchar);
select * from "person";
- 创建完视图后再次查看hbase中表的信息
- view只读验证
UPSERT INTO "person" VALUES('1','uwo','30');
- phoenix 中删除视图
drop view "person";
- 再次查看hbase中表的信息 person 依然存在
- phoenix 中创建映射表(table 读写)
create table "person" ("ROW" varchar primary key,"basicinfo"."name" varchar,"basicinfo"."age" varchar);
select * from "person";
- 创建完表后再次查看hbase中表的信息
多了一个映射信息:column=basicinfo:_0
- phoenix中写验证
UPSERT INTO "person" VALUES('1','uwo','30');
select * from "person";
这个时候如果在phoenix删除表会同时删除hbase中的表
phoenix和hbase中非字符串类型的字段映射会有些问题,在通过api写数据的时候需要经过特殊处理
具体情况参考HBase和Phoenix的类型转换:https://blog.csdn.net/rewerma/article/details/80254876