Hbase+ Phoenix搭建教程
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安装
- 下载 我们的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
- 解压
tar -zxvf phoenix-4.3.1-bin.tar.gz
- 拷贝jar文件到HBase HMaster,和所有RegionServer的lib目录下
cp phoenix-4.3.1-bin/phoenix-4.3.1-server.jar $(HBASE_HOME)/lib
- 配置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>
- 配置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>
- 配置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
验证
按照上面的步骤配置完成后就可以进行验证了~本地验证方式如下,进行验证:
- 启动hbase集群
$(HBASE_HOME)/bin/start-hbase.sh
- 启动Phoenix SQLLine工具
$(PHOENIX_HOME)/bin/sqlline.py localhost
- 运行Phoenix Performance 工具,本地测试的话数据尽量不要超过1000w,通常1000w数据会报错。。。 如下命令,第一个参数是zk地址,第二个是性能测试的数据数量,测试数据会自动生成
$(PHOENIX_HOME)/bin/performance.py localhost1000000
- 在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
编译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搭建教程的更多相关文章
- HBase入门基础教程之单机模式与伪分布式模式安装(转)
原文链接:HBase入门基础教程 在本篇文章中,我们将介绍Hbase的单机模式安装与伪分布式的安装方式,以及通过浏览器查看Hbase的用户界面.搭建HBase伪分布式环境的前提是我们已经搭建好了Had ...
- Spring+SpringMvc+Mybatis框架集成搭建教程
一.背景 最近有很多同学由于没有过SSM(Spring+SpringMvc+Mybatis , 以下简称SSM)框架的搭建的经历,所以在自己搭建SSM框架集成的时候,出现了这样或者那样的问题,很是苦恼 ...
- 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 ...
- Windows Server 2012 R2 IIS8.5+PHP(FastCGI)+MySQL环境搭建教程
原文地址:http://www.osyunwei.com/archives/7378.html 搬运是为了自己找资料方便. 准备篇 一.环境说明: 操作系统:Windows Server 2012 R ...
- 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 ...
- 【网站搭建教程】黑手VIP卡盟搭建教程(无KEY)
黑手VIP卡盟搭建教程(无KEY)教程介绍:第一课 卡盟介绍与课程流程.exe第七课 卡盟源码的搜集与选择_.exe第三课 卡盟域名之注册.exe第九课 IIS的本机架设_.exe第二课 卡盟域名之选 ...
- LAMP环境搭建教程
原文:LAMP环境搭建教程 学习PHP脚本编程语言之前,必须先搭建并熟悉开发环境,开发环境有很多种,例如LAMP.WAMP.MAMP等.这里我介绍一下LAMP环境的搭建,即Linux.Apache.M ...
- Win2012 R2 IIS8.5+PHP(FastCGI)+MySQL运行环境搭建教程
这篇文章主要介绍了Win2012 R2 IIS8.5+PHP(FastCGI)+MySQL运行环境搭建教程,需要的朋友可以参考下 准备篇 一.环境说明: 操作系统:Windows Server 201 ...
- Win2008 R2 IIS7.5+PHP5(FastCGI)+MySQL5环境搭建教程
现在很多朋友想尝试win2008 r2来跑web服务器,跟win2003相比界面差别有点大,有些人可能不太习惯,不过以后是趋势啊,这里简单分享下,方便需要的朋友 准备篇 一.环境说明: 操作系统:Wi ...
随机推荐
- UISearchBar控件-让我们来搞定!(转)
转载自:http://blog.sina.com.cn/s/blog_7b9d64af0101dfg8.html 最近用到搜索功能.于是,经过不断的研究,终于,有点懂了. 那就来总结一下吧,好 ...
- ElasticSearch-5.0.0安装中文分词插件IK
Install IK 源码地址:https://github.com/medcl/elasticsearch-analysis-ik,git clone下来. 1.compile mvn packag ...
- pycloudtag 标签云
原创,转载请标明 QQ:231469242 # -*- coding: utf-8 -*- """Python3.0 Created on Sat Nov 26 08:5 ...
- 搭建haproxy
1:下载haproxy wget http://haproxy.1wt.eu/download/1.3/src/haproxy-1.3.20.tar.gz2:解压,编译,安装 tar zxf hapr ...
- 【09-14】eclipse学习笔记
eclipse安装class文件反编译插件jadClipse /** 1. 下载JadClipse的jar包 2. 下载Jad反编译器 3. 将JarClipse jar包放到eclipse plug ...
- Codeforces#262_1002
Codeforces#262_1002 B. Little Dima and Equation time limit per test 1 second memory limit per test 2 ...
- 还原MySql数据库失败:max_allowed_packet 设置过小导致记录写入失败
MySQL根据配置文件会限制Server接受的数据包大小. 有时候大的插入和更新会受 max_allowed_packet 参数限制,导致写入或者更新失败. 查看目前配置 show VARIABLES ...
- 深入Nginx
Nginx功能模块汇总 --with-http_core_module #包括一些核心的http参数配置,对应nginx的配置为http区块部分 --with-http_access_module # ...
- nginx配置301重定向
1. 简介 301重定向可以传递权重,相比其他重定向,只有301是最正式的,不会被搜索引擎判断为作弊 2. 栗子 savokiss.com 301到 savokiss.me 3. nginx默认配置方 ...
- ffmpeg-20160926[27]-bin.7z
ffplay 2016.09.26 开始使用 SDL 2.x , CPU 利用率比 SDL 1.x 略微好一些. ESC 退出 0 进度条开关 1 屏幕原始大小 2 屏幕1/2大小 3 屏幕1/3大小 ...