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. Oracle之分页查询

    select * from ( select a.*, rownum rn from (select * from table_name) a where rownum<= 40 ) where ...

  2. AOJ DSL_2_D Range Update Query (RUQ)

    Range Update Query 数列 A = {a0,a1 ,...,an−1} に対し.次の2つの操作を行うプログラムを作成せよ. update(s,t,x): as,as+1,...,at  ...

  3. Leetcode 40. Combination Sum II

    Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in ...

  4. 移动端浏览器和微信浏览器上禁止body的滚动条

    一般禁止body滚动的做法就是设置overflow:hidden. 但是很奇怪的发现在移动端浏览器和微信浏览器上这个不起作用,然后我分析了我的写法,就是在body上加了一个class去定义属性,然后改 ...

  5. js整数补零

    /* * * 整数前面补零 * * 质朴长存法 * num 要补灵的整数 * n个数,比整数位数多前面自动补零 * **/ function pad(num, n) { var len = num.t ...

  6. 20145204&20145212信息安全系统实验一报告

    信息安全系统实验报告 实验一 步骤 1.连接 arm 开发板 将 arm 开发板的电源线接好,使得开发板开关处于闭合状态.再分别将串口线.并口线和网线与 pc 机连接好. 2.建立超级终端 运行 wi ...

  7. rails 常用的知识点

    按惯例先上网址:  http://guides.ruby-china.org/    适合初学者很好的文章 ===========================知识点================ ...

  8. linux零基础入门总结

    啊,notepad++贴过来怎么对齐格式这么糟糕呢? #root用户 $普通用户   linux命令 清屏clear翻页清屏  CRT中ctrl+L    reset"清空 CRT中不起作用 ...

  9. JavaScript getComputedStyle

    我们使用 element.style 也可以获取元素的CSS样式声明对象,但是其与 getComputedStyle 方法还是有一些差异的. 首先,element.style 是可读可写的,而 get ...

  10. R语言爬虫初尝试-基于RVEST包学习

    注意:这文章是2月份写的,拉勾网早改版了,代码已经失效了,大家意思意思就好,主要看代码的使用方法吧.. 最近一直在用且有维护的另一个爬虫是KINDLE 特价书爬虫,blog地址见此: http://w ...