一,下载并解压phoenix的压缩包(压缩包版本根据自己hbase版本而定)
tar –zxvf phoenix-4.7.0-HBase-1.1-bin
二,配置phoenix
1,将phoenix-4.7.0-HBase-1.1-bin目录下的phoenix-4.7.0-HBase-1.1-client.jar,phoenix-core-4.7.0-HBase-1.1.jar拷贝到各个hbase节点的hbase目录下的lib目录下cp phoenix-core-4.7.0-HBase-1.1.jar ../hbase-1.1.5/lib/
cp phoenix-4.7.0-HBase-1.1-client.jar ../hbase-1.1.5/lib/
进入hbase-1.1.5/lib/目录执行(也可以在phoenix目录下执行)
scp phoenix*.jar hadoop@node1:/home/hadoop/hbase-1.1.5/lib/
scp phoenix*.jar hadoop@node2:/home/hadoop/hbase-1.1.5/lib/
注意:复制完jar包以后需要重启hbase集群让jar包生效
2,将主节点的hbase-site.xml文件拷贝到phoenix-4.7.0-HBase-1.1-bin/bin目录下
cp hbase-site.xml ~/phoenix-4.7.0-HBase-1.1-bin/bin/
3,进入phoenix的安装目录下执行如下操作
cd /bin
chmod 777 psql.py sqlline.py
三,验证是否配置成功
在bin目录下执行python sqlline.py localhost
出现如下表示启动成功:(不方便截图,请谅解)
Connected to: Phoenix (version 4.7)
Driver: PhoenixEmbeddedDriver (version 4.7)
Autocommit status: true
Transaction isolation: TRANSACTION_READ_COMMITTED
Building list of tables and columns for tab-completion (set fastconnect to true to skip)...
83/83 (100%) Done
Done
sqlline version 1.1.8
0: jdbc:phoenix:localhost>
四,phoenix的使用
1,进入phoenix后可以执行一下!tables来查看有多少表
0: jdbc:phoenix:localhost> !tables+------------+--------------+-------------+---------------+----------+------------+----------------------------+-----------------+--------------+-----------+
| TABLE_CAT | TABLE_SCHEM | TABLE_NAME | TABLE_TYPE | REMARKS | TYPE_NAME | SELF_REFERENCING_COL_NAME | REF_GENERATION | INDEX_STATE | IMMUTABLE |
+------------+--------------+-------------+---------------+----------+------------+----------------------------+-----------------+--------------+-----------+
| | SYSTEM | CATALOG | SYSTEM TABLE | | | | | | false |
| | SYSTEM | FUNCTION | SYSTEM TABLE | | | | | | false |
| | SYSTEM | SEQUENCE | SYSTEM TABLE | | | | | | false |
| | SYSTEM | STATS | SYSTEM TABLE | | | | | | false |
+------------+--------------+-------------+---------------+----------+------------+----------------------------+-----------------+--------------+-----------+
0: jdbc:phoenix:localhost> !exit
!exit代表退出。(老版本的也有可能用!quit)
2,建表:
echo 'CREATE TABLE IF NOT EXISTS PHONEIX_TEST (A1 VARCHAR(2),
USAGE.CORE BIGINT,
USAGE.DB BIGINT,
STATS.ACTIVE_VISITOR INTEGER
CONSTRAINT PK PRIMARY KEY (A1)
)' >PHONEIX_TEST.sql
3,执行建表语句
./psql.py localhost:2181 PHONEIX_TEST.sql4,再次进入查看表
0: jdbc:phoenix:localhost> !tables+------------+--------------+-------------+---------------+----------+------------+----------------------------+-----------------+--------------+-----------+
| TABLE_CAT | TABLE_SCHEM | TABLE_NAME | TABLE_TYPE | REMARKS | TYPE_NAME | SELF_REFERENCING_COL_NAME | REF_GENERATION | INDEX_STATE | IMMUTABLE |
+------------+--------------+-------------+---------------+----------+------------+----------------------------+-----------------+--------------+-----------+
| | SYSTEM | CATALOG | SYSTEM TABLE | | | | | | false |
| | SYSTEM | FUNCTION | SYSTEM TABLE | | | | | | false |
| | SYSTEM | SEQUENCE | SYSTEM TABLE | | | | | | false |
| | SYSTEM | STATS | SYSTEM TABLE | | | | | | false |
| | | PHONEIX_TEST| TABLE | | | | | | false |
+------------+--------------+-------------+---------------+----------+------------+----------------------------+-----------------+--------------+-----------+