简介
HBase是一个基于HDFS的、分布式的、面向列(列族)的非关系型数据库(NOSQL)。
HBase的特点
1.海量数据存储,HBase表中的数据能够容纳上百亿行*上百万列。
2.面向列的存储,数据在表中是按照列进行存储的,能够动态的增加列并对列进行各种操作。
3.准实时查询,HBase在海量的数据量下能够接近准实时的查询(百毫秒以内)
4.多版本,HBase中每一列的数据都可以有多个版本。
5.可靠性,HBase中的数据存储于HDFS中且依赖于Zookeeper进行Master和RegionServer的协调管理。
HBase与关系型数据库的区别
1.HBase中的数据类型只有String,而关系型数据库中有char、varchar、int等。
2.HBase中只有普通的增删改查操作,没有表与表之间的连接、子查询等,若想要在HBase中进行复杂的操作则应该使用Phoenix。
3.HBase是基于列进行存储的,因此在查询指定列的数据时效率会很高,而关系型数据库是基于行存储,每次查询都要查询整行。
4.HBase适合海量数据存储,而关系型数据库一般一张表不超过500M,否则就要考虑分表操作。
5.HBase中为空的列不占用存储空间,表的设计可以非常稀疏,而关系型数据库中表的设计较谨密。
6.HBase不支持事务,而非关系型数据库支持事务。
7.HBase区分大小写,而SQL不区分大小写。
HBase的表结构


*HBase中的表由RowKey、ColumnFamily(列族)、Column、Timestamp组成。
Timestamp:HBase中的每个键值对都有一个时间戳,在进行插入时由HBase进行自动赋值。


架构

Master
1.处理对【表】的添加、删除、查询等操作。
2.进行RegionServer的负载均衡(Region与RegionServer的分配)
3.在RegionServer宕机后负责RegionServer上的Region转移(通过WAL日志)
*Master失效仅会导致meta数据和表无法被修改,表中的数据仍然可以进行读取和写入。
RegionServer
1.处理对【表中数据】的添加、删除、修改、查询等操作。
2.维护Region并将Region中StoreFile写入到HDFS中。
3.当Region中的数据达到一定大小时进行Region的切分。
安装



操作命令


HBase 与Hive


案例
文章表(内容表)、用户关注与粉丝表(用户关系表)、用户发布文章表(收件箱表)

参见:
HBase海量数据存储 - 辣鸡小篮子 - 博客园www.cnblogs.com

