Apache Phoenix

Apache Phoenix is a SQL skin on top of HBase. Using Apache phoenix you are use HBase for OTLP operations (for example, serve HBase as a backend for a web application) . It supports RDBMS like schema design, secondary index, CRUD, and experimental atomic transactions across multiple tables.

In this article, let me explain how to get started with Phoenix.

Set JAVA_HOME to JDK 1.8

Download hbase binary

$ wget https://www.apache.org/dyn/closer.lua/hbase/2.1.1/hbase-2.1.1-bin.tar.gz
$ tar xf hbase-2.1.1-bin.tar.gz
$ export HBASE_HOME=$(pwd)/hbase-2.1.0 

Download phoenix binary and copy necessary jars to $HBASE_HOME/lib

$ wget http://www.apache.org/dyn/closer.lua/phoenix/apache-phoenix-5.0.0-HBase-2.0/bin/apache-phoenix-5.0.0-HBase-2.0-bin.tar.gz
$ tar xf apache-phoenix-5.0.0-HBase-2.0-bin.tar.gz
$ cp phoenix-5.0.0-HBase-2.0-server.jar $HBASE_HOME/lib
$ cp phoenix-core-5.0.0-HBase-2.0.jar $HBASE_HOME/lib


$ $HBASE_HOME/bin/start-hbase.sh

To verify that phoenix-5.0.0-HBase-2.0-server.jar and phoenix-core-5.0.0-HBase-2.0.jar are loaded to the HBase server, open jconsole and connect the JVM service.

Open SQL workbench and configure a new driver for phoenix-5.0.0-HBase-2.0-client.jar.

Now using the driver create a connection.

Test the connection and click OK. Run the following commands.

      state CHAR(2) NOT NULL,
      city VARCHAR NOT NULL,
      population BIGINT
      CONSTRAINT my_pk PRIMARY KEY (state, city));
upsert into us_population values ('NY','New York',8143197); 
-- phoenix does not support traditional insert
-- upsert = insert/update

select * from us_population;