phoenix php,利用phoenix进行Hbase数据访问

一、背景

近期一个用户画像的项目,数据量庞大,用MySQL进行存取不太现实,所以采用Hbase集群的方案来实施。由于业务层使用的是PHP,所以研发同学首先想到的是PHP-Thrift来访问Hbase,编码实验了几天,效果不是太理想,尤其是编码成本较大,各种scan、filter之类的语法,不利于团队进行快速开发;当然,最崩溃的还是想利用count进行数据总量计算,是Thrift里,这个太难搞。

所以再换一个phoenix的方案,模拟SQL的形式进行Hbase数据访问;不过这东西没有PHP版本的,只有Hbase的jar包支持,还有一个python版本的command line console,开发过程中用来做数据查看还是比较方便的。

二、环境部署

1、phoenix下载

2、部署jar包到Hbase集群

# 下载phoenix

wget http://apache.fayea.com/phoenix/phoenix-4.7.0-HBase-1.1/bin/phoenix-4.7.0-HBase-1.1-bin.tar.gz

# 解压

tar zxfv phoenix-4.7.0-HBase-1.1-bin.tar.gz > /dev/null

# 部署jar包到hbase

cp -r phoenix-4.7.0-HBase-1.1/*.jar /home/hbase/hbase-1.1.5/lib/

# 重启Hbase

/home/hbase/hbase-1.1.5/bin/stop-hbase.sh

/home/hbase/hbase-1.1.5/bin/start-hbase.sh

3、验证phoenix安装情况

cd /home/hbase/phoenix-4.7.0-HBase-1.1/bin

./sqlline.py localhost:2181

出现下图所示的样子,就算是安装成功了:

8cd0f8587c281208fe3feb32b4944a19.png

敲击 !help 命令,查看内置命令:

0: jdbc:phoenix:localhost:2181> !help

!all Execute the specified SQL against all the current connections

!autocommit Set autocommit mode on or off

!batch Start or execute a batch of statements

!brief Set verbose mode off

!call Execute a callable statement

!close Close the current connection to the database

!closeall Close all current open connections

!columns List all the columns for the specified table

!commit Commit the current transaction (if autocommit is off)

!connect Open a new connection to the database.

!dbinfo Give metadata information about the database

!describe Describe a table

!dropall Drop all tables in the current database

!exportedkeys List all the exported keys for the specified table

!go Select the current connection

!help Print a summary of command usage

!history Display the command history

!importedkeys List all the imported keys for the specified table

!indexes List all the indexes for the specified table

!isolation Set the transaction isolation for this connection

!list List the current connections

!manual Display the SQLLine manual

!metadata Obtain metadata information

!nativesql Show the native SQL for the specified statement

!outputformat Set the output format for displaying results

(table,vertical,csv,tsv,xmla

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值