About Phoenix Introduction and installation deployment use

Source: Internet
Author: User
Tags psql centos
This article is based on centos6.x + cdh5.x
What is Phoenix Phoenix's team summed up Phoenix in a nutshell: "We put the SQL back in NoSQL" means: We put SQL into NoSQL again. The nosql here refers to HBase, which means that you can query hbase with SQL statements, and you might say, "Hive and Impala are OK." ”。 But Hive and Impala can also query text files, and Phoenix's feature is that it can only find hbase, and no other type is supported. But also because of this exclusive attitude, Phoenix in HBase to query the performance of more than Hive and Impala.
The components before the installation of Phoenix were installed through CDH, but this time it was completely irrelevant to Cloudera. Download Phoenix package from Apache Phoenix Download, but this image is a bit slow, I upload the package to csdn, download address see the following version of the corresponding
Phoenix with HBase version corresponds to Phoenix 2.x-hbase 0.94.x Phoenix 3.x-hbase 0.94.x download address Phoenix 4.x-hbase 0.98.1+ download address official website Download address
Here I use 4.2.2, download good, unzip open, copy Phoenix-4.2.2-server.jar to all regionserver Lib directory/usr/lib/hbase/lib

CP phoenix-4.2.2-server.jar/usr/lib/hbase/lib Copy Code
Then restart all Regionserver

Service hbase-regionserver Restart Copy code

Use Phoenix to extract the phoenix-4.2.2-bin.tar.gz Phoenix-4.2.2-bin folder is also uploaded to Host1, and then to the Bin directory execution (in fact, in this machine can also, It's just that I have no Python environment on this machine and CentOS is inherently python.
If it is downloaded under Windows, you must first assign execute permissions to the. py file in the Bin folder on CentOS


[Root@host1 ~]# CD phoenix-4.2.2-bin/
[Root@host1 phoenix-4.2.2-bin]# CD Bin
[Root@host1 bin]# chmod +x *.py Copy Code

Phoenix can be called in 4 different ways
Batch mode command line mode GUI mode JDBC call

Batch mode we build SQL named Us_population.sql content is


CREATE TABLE IF not EXISTS us_population (the state CHAR (2) is not NULL, the city VARCHAR is not null, population BIGINT CONSTRAINT MY_PK PRIMARY KEY (state, city)); Copy Code

Create a file Us_population.csv
Ny,new york,8143197
Ca,los angeles,3844829
il,chicago,2842518
tx,houston,2016582
pa,philadelphia,1463281
az,phoenix,1461575
Tx,san antonio,1256509
Ca,san diego,1255540
tx,dallas,1213825
Ca,san jose,912332 Copy Code

Create a second file Us_population_queries.sql
Select state as ' state ', Count (city) as ' City Count ', sum (population) as "population sum" from us_population GROUP by state ORDER by sum (population) DESC; Copy the code and execute it together
phoenix-4.2.2-bin/bin/psql.py host1,host2:2181 us_population.sql us_population.csv us_population_queries.sql Copy Code

Here, remember to replace Host1 and host2 with your zookeeper address.
This command you do at the same time create a table, insert data, query results three things

[Root@host1 ~]# phoenix-4.2.2-bin/bin/psql.py host1,host2:2181 us_population.sql us_population.csv us_population_ Queries.sql
15/03/04 17:14:23 WARN util. nativecodeloader:unable to load Native-hadoop library for your platform ... using Builtin-java classes where applicable
15/03/04 17:14:24 WARN Impl. Metricsconfig:cannot Locate configuration:tried hadoop-metrics2-phoenix.properties,hadoop-metrics2.properties
No rows upserted
time:0.726 sec (s)

CSV columns from database.
CSV Upsert complete. Rows upserted
time:0.103 sec (s)

St City Count Population Sum
-- ---------------------------------------- ----------------------------------------
NY 1 8143197
CA 3 6012701
TX 3 4486916
IL 1 2842518
PA 1 1463281
AZ 1 1461575
time:0.048 sec (s) copy code with HBase shell, you'll find a us_population table, and use the Scan command to see the table's data.
HBase (main):002:0> scan ' us_population '
ROW Column+cell
Azphoenix column=0:population, timestamp=1425460467206, value=\x80\x00\x00\x00\x00\x 16MG
Azphoenix column=0:_0, timestamp=1425460467206, value=

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.