[BigData] HBase 集成 Phoenix SQL 查询引擎

来源:互联网 发布:软件测试周末班 编辑:程序博客网 时间:2024/05/22 05:31

一、背景介绍

         HBase 默认不支持SQL语句查询,而且仅提供了针对RowKey的快速检索,不支持二级索引,这严重限制了HBase的应用场景。

         Phoenix 在 HBase 之上构筑了一套 SQL 引擎,实现了二级检索,使查询不再受限于RowKey的单一维度。

         通过建立索引,Phoenix 能够实现大数据快速检索,测试验证1亿条数据的带 where 条件检索能够在1秒内得到响应。

二、HBase 集成 Phoenix

   2.1 下载与 HBase 版本对应的 Phoenix

         下载地址:http://mirrors.hust.edu.cn/apache/phoenix/

          

   2.2  解压 Phoenix 软件包,将 phoenix-4.12.0-HBase-x.x-server.jar 复制到 HBase 的 Lib 文件夹下

          

   2.3  配置 HBase 配置文件 hbase-site.xml,添加如下内容(超时时间可以根据自己需要修改):         

  <property>    <name>zookeeper.session.timeout</name>    <value>3600000</value>  </property>  <property>    <name>hbase.rpc.timeout</name>    <value>3600000</value>  </property>  <property>    <name>hbase.client.operation.timeout</name>    <value>3600000</value>  </property>  <property>    <name>hbase.client.scanner.timeout.period</name>    <value>3600000</value>  </property>  <property>    <name>phoenix.query.keepAliveMs</name>    <value>3600000</value>  </property>  <property>    <name>phoenix.query.timeoutMs</name>    <value>3600000</value>  </property>  <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>    <description>Factory to create the Phoenix RPC Scheduler that uses separate queues for index and metadata updates</description>  </property>  <property>    <name>hbase.rpc.controllerfactory.class</name>    <value>org.apache.hadoop.hbase.ipc.controller.ServerRpcControllerFactory</value>    <description>Factory to create the Phoenix RPC Scheduler that uses separate queues for index and metadata updates</description>  </property>
   2.4  配置环境变量,修改 /etc/profile,增加如下内容:

  export HBASE_CONF_DIR=${你的HBase配置文件路径}
   2.5  执行 SQL 查询,进入 Phoenix 安装目录下的 bin 目录,执行 sqlline.py ${你的HBsae使用的Zookeeper地址,如zk-0:2181}

          

    好了,Phoenix 至此已经集成进 HBase了,更多使用方法请参照官网:http://phoenix.apache.org/language/

          

                 

原创粉丝点击