h1. Phoenix Data Sources |
h1. Configuring a Phoenix data source in JBoss/WildFly (JBoss AS 7.x or later) |
|
Configuring a Phoenix data source is nearly identical to configuring [TEIID:JDBC Data Sources]. The first step is deploying the Phoenix driver jar. Use the following command using the CLI to deploy Phoenix driver: |
|
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 h1. Configuring a Phoenix data source in JBoss/WildFly (later than JBoss AS 7) Configuring a Phoenix data source is nearly identical configuring a [TEIID:JDBC Data Sources], first step is deploying the Phoenix driver jar, the following command using the CLI to deploy Phoenix driver |
{code} deploy /path/to/phoenix-[version]-client.jar |
... |
The Driver jar can be download from [phoenix document.|http://phoenix.apache.org/] |
The second steps is creating the Data Source base on above deployed driver, which is also like creating [JDBC Data Source|TEIID:JDBC Data Sources]. Execute the following CLI command: |
|
The second steps is creating the Data Source base on above deployed driver, also like creating [JDBC Data Source|TEIID:JDBC Data Sources], execute the following CLI command: |
{code} /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}) {code} |
Please make sure the URL, Driver, and other properties are configured correctly: |
* jndi-name - The JNDI name need to match the JNDI name you used in VDB |
... |
h1. 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|http://phoenix.apache.org/download.html]. |
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 - for more details please refer to the [phoenix documentation|http://phoenix.apache.org/download.html]. |
|
The second step is executing the DDL to map a Phoenix table to an existing HBase table, the 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: |
The Following is a example for mapping an existing HBase Customer with the following structure: |
| Row Key | customer | sales | | ROW_ID | name | city | product | amount | |
... |
|
As depicted above, the HBase _Customer_ table have 2 column families, _customer_ and _sales_, and each has 2 column qualifiers, _name_, _city_, _product_ and _amount_ correspondingly. respectively. We can map this Table to Phoenix via 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} |
For more about mapping Phoenix table to an existing HBase table please refer to the [phoenix documentation|http://phoenix.apache.org/faq.html#How_I_map_Phoenix_table_to_an_existing_HBase_table]. |
|
h1. Creating A New 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 |
Creating a new Phoenix table is just like mapping to an existing HBase table. Phoenix will create any metadata (table, column families) that do not exist. Similar to the above example the DDL to create the Phoenix/HBase Customer table would be: |
{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. |
Configuring a Phoenix data source is nearly identical to configuring JDBC Data Sources. The first step is deploying the Phoenix driver jar. Use 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, which is 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, and other properties are configured correctly:
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 - for more details please refer to the phoenix documentation.
The second step is executing the DDL to map a 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 Customer with the following structure:
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, the HBase Customer table have 2 column families, customer and sales, and each has 2 column qualifiers, name, city, product and amount respectively. 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 the phoenix documentation.
Creating a new Phoenix table is just like mapping to an existing HBase table. Phoenix will create any metadata (table, column families) that do not exist. Similar to the above example the DDL to create the Phoenix/HBase Customer table would be:
CREATE TABLE IF NOT EXISTS "Customer"("ROW_ID" VARCHAR PRIMARY KEY, "customer"."city" VARCHAR, "customer"."name" VARCHAR, "sales"."amount" VARCHAR, "sales"."product" VARCHAR)