脚本宝典收集整理的这篇文章主要介绍了HBase 原理、Shell、API读写操作,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
2)利用Hadoop HDFS作为文件存储系统,提供高可靠性、高性能、列存储、可伸缩、实时读写、适用于非结构化数据存储的数据库系统
3)利用Hadoop Mapreduce来处理Hbase中的海量数据
4)利用ZoopkeePEr作为分布式系统服务
1)数据量大:一个表可以上亿行,上百万列(列多时,插入变慢)
2)面向列:面向列簇的存储和权限控制,列(族)独立检索
3)稀疏:对于为空(null)的列,并不占用存储空间
4)多版本:每个cell中数据有多个版本,默认版本号自动分配,是单元格插入时的时间戳
5)无类型:Hbase中的数据都是字符串,没有类型
6)强一致性:同一行数据的读写只在同一台Region Server上进行
7)有限查询方式:仅支持三种扫描方式(单个rowkey查询,通过rowkey的range查询,全表扫描)
8)高性能随机读写
1)行:同一个key对应所有数据
2)列族:相似的列数据通常被划分成一个列族
3)列:列名
4)Cell及时间戳(版本)
每个cell有任意多的版本
建表时设置每个列族可以保留多个版本
5)三维有序
SortedMap(RowKey,
List(SortedMap(Column,
List(value,Timestamp))))
rowkey(ASC)+columnLabel(ASC)+Version(DESC)->value
HRegion是负载均衡调度的最小单位,一张表被分成若干个region,行按照rowkey进行字段排序,并支持随机读写。
Client:访问HBase接口并提供Cache,加速堆Hbase得访问
HRegionServer管理多个HRegion
HRegion首先将操作写入HLOG,将数据写入MemStore里面,MemStroe达到一定阈值后,Flush到StoreFile, StoreFile达到阈值后,会Combine到HFile,写入到Hadoop集群中
Zookeeper:
1)监控HRegionServer上线与下线的状态,启动会通知HMaster
2)存储所有Region的寻址入口地址以及Hbase的table和schema元数据信息
HMaster:负责负载均衡,以及HRegionServer的HRegion分配
HRegion:管理MemStore,组合成大的StoreFile,写入到HDFS集群中
@H_304_146@
ZooKeeper找到ROOT表,ROOT记录每个region所在region server
META表记录多个region
table信息:表名,起始行,时间戳,MD5值
例如:testTabe.xyz,1279729913622.1babcdefg123483f6.
要查找一个特定的行所在的区域,只要在目录表中找到第一个键号>=给定行键的项即可
配置Hbase-env.sh
Regionserver
运行start-hbase.sh
启动hbase shell
jps
查看是否包括HMaster和HRegionServer节点
list
exit
./hadoop fs -ls /hbase默认会建立/hbase目录
create 'test','info’ //表名,列族名
put 'test','row1','info:A','1’ //row1:rowkey info:A列族 1:值
put 'test','row1','info,'2’
put 'test','row1','info:B','3’
scan 'test'
put 'test','row1','info:B','2'
scan 'test'
disable 'test' //先要disable
drop 'test'
list
configuraiton conf=new Configuration();
HBaseConfiguration hbconf=new HBaseConfiguration(conf);
HbaseAdmin admin=new HbaseAdmin(hbconf);
HTableDescriptor tableDesc=new HTableDescriptor(“test”);
tableDesc.addFamily(new HColumDescription(“info”));
admin.createTable(tableDesc);
List
Scan ‘test’
Configuraiton conf=new Configuration();
HBaseConfiguration hbconf=new HBaseConfiguration(conf);
HTable table=new HTable(hbconf,”test”);
Put put=new Put(“row1”.getBytes()); //创建rowKey
Put.add(“info”.getBytes(),”A”.getBytes(),”1”.getBytes()); //插入列族Put‘test’,’row1’,’info:B’,’2’
table.put();
table.close();
Scan ‘test’
查找数据
Configuraiton conf=new Configuration();
HBaseConfiguration hbconf=new HBaseConfiguration(conf);
HTable table=new HTable(hbconf,”test”);
Scan scan=new Scan();
ResultScanner rs=table.getScanner(scan);
for(Result r:res){
for(KeyValue kv:r.row()){
System.out.PRintln(“rowkey=>”+new String(r.getRow())
+”family=>”+new String(kv.getFamily()) 列族
+”qualfier=>”+new String(kv.getQualifier())列名
+”timestamp=>”+kv.getTimestamp()
+”value=>”+new String(kv.getValue())
);
}
}
以上是脚本宝典为你收集整理的HBase 原理、Shell、API读写操作全部内容,希望文章能够帮你解决HBase 原理、Shell、API读写操作所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。