Phoenix Data Sources

Page edited by Kylin Soong


Changes (11)

...
* Mapping Phoenix table to an existing HBase table

* Creaing Phoenix table for creating a new HBase table
* Creaing Phoenix table

h1. Configuring a Phoenix data source in JBoss/WildFly (later than JBoss AS 7)
...
* driver-name - The Driver name need to match the driver you deployed in above steps

* driver-class - The Driver Class, the value should be _org.apache.phoenix.jdbc.PhoenixDriver_

* connection-url - The URL need to match the HBase zookeeper quorum server, the format like _jdbc:phoenix \[ :<zookeeper quorum> \[ :<port number> \] \[ :<root node> \] \], 'jdbc:phoenix:127.0.0.1:2181' \]_, '_jdbc:phoenix:127.0.0.1:2181_' is a example

* user-name/password - The user credentials for Phoenix Connection
...
The second step is executing the DDL to map Phoenix table to an existing HBase table, the DDL can either be executed via [Phoenix Command Line|http://phoenix.apache.org/download.html], or executed by JDBC.

The Following is a example for mapping an existing HBase table, assume the Customer table, assume the Customer table is existing in HBase, it looks as below figure is existing in HBase, it looks as below figure
The Following is a example for mapping an existing HBase table, assume the Customer table, assume the _Customer_ table is existing in HBase, it looks as below:


Test
| Row Key | customer | sales |
| ROW_ID | name | city | product | amount |
| 101 | John White | Los Angeles, CA | Chairs | $400.00 |
| 102 | Jane Brown | Atlanta, GA | Lamps | $200.00 |
| 103 | Bill Green | Pittsburgh, PA | Desk | $500.00 |
| 104 | Jack Black | St. Louis, MO | Bed | $1,600.00 |


As depicted above, HBase _Customer_ table have 2 column families, _customer_ and _sales_, each has 2 column qualifiers, _name_, _city_, _product_ and _amount_ correspondingly. We can map this Table to Phoenix via DDL:
Test
{code}
CREATE TABLE IF NOT EXISTS "Customer"("ROW_ID" VARCHAR PRIMARY KEY, "customer"."city" VARCHAR, "customer"."name" VARCHAR, "sales"."amount" VARCHAR, "sales"."product" VARCHAR)
{code}
For more about mapping Phoenix table to an existing HBase table please refer to [phoenix document|http://phoenix.apache.org/faq.html#How_I_map_Phoenix_table_to_an_existing_HBase_table].

h1. Creating Phoenix table

For creating Phoenix table just like mapping to an existing HBase table, Phoenix will create any metadata (table, column families) that doesn’t exist. As above example, if Customer doesn't exist, the DDL

{code}
CREATE TABLE IF NOT EXISTS "Customer"("ROW_ID" VARCHAR PRIMARY KEY, "customer"."city" VARCHAR, "customer"."name" VARCHAR, "sales"."amount" VARCHAR, "sales"."product" VARCHAR)
{code}
will create _Customer_ table in HBase.

Full Content

Phoenix Data Sources

Primary purpose of this article including:

  • Configuring a Phoenix data source in JBoss/WildFly Container(later than JBoss AS 7)
  • Mapping Phoenix table to an existing HBase table
  • Creaing Phoenix table

Configuring a Phoenix data source in JBoss/WildFly (later than JBoss AS 7)

Configuring a Phoenix data source is nearly identical configuring a JDBC Data Sources, first step is deploying the Phoenix driver jar, the following command using the CLI to deploy Phoenix driver

deploy /path/to/phoenix-[version]-client.jar

The Driver jar can be download from phoenix document.

The second steps is creating the Data Source base on above deployed driver, also like creating JDBC Data Source, execute the following CLI command:

/subsystem=datasources/data-source=phoenixDS:add(jndi-name=java:/phoenixDS,  driver-name=phoenix-[version].jar, driver-class=org.apache.phoenix.jdbc.PhoenixDriver, connection-url=jdbc:phoenix:{zookeeper quorum server},user-name={user}, password={password})

Please make sure the URL, Driver are configured correctly:

  • jndi-name - The JNDI name need to match the JNDI name you used in VDB
  • driver-name - The Driver name need to match the driver you deployed in above steps
  • driver-class - The Driver Class, the value should be org.apache.phoenix.jdbc.PhoenixDriver
  • connection-url - The URL need to match the HBase zookeeper quorum server, the format like jdbc:phoenix [ :<zookeeper quorum> [ :<port number> ] [ :<root node> ] ], 'jdbc:phoenix:127.0.0.1:2181' is a example
  • user-name/password - The user credentials for Phoenix Connection

Mapping Phoenix table to an existing HBase table

Mapping Phoenix table to an existing HBase table has 2 steps, the first step is installing phoenix-[version]-server.jar to the classpath of every HBase region server,an easy way to do this is to copy it into the HBase lib, more details please refer to phoenix document.

The second step is executing the DDL to map Phoenix table to an existing HBase table, the DDL can either be executed via Phoenix Command Line, or executed by JDBC.

The Following is a example for mapping an existing HBase table, assume the Customer table, assume the Customer table is existing in HBase, it looks as below:

Row Key customer sales
ROW_ID name city product amount
101 John White Los Angeles, CA Chairs $400.00
102 Jane Brown Atlanta, GA Lamps $200.00
103 Bill Green Pittsburgh, PA Desk $500.00
104 Jack Black St. Louis, MO Bed $1,600.00

As depicted above, HBase Customer table have 2 column families, customer and sales, each has 2 column qualifiers, name, city, product and amount correspondingly. We can map this Table to Phoenix via DDL:

CREATE TABLE IF NOT EXISTS "Customer"("ROW_ID" VARCHAR PRIMARY KEY, "customer"."city" VARCHAR, "customer"."name" VARCHAR, "sales"."amount" VARCHAR, "sales"."product" VARCHAR)

For more about mapping Phoenix table to an existing HBase table please refer to phoenix document.

Creating Phoenix table

For creating Phoenix table just like mapping to an existing HBase table, Phoenix will create any metadata (table, column families) that doesn’t exist. As above example, if Customer doesn't exist, the DDL

CREATE TABLE IF NOT EXISTS "Customer"("ROW_ID" VARCHAR PRIMARY KEY, "customer"."city" VARCHAR, "customer"."name" VARCHAR, "sales"."amount" VARCHAR, "sales"."product" VARCHAR)

will create Customer table in HBase.

Stop watching space | Change email notification preferences
View Online | View Changes | Add Comment