apache phoenix 安装试用
备注:
本次安装是在hbase docker 镜像的基础上配置的,主要是为了方便学习,而hbase搭建有觉得
有点费事,用镜像简单。
1. hbase 镜像
docker pull harisekhon/hbase
2. 启动hbase
docker run -d -p 2181:2181 -p 8080:8080 -p 8085:8085 -p 9090:9090 -p 9095:9095 -p 16000:16000 -p 16010:16010 -p 16201:16201 -p 16301:16301 harisekhon/hbase
3. 测试hbase
docker exec -it {hbasedocker-id} sh
hbase shell
// 看到下面的就是启动成功了
2017-12-11 05:15:10,909 WARN [main] util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 1.3.1, r930b9a55528fe45d8edce7af42fef2d35e77677a, Thu Apr 6 19:36:54 PDT 2017
// 创建表
create 'users','user_id','user_name','user_age'
4. 集成apache phoenix
因为hbase 的镜像是使用alpine linux 版本,默认已经安装了wget 等一些工具,但是没有python
安装apache phoenix 需要准备 phoenix 以及python
1. apache phoenix
wget http://apache.osuosl.org/phoenix/apache-phoenix-4.13.1-HBase-1.3/bin/apache-phoenix-4.13.1-HBase-1.3-bin.tar.gz
2. python
apk add --no-cache python
3. 按照官方介绍copy phoenix server 到hbase 的lib 目录
tar xvf apache-phoenix-4.13.1-HBase-1.3-bin.tar.gz
cd cd apache-phoenix-4.13.1-HBase-1.3-bin/
cp phoenix-4.13.1-HBase-1.3-server.jar /hbase/lib/
4. 重启hbase server
cd hbase
./stop-hbase.sh
./start-hbase.sh
5. apache phoenix 试用
a. 连接
cd /apache-phoenix-4.13.1-HBase-1.3-bin/bin
./sqlline.py
b. crud
// 创建表
create table userinfo(name varchar,age integer not null primary key);
// 添加数据 upsert into 更新是一样的
upser into userinfo(name,age) values("dalong",1);
// select
select * from userinfo; --- where
+---------+------+
| NAME | AGE |
+---------+------+
| dalong | 1 |
+---------+------+
// delete
delete from userinfo where age=1
// 修改表结构
alter table userinfo add version varchar
alter table userinfo drop COLUMN version
+---------+------+----------+
| NAME | AGE | VERSION |
+---------+------+----------+
| dalong | 1 | |
+---------+------+----------+
6. 客户端工具
1. phoenix 自带的
2. SQuirrel
参考文档:
http://phoenix.apache.org/installation.html#SQL_Client
7. 参考资料
http://phoenix.apache.org/Phoenix-in-15-minutes-or-less.html
https://hub.docker.com/r/harisekhon/hbase/