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
wget http://mirrors.cnnic.cn/apache/phoenix/phoenix-4.3.1/bin/phoenix-4.3.1-bin.tar.gz 
  1. 解压
tar -zxvf phoenix-4.3.1-bin.tar.gz 
  1. 拷贝jar文件到HBase HMaster,和所有RegionServer的lib目录下
cp phoenix-4.3.1-bin/phoenix-4.3.1-server.jar $(HBASE_HOME)/lib 
  1. 配置HMaster的hbase-site.xml
<!-- 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
<!-- 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中加入如下配置
# 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集群
$(HBASE_HOME)/bin/start-hbase.sh 
  1. 启动Phoenix SQLLine工具
$(PHOENIX_HOME)/bin/sqlline.py localhost 
  1. 运行Phoenix Performance 工具,本地测试的话数据尽量不要超过1000w,通常1000w数据会报错。。。 如下命令,第一个参数是zk地址,第二个是性能测试的数据数量,测试数据会自动生成
$(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. Mysql 命令大全

    1.连接Mysql 格式: mysql -h主机地址 -u用户名 -p用户密码1.连接到本机上的MYSQL.首先打开DOS窗口,然后进入目录mysql\bin,再键入命令mysql -u root - ...

  2. 运行tomcat8w.exe未安装指定的服务

    1.报错:指定的服务未安装. 2:解决方案有些写的不够详细,现在发表一遍详细操作手册 以上是解决方案备忘录

  3. js获取域名

    <script language="javascript">//获取域名host = window.location.host;host2=document.domai ...

  4. Python * 和 ** 参数问题

    Problem def calcuate(*keys) def calcluate(**keys) Slove *: 用来传递人一个无名字的参数,这些参数会以一个Tuple的形式来访问. **: 用来 ...

  5. NPOI 导出Excel

    NPOIExcel npoiexcel = new NPOIExcel(); string filename = DateTime.Now.ToString("yyyyMMddHHmmssf ...

  6. SDL绑定播放窗口 及 视频窗口缩放

    绑定播放窗口 必须在Sdl.SDL_Init之前执行 Sdl.SDL_putenv 同时SDL_SetVideoMode里播放窗口长宽不能大于绑定窗口的长宽 int i = Sdl.SDL_puten ...

  7. HashMap Hasptable的区别

    HashTable的应用非常广泛,HashMap是新框架中用来代替HashTable的类,也就是说建议使用HashMap,不要使用HashTable.可能你觉得HashTable很好用,为什么不用呢? ...

  8. 关于学习JavaScript 的 高三编程 一些心得(三)

    最近在学习高三的 过程中,遇到的了一些 难以理解的问题, 在看到第五章之前都是 OK 的.但是到了 引用类型的时候就有点蒙了. 首先我们看下,引用类型的  解释:[引用类型的值(对象)是引用类型的一个 ...

  9. mysql [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist (转载)

    mysql报错Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist 2013-11-2 ...

  10. [Recommendation System] 推荐系统之协同过滤(CF)算法详解和实现

    1 集体智慧和协同过滤 1.1 什么是集体智慧(社会计算)? 集体智慧 (Collective Intelligence) 并不是 Web2.0 时代特有的,只是在 Web2.0 时代,大家在 Web ...