Hbase+ Phoenix搭建教程

一、Hbase简介

HBase是基于列存储、构建在HDFS上的分布式存储系统,其主要功能是存储海量结构化数据。

HBase构建在HDFS之上,因此HBase也是通过增加廉价的PC机提高系统运行和存储的能力。

HBase中存储的表有如下特点:

1、大表:一个表可以有数十亿行,上百万列;

2、无模式:每行都有一个可排序的主键和任意多的列,列可以根据需要动态的增加,同一张表中不同的行可以有截然不同的列;

3、面向列:面向列(族)的存储和权限控制,列(族)独立检索;

4、稀疏:对于空(null)的列,并不占用存储空间,表可以设计的非常稀疏;

5、数据多版本:每个单元中的数据可以有多个版本,默认情况下版本号自动分配,是单元格插入时的时间戳;

6、数据类型单一:Hbase中的数据都是字符串,没有类型。

二、hbase的适用场景

1、存在高并发读写

2、表结构的列族经常需要调整

3、存储结构化或半结构化数据

4、高并发的key-value存储

5、key随机写入,有序存储

6、针对每个key保存一个固定大小的集合  多版本

同样hbase数据也存在不适用的场景

1、由于hbase只能提供行锁,它对分布式事务支持不好

2、对于查询操作中的join、group by 性能很差

3、查询如果不使用row-key查询,性能会很差,因为此时会进行全表扫描,建立二级索引或多级索引需要同时维护一张索引表

4、高并发的随机读支持有限

三、hbase基本架构及组件说明

由上图可知,hbase包括Clinet、HMaster、HRegionServer、ZooKeeper组件

各组件功能介绍:

1、Client

Client主要通过ZooKeeper与Hbaser和HRegionServer通信,对于管理操作:client向master发起请求,对于数据读写操作:client向regionserver发起请求

2、ZooKeeper

zk负责存储_root_表的地址,也负责存储当前服务的master地址,regsion server也会将自身的信息注册到zk中,以便master能够感知region server的状态,zk也会协调active master,也就是可以提供一个选举master leader,也会协调各个region server的容灾流程

3、HMaster

master可以启动多个master,master主要负责table和region的管理工作,响应用户对表的CRUD操作,管理region server的负载均衡,调整region 的分布和分配,当region server停机后,负责对失效的regionn进行迁移操作

4、HRegionServer

region server主要负责响应用户的IO请求,并把IO请求转换为读写HDFS的操作

二、hbase安装

参考:http://hbase.apache.org/book/quickstart.html

三、添加Phoenix支持

Phoenix安装

  1. 下载 我们的HBase版本是0.98.6-hadoop2,对应的Phoenix版本是4.3.1
  1. wget http://mirrors.cnnic.cn/apache/phoenix/phoenix-4.3.1/bin/phoenix-4.3.1-bin.tar.gz
  1. 解压
  1. tar -zxvf phoenix-4.3.1-bin.tar.gz
  1. 拷贝jar文件到HBase HMaster,和所有RegionServer的lib目录下
  1. cp phoenix-4.3.1-bin/phoenix-4.3.1-server.jar $(HBASE_HOME)/lib
  1. 配置HMaster的hbase-site.xml
  1. <!-- Phoenix订制的索引负载均衡器 --> <property> <name>hbase.master.loadbalancer.class</name> <value>org.apache.phoenix.hbase.index.balancer.IndexLoadBalancer</value> </property> <!-- Phoenix订制的索引观察者 --> <property> <name>hbase.coprocessor.master.classes</name> <value>org.apache.phoenix.hbase.index.master.IndexMasterObserver</value> </property>
  1. 配置RegionServer的hbase-site.xml
  1. <!-- Enables custom WAL edits to be written, ensuring proper writing/replay of the index updates. This codec supports the usual host of WALEdit options, most notably WALEdit compression. --> <property>  <name>hbase.regionserver.wal.codec</name>  <value>org.apache.hadoop.hbase.regionserver.wal.IndexedWALEditCodec</value> </property> <!-- Prevent deadlocks from occurring during index maintenance for global indexes (HBase 0.98.4+ and Phoenix 4.3.1+ only) by ensuring index updates are processed with a higher priority than data updates. It also prevents deadlocks by ensuring metadata rpc calls are processed with a higher priority than data rpc calls --> <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> <!-- To support local index regions merge on data regions merge you will need to add the following parameter to hbase-site.xml in all the region servers and restart. (It’s applicable for Phoenix 4.3+ versions) --> <property>  <name>hbase.coprocessor.regionserver.classes</name>  <value>org.apache.hadoop.hbase.regionserver.LocalIndexMerger</value> </property>
  1. 配置Tracing (hadoop-metrics2-hbase.properties) 在HBase的HMaster和所有RegionServer下的conf/hadoop-metrics2-hbase.properties中加入如下配置
  1. # ensure that we receive traces on the server hbase.sink.tracing.class=org.apache.phoenix.trace.PhoenixMetricsSink # Tell the sink where to write the metrics hbase.sink.tracing.writer-class=org.apache.phoenix.trace.PhoenixTableMetricsWriter # Only handle traces with a context of "tracing" hbase.sink.tracing.context=tracing

验证

按照上面的步骤配置完成后就可以进行验证了~本地验证方式如下,进行验证:

  1. 启动hbase集群
  1. $(HBASE_HOME)/bin/start-hbase.sh
  1. 启动Phoenix SQLLine工具
  1. $(PHOENIX_HOME)/bin/sqlline.py localhost
  1. 运行Phoenix Performance 工具,本地测试的话数据尽量不要超过1000w,通常1000w数据会报错。。。 如下命令,第一个参数是zk地址,第二个是性能测试的数据数量,测试数据会自动生成
  1. $(PHOENIX_HOME)/bin/performance.py localhost 1000000
  1. 在Phoenix SQLLine中进行一些查询操作,sql语法可以参考

http://phoenix.apache.org/language/index.html

备注:

http://nunknown.com/study/282/

bin/hadoop fs -ls /user/root/output3

https://hadoop.apache.org/docs/r1.0.4/cn/hdfs_shell.html

https://hadoop.apache.org/docs/r2.7.1/hadoop-project-dist/hadoop-common/SingleCluster.html#YARN_on_Single_Node

编译hadoop

http://zilongzilong.iteye.com/blog/2246856

https://segmentfault.com/a/1190000000583427#articleHeader1

http://www.ixirong.com/2015/06/24/how-hbase-use-apache-phoenix/

http://www.infoq.com/cn/news/2013/02/Phoenix-HBase-SQL

client连接使用:

http://www.cnblogs.com/laov/p/4137136.html

Hbase+ Phoenix搭建教程的更多相关文章

  1. HBase入门基础教程之单机模式与伪分布式模式安装(转)

    原文链接:HBase入门基础教程 在本篇文章中,我们将介绍Hbase的单机模式安装与伪分布式的安装方式,以及通过浏览器查看Hbase的用户界面.搭建HBase伪分布式环境的前提是我们已经搭建好了Had ...

  2. Spring+SpringMvc+Mybatis框架集成搭建教程

    一.背景 最近有很多同学由于没有过SSM(Spring+SpringMvc+Mybatis , 以下简称SSM)框架的搭建的经历,所以在自己搭建SSM框架集成的时候,出现了这样或者那样的问题,很是苦恼 ...

  3. Windows Server 2003 IIS6.0+PHP5(FastCGI)+MySQL5环境搭建教程

    准备篇 一.环境说明: 操作系统:Windows Server 2003 SP2 32位 PHP版本:php 5.3.14(我用的php 5.3.10安装版) MySQL版本:MySQL5.5.25 ...

  4. Windows Server 2012 R2 IIS8.5+PHP(FastCGI)+MySQL环境搭建教程

    原文地址:http://www.osyunwei.com/archives/7378.html 搬运是为了自己找资料方便. 准备篇 一.环境说明: 操作系统:Windows Server 2012 R ...

  5. Windows Server 2012 R2 IIS8.5+PHP(FastCGI)+MySQL环境搭建教程

    准备篇 一.环境说明: 操作系统:Windows Server 2012 R2 PHP版本:php 5.5.8 MySQL版本:MySQL5.6.15 二.相关软件下载: 1.PHP下载地址: htt ...

  6. 【网站搭建教程】黑手VIP卡盟搭建教程(无KEY)

    黑手VIP卡盟搭建教程(无KEY)教程介绍:第一课 卡盟介绍与课程流程.exe第七课 卡盟源码的搜集与选择_.exe第三课 卡盟域名之注册.exe第九课 IIS的本机架设_.exe第二课 卡盟域名之选 ...

  7. LAMP环境搭建教程

    原文:LAMP环境搭建教程 学习PHP脚本编程语言之前,必须先搭建并熟悉开发环境,开发环境有很多种,例如LAMP.WAMP.MAMP等.这里我介绍一下LAMP环境的搭建,即Linux.Apache.M ...

  8. Win2012 R2 IIS8.5+PHP(FastCGI)+MySQL运行环境搭建教程

    这篇文章主要介绍了Win2012 R2 IIS8.5+PHP(FastCGI)+MySQL运行环境搭建教程,需要的朋友可以参考下 准备篇 一.环境说明: 操作系统:Windows Server 201 ...

  9. Win2008 R2 IIS7.5+PHP5(FastCGI)+MySQL5环境搭建教程

    现在很多朋友想尝试win2008 r2来跑web服务器,跟win2003相比界面差别有点大,有些人可能不太习惯,不过以后是趋势啊,这里简单分享下,方便需要的朋友 准备篇 一.环境说明: 操作系统:Wi ...

随机推荐

  1. JS获取URL地址参数

    <script> var url = "http://127.0.0.1/index.php?old_quantity=168&date=1478309879000$id ...

  2. php 不用四舍五入的方式截取小数点后两位

    /** * 字符串截取, 默认小数点后2位 * @param $money * @param int $accuracy * @return float */ private function fil ...

  3. angular指令深度学习篇

    angular指令深度学习-过滤器 limitTo ... <body ng-app="app" > <div ng-controller="myCtr ...

  4. 【整理】认识MSG结构体

    在Windows程序中,消息是由MSG结构体来表示的.MSG结构体的定义如下(参见MSDN): typedef struct tagMSG { HWND hwnd; UINT message; WPA ...

  5. zoom在css中的作用

    zoom:1 zoom:1;属性是IE浏览器的专有属性,Firefox等其它浏览器不支持.它可以设置或检索对象的缩放比例. 兼容IE6.IE7.IE8浏览器,经常会遇到一些问题,可以使用zoom:1来 ...

  6. 【原】常用的javascript设计模式

    设计模式太多了,貌似有23种,其实我们在平时的工作中没有必要特意去用什么样的设计模式,或者你在不经意间就已经用了设计模式当中的一种.本文旨在总结平时相对来说用的比较多的设计模式. 什么是设计模式 百度 ...

  7. System类和Random类

    System类 成员方法: public static void gc():运行垃圾回收器 public static void exit(int status):退出垃圾回收器 public sta ...

  8. Echart的简单例子

    [转载自:http://echarts.baidu.com/echarts2/doc/start.html] <%@ page language="java" content ...

  9. logo

  10. Google 地图 API V3 使用入门

    Google官方教程: Google 地图 API V3 使用入门 Google 地图 API V3 针对移动设备进行开发 Google 地图 API V3 之事件 Google 地图 API V3 ...