1、背景
CDH6.2已经支持phoenix Parcel, 可以下载对应包后在CM界面化方式安装(可参考CDH6.2-phoenix 文章)。CDH6.1 貌似没有集成phoenix。手动安装吧
2、安装过程
[root@cdh03 ~]# apache-phoenix-5.0.0-HBase-2.0-bin.tar.gz
[root@cdh03 ~]# tar -zxf apache-phoenix-5.0.0-HBase-2.0-bin.tar.gz
[root@cdh03 ~]# mv apache-phoenix-5.0.0-HBase-2.0-bin phoenix-5.0-HBase-2.0
[root@cdh03 ~]# mv phoenix-5.0-HBase-2.0 /opt/
[root@cdh03 ~]# vi /etc/profile
????????export JAVA_HOME=/usr/java/jdk1.8.0_141-cloudera ????????export PHOENIX_HOME=/opt/phoenix-5.0-HBase-2.0 ????????export PATH=$PHOENIX_HOME/bin:$JAVA_HOME/bin:$PATH
[root@cdh01 ~]# scp phoenix-5.0.0-HBase-2.0-*.jar root@cdh01:/opt/cloudera/parcels/CDH-6.1.0-1.cdh6.1.0.p0.770702/lib/hbase/lib/
[root@cdh01 ~]# scp phoenix-5.0.0-HBase-2.0-*.jar root@cdh02:/opt/cloudera/parcels/CDH-6.1.0-1.cdh6.1.0.p0.770702/lib/hbase/lib/
[root@cdh01 ~]# scp phoenix-5.0.0-HBase-2.0-*.jar root@cdh03:/opt/cloudera/parcels/CDH-6.1.0-1.cdh6.1.0.p0.770702/lib/hbase/lib/
3、CDH hbase配置
?
保存 ->?重启hbase生效
4、测试?
4.1进入phoenix终端
[root@cdh03 ~]# sqlline.py
0: jdbc:phoenix:> !tables
+------------+--------------+-------------+---------------+----------+------------+----------------------------+-+
| TABLE_CAT | TABLE_SCHEM | TABLE_NAME | TABLE_TYPE | REMARKS | TYPE_NAME | SELF_REFERENCING_COL_NAME | |
+------------+--------------+-------------+---------------+----------+------------+----------------------------+-+
| | SYSTEM | CATALOG | SYSTEM TABLE | | | | |
| | SYSTEM | FUNCTION | SYSTEM TABLE | | | | |
| | SYSTEM | LOG | SYSTEM TABLE | | | | |
| | SYSTEM | SEQUENCE | SYSTEM TABLE | | | | |
| | SYSTEM | STATS | SYSTEM TABLE | | | | |
| | | user_info | TABLE | | | | |
+------------+--------------+-------------+---------------+----------+------------+----------------------------+-+
0: jdbc:phoenix:>
4.2、phoenix终端建表测试
0: jdbc:phoenix:> CREATE TABLE "user_info" (
. . . . . . . . > "ROW" varchar primary key,
. . . . . . . . > "cf1"."gc" double ,
. . . . . . . . > "cf1"."id" bigint ,
. . . . . . . . > "cf1"."jd" double ,
. . . . . . . . > "cf1"."name" varchar ,
. . . . . . . . > "cf1"."wd" double
. . . . . . . . > )column_encoded_bytes=0;
No rows affected (3.159 seconds)
0: jdbc:phoenix:> !table
+------------+--------------+-------------+---------------+----------+------------+----------------------------+-+
| TABLE_CAT | TABLE_SCHEM | TABLE_NAME | TABLE_TYPE | REMARKS | TYPE_NAME | SELF_REFERENCING_COL_NAME | |
+------------+--------------+-------------+---------------+----------+------------+----------------------------+-+
| | SYSTEM | CATALOG | SYSTEM TABLE | | | | |
| | SYSTEM | FUNCTION | SYSTEM TABLE | | | | |
| | SYSTEM | LOG | SYSTEM TABLE | | | | |
| | SYSTEM | SEQUENCE | SYSTEM TABLE | | | | |
| | SYSTEM | STATS | SYSTEM TABLE | | | | |
| | | user_info | TABLE | | | | |
+------------+--------------+-------------+---------------+----------+------------+----------------------------+-+
0: jdbc:phoenix:> UPSERT INTO "user_info"("ROW", "gc", "id", "jd", "name", "wd") VALUES('2', 1.1, 2, 3.33, '名字1'5.1234);
1 row affected (0.089 seconds)
0: jdbc:phoenix:> select * from "user_info";
+------+------+-----+-------+-------+---------+
| ROW | gc | id | jd | name | wd |
+------+------+-----+-------+-------+---------+
| 2 | 1.1 | 2 | 3.33 | 名字1 | 5.1234 |
+------+------+-----+-------+-------+---------+
1 row selected (0.076 seconds)
0: jdbc:phoenix:>
4.3、hbase 终端查看
base(main):001:0> list
TABLE
SYSTEM.CATALOG
SYSTEM.FUNCTION
SYSTEM.LOG
SYSTEM.MUTEX
SYSTEM.SEQUENCE
SYSTEM.STATS
user_info
7 row(s)
Took 3.4901 seconds
=> ["SYSTEM.CATALOG", "SYSTEM.FUNCTION", "SYSTEM.LOG", "SYSTEM.MUTEX", "SYSTEM.SEQUENCE", "SYSTEM.STATS", "user_info"]
hbase(main):002:0> scan 'user_info'
ROW COLUMN+CELL
2 column=cf1:_0, timestamp=1653199176682, value=x
2 column=cf1:gc, timestamp=1653199176682, value=\xBF\xF1\x99\x99\x99\x99\x99\x9B
2 column=cf1:id, timestamp=1653199176682, value=\x80\x00\x00\x00\x00\x00\x00\x02
2 column=cf1:jd, timestamp=1653199176682, value=\xC0\x0A\xA3\xD7\x0A=p\xA5
2 column=cf1:name, timestamp=1653199176682, value=\xE5\x90\x8D\xE5\xAD\x971
2 column=cf1:wd, timestamp=1653199176682, value=\xC0\x14~\x5C\x91\xD1N=
1 row(s)
Took 0.2343 seconds
ok!
|