Phoenix部署和使用

1. 下载phoenix

查看hbase版本:1.2.6

比对版本,下载相关的Phoenix。

http://archive.apache.org/dist/phoenix/apache-phoenix-4.14.1-HBase-1.2/bin/apache-phoenix-4.14.1-HBase-1.2-bin.tar.gz

2.

tar zxvf apache-phoenix-4.14.1-HBase-1.2-bin.tar.gz

mv apache-phoenix-4.14.1-HBase-1.2-bin phoenix

3.配置phoenix

3.1

cp phoenix-4.14.1-HBase-1.2-server.jar phoenix-core-4.14.1-HBase-1.2.jar /data/bigdata/hbase/lib/

3.2 

cp /data/bigdata/hbase/conf/hbase-site.xml bin/

增加如下几项

<property>   
      <name>hbase.regionserver.wal.codec</name>   
      <value>org.apache.hadoop.hbase.regionserver.wal.IndexedWALEditCodec</value> 
    </property>
    <property> 
      <name>hbase.region.server.rpc.scheduler.factory.class</name>
      <value>org.apache.hadoop.hbase.ipc.PhoenixRpcSchedulerFactory</value> 
    </property>

cp /data/bigdata/hadoop/etc/hadoop/core-site.xml bin/

cp /data/bigdata/hadoop/etc/hadoop/hdfs-site.xml bin/

3.3

重启hbase

cd /data/bigdata/hbase

kill掉hbase进程

bin/start-hbase.sh

4. shell执行sql

4.1 使用psql.py

4.1.1 us_population.sql

内容:

CREATE TABLE IF NOT EXISTS us_population (
"state" CHAR(2) NOT NULL,  
"city" VARCHAR(18) NOT NULL, 
"info"."population" BIGINT,
CONSTRAINT my_pk PRIMARY KEY ("state", "city")
);
upsert into "US_POPULATION"("state","city","population") values('NY','New York',8143197);  
upsert into "US_POPULATION"("state","city","population") values('CA','Los Angeles',3844829); 
upsert into "US_POPULATION"("state","city","population") values('IL','Chicago',2842518);
upsert into "US_POPULATION"("state","city","population") values('TX','Houston',2016582);
upsert into "US_POPULATION"("state","city","info"."population") values('PA','Philadelphia',1463281);  
upsert into "US_POPULATION"("state","city","info"."population") values('AZ','Phoenix',1461575);
upsert into "US_POPULATION"("state","city","info"."population") values('TX','San Antonio',1256509);  
upsert into "US_POPULATION"("state","city","info"."population") values('CA','San Diego',1255540);
upsert into "US_POPULATION"("state","city","info"."population") values('TX','Dallas',1213825);
upsert into "US_POPULATION"("state","city","info"."population") values('CA','San Jose',912332);

执行命令:

bin/psql.py 10.88.0.54 /home/glsong/us_population.sql

4.1.2 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;

执行命令:

bin/psql.py 10.88.0.54 /home/glsong/us_population_queries.sql

4.2 使用

table.sql

内容:

create table sample(id integer primary key,t1 varchar,t2 varchar);

执行命令文件 table.sh

table.sh

!#/bin/bash
cd /home/glsong/phoenix/bin
./sqlline.py 10.10.1.1:2181 /home/glsong/table.sql

执行命令:

./table.sh

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值