Monday 7 August 2017

Connect Apache Phoenix to MapR HBase

Aim:

Integrate Apache Phoenix and MapR HBase.

Environment details:

MapR Core Version : 5.2.1
Phoenix Version         : 4.8.2
MapR HBase Version : 1.1.8 

Pre-requisites:

MapR cluster (unsecured) up and running with HBase master and regionserver. Following example is performed on a single node cluster. The services running on the cluster is shown below:

historyserver,hbmaster,hbregionserver,webserver,nodemanager,cldb,fileserver,resourcemanager,hoststats

Steps:

[1] Download the required Phoenix from http://phoenix.apache.org/download.html
[2] Extract the tar file
[3] Copy the phoenix-4.8.2-HBase-1.1-server.jar to ‘/opt/mapr/hbase/hbase-1.1.8/lib/’ folder on all nodes that has HBase master or regionserver installed.

[4] Restart the HBase services on all nodes.
maprcli node services -action restart -name hbmaster -filter ["csvc==hbmaster"]
maprcli node services -action restart -name hbregionserver -filter ["csvc==hbregionserver"]

[5] Go to the Phoenix bin directory, execute the following command:
./sqlline.py <zookeeper_node>:5181
[root@ip-10-X-Y-Z bin]# ./sqlline.py `hostname`:5181
Setting property: [incremental, false]
Setting property: [isolation, TRANSACTION_READ_COMMITTED]
issuing: !connect jdbc:phoenix:ip-10-X-Y-Z:5181 none none org.apache.phoenix.jdbc.PhoenixDriver
Connecting to jdbc:phoenix:ip-10-X-Y-Z:5181
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/mapr/phoenix/apache-phoenix-4.8.2-HBase-1.1-bin/phoenix-4.8.2-HBase-1.1-client.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/mapr/lib/slf4j-log4j12-1.7.12.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
17/08/07 18:02:42 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Connected to: Phoenix (version 4.8)
Driver: PhoenixEmbeddedDriver (version 4.8)
Autocommit status: true
Transaction isolation: TRANSACTION_READ_COMMITTED
Building list of tables and columns for tab-completion (set fastconnect to true to skip)...
88/88 (100%) Done
Done
sqlline version 1.1.9
0: jdbc:phoenix:ip-10-X-Y-Z:5181>

[6] Listing tables in Phoenix:
0: jdbc:phoenix:ip-10-9-0-9:5181> !tables
+------------+--------------+-------------+---------------+----------+------------+----------------------------+-----------------+--------------+-----------------+---+
| TABLE_CAT | TABLE_SCHEM | TABLE_NAME | TABLE_TYPE | REMARKS | TYPE_NAME | SELF_REFERENCING_COL_NAME | REF_GENERATION | INDEX_STATE | IMMUTABLE_ROWS | S |
+------------+--------------+-------------+---------------+----------+------------+----------------------------+-----------------+--------------+-----------------+---+
| | SYSTEM | CATALOG | SYSTEM TABLE | | | | | | false | n |
| | SYSTEM | FUNCTION | SYSTEM TABLE | | | | | | false | n |
| | SYSTEM | SEQUENCE | SYSTEM TABLE | | | | | | false | n |
| | SYSTEM | STATS | SYSTEM TABLE | | | | | | false | n |
+------------+--------------+-------------+---------------+----------+------------+----------------------------+-----------------+--------------+-----------------+---+
0: jdbc:phoenix:ip-10-9-0-9:5181>


[6] At this point you will see following tables in HBase:
hbase(main):006:0> list
Listing HBase tables. Specify a path or configure namespace mappings to list M7 tables.
TABLE
SYSTEM.CATALOG
SYSTEM.FUNCTION
SYSTEM.SEQUENCE
SYSTEM.STATS
4 row(s) in 0.0090 seconds

=> ["SYSTEM.CATALOG", "SYSTEM.FUNCTION", "SYSTEM.SEQUENCE", "SYSTEM.STATS"]  

No comments:

Post a Comment