安装好Phoenix后配置环境变量
export PHOENIX_PATH=/opt/cloudera/parcels/APACHE_PHOENIX-4.14.0-cdh5.14.2.p0.3
export PATH=$PATH:$PHOENIX_PATH/bin:
进入命令行,这是sqlline.py 配置到path环境变量的情况下
[root@node1 ~]# phoenix-sqlline.py node3:2181:/hbase
如果要退出命令行:!q 或者 !quit
返回信息
[root@node1 ~]# phoenix-sqlline.py node3:2181:/hbase
Setting property: [incremental,false]
Setting property: [isolation, TRANSACTION_READ_COMMITTED]
issuing:!connect jdbc:phoenix:node3:2181:/hbase none none org.apache.phoenix.jdbc.PhoenixDriver
Connecting to jdbc:phoenix:node3:2181:/hbase
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found bindingin [jar:file:/opt/cloudera/parcels/APACHE_PHOENIX-4.14.0-cdh5.14.2.p0.3/lib/phoenix/phoenix-4.14.0-cdh5.14.2-client.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found bindingin [jar:file:/opt/cloudera/parcels/CDH-5.14.2-1.cdh5.14.2.p0.3/jars/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]19/06/20 20:03:49 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Connected to: Phoenix (version4.14)
Driver: PhoenixEmbeddedDriver (version4.14)
Autocommit status:trueTransaction isolation: TRANSACTION_READ_COMMITTED
Building list of tables and columnsfor tab-completion (set fastconnect to trueto skip)...865/865 (100%) Done
Done
sqlline version1.2.0
显示所有表
0: jdbc:phoenix:node3:2181:/hbase> !tables
返回信息
0: jdbc:phoenix:node3:2181:/hbase> !tables+------------+--------------+-------------------------+---------------+----------+------------+-------+
| TABLE_CAT | TABLE_SCHEM | TABLE_NAME | TABLE_TYPE | REMARKS | TYPE_NAME | SELF_ |
+------------+--------------+-------------------------+---------------+----------+------------+-------+
| | | INDEX1_ITEM_TEST1 | INDEX | | | |
| | SYSTEM | CATALOG | SYSTEM TABLE | | | |
| | SYSTEM | FUNCTION | SYSTEM TABLE | | | |
| | SYSTEM | LOG | SYSTEM TABLE | | | |
| | SYSTEM | SEQUENCE | SYSTEM TABLE | | | |
| | SYSTEM | STATS | SYSTEM TABLE | | | |
| | | ASSET_ALLOT | TABLE | | | |
| | | ASSET_BUILDING | TABLE | | | |
| | | ASSET_BUILDING_PENDING | TABLE | | | |
| | | ASSET_CHECK | TABLE | | | |
| | | ASSET_CHECK_PLAN | TABLE | | | |
| | | ASSET_CHECK_REPORT | TABLE | | | |
| | | ASSET_FINANCIAL_DETAIL | TABLE | | | |
| | | ASSET_INVENTORY | TABLE | | | |
| | | ASSET_INVENTORY_PLAN | TABLE | | | |
| | | ASSET_INVENTORY_REPORT | TABLE | | | |
| | | ASSET_ISLAND | TABLE | | | |
| | | ASSET_ISLAND_PENDING | TABLE | | | |
| | | ASSET_NORMAL | TABLE | | | |
| | | ASSET_NORMAL_MOULD | TABLE | | | |
| | | ASSET_NORMAL_PENDING | TABLE | | | |
| | | ASSET_RECORD | TABLE | | | |
| | | ASSET_RENT | TABLE | | | |
| | | ASSET_ROOM | TABLE | | | |
| | | ASSET_SCRAP | TABLE | | | |
| | | ASSET_SEAL | TABLE | | | |
| | | ASSET_TAKEAWAY | TABLE | | | |
| | | ASSET_UNSEAL | TABLE | | | |
| | | ITEM_TEST1 | TABLE | | | |
| | | US_POPULATION | TABLE | | | |
| | | US_POPULATION1 | TABLE | | | |
+------------+--------------+-------------------------+---------------+----------+------------+-------+
从表 ASSET_RECORD 中查询前10条记录
0: jdbc:phoenix:node3:2181:/hbase> SELECT * FROM ASSET_RECORD LIMIT 10;
返回信息
0: jdbc:phoenix:node3:2181:/hbase> SELECT * FROM ASSET_RECORD LIMIT 10;+-----------------------------------+-------------------------+-------------------+---------------+---+
| ID | ASSET_ID | MANAGEMENT_TABLE | INTRODUCTION | |
+-----------------------------------+-------------------------+-------------------+---------------+---+
| d083250dc0f74c3cb79b6ffe041fa4c3 | 仪6-1133208949747748815 | ASSET_CHECK | | 8 |
+-----------------------------------+-------------------------+-------------------+---------------+---+
1 row selected (0.066 seconds)
参考: