hbase表的多版本读写
TTL(Time To Live)生存期
hbase表默认保存一个版本的数据
hbase(main):123:0> create 't_name','st1'
Created table t_name
Took 1.3807 seconds
=> Hbase::Table - t_name
hbase(main):124:0> desc 't_name'
Table t_name is ENABLED
t_name
COLUMN FAMILIES DESCRIPTION
{NAME => 'st1', VERSIONS => '1', EVICT_BLOCKS_ON_CLOSE => 'false', NEW_VERSION_BEHAVIOR => 'false', KEEP_DELETED_CELLS => 'FALSE', CACHE_DATA_ON_WRITE => 'false', DATA_BLOCK_ENC
ODING => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', REPLICATION_SCOPE => '0', BLOOMFILTER => 'ROW', CACHE_INDEX_ON_WRITE => 'false', IN_MEMORY => 'false', CACHE_BLOOMS_ON_WR
ITE => 'false', PREFETCH_BLOCKS_ON_OPEN => 'false', COMPRESSION => 'NONE', BLOCKCACHE => 'true', BLOCKSIZE => '65536'}
1 row(s)
Took 0.0310 seconds
添加一个列族
hbase(main):126:0> alter 't_name',{NAME=>'st2'}
Updating all regions with the new schema...
All regions updated.
Done.
Took 1.5367 seconds
hbase(main):127:0> desc 't_name'
Table t_name is DISABLED
t_name
COLUMN FAMILIES DESCRIPTION
{NAME => 'st1', VERSIONS => '1', EVICT_BLOCKS_ON_CLOSE => 'false', NEW_VERSION_BEHAVIOR => 'false', KEEP_DELETED_CELLS => 'FALSE', CACHE_DATA_ON_WRITE => 'false', DATA_BLOCK_ENC
ODING => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', REPLICATION_SCOPE => '0', BLOOMFILTER => 'ROW', CACHE_INDEX_ON_WRITE => 'false', IN_MEMORY => 'false', CACHE_BLOOMS_ON_WR
ITE => 'false', PREFETCH_BLOCKS_ON_OPEN => 'false', COMPRESSION => 'NONE', BLOCKCACHE => 'true', BLOCKSIZE => '65536'}
{NAME => 'st2', VERSIONS => '1', EVICT_BLOCKS_ON_CLOSE => 'false', NEW_VERSION_BEHAVIOR => 'false', KEEP_DELETED_CELLS => 'FALSE', CACHE_DATA_ON_WRITE => 'false', DATA_BLOCK_ENC
ODING => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', REPLICATION_SCOPE => '0', BLOOMFILTER => 'ROW', CACHE_INDEX_ON_WRITE => 'false', IN_MEMORY => 'false', CACHE_BLOOMS_ON_WR
ITE => 'false', PREFETCH_BLOCKS_ON_OPEN => 'false', COMPRESSION => 'NONE', BLOCKCACHE => 'true', BLOCKSIZE => '65536'}
2 row(s)
Took 0.0147 seconds
修改版本数:
hbase(main):151:0> alter 't_name',{NAME=>'st1'},{NAME=>'st1',VERSIONS=>5}
Updating all regions with the new schema...
1/1 regions updated.
Done.
Took 3.6029 seconds
插入数据:
hbase(main):128:0> enable 't_name'
Took 1.2686 seconds
hbase(main):129:0> put 't_name','1','st1:name','xiaoma'
Took 0.0060 seconds
hbase(main):146:0> put 't_name','1','st1:age','30'
Took 0.0024 seconds
hbase(main):155:0> put 't_name','1','st1:age',100
Took 0.0028 seconds
hbase(main):157:0> put 't_name','1','st1:age',88
Took 0.0022 seconds
同一单元写入3次,查询:
hbase(main):158:0> scan 't_name'
ROW COLUMN+CELL
1 column=st1:age, timestamp=1526971520170, value=88
1 column=st1:name, timestamp=1526971227081, value=xiaoma
1 column=st2:level, timestamp=1526971286607, value=50
1 row(s)
Took 0.0042 seconds
hbase(main):173:0> get 't_name','1'
COLUMN CELL
st1:age timestamp=1526971520170, value=88
st1:name timestamp=1526971227081, value=xiaoma
st2:level timestamp=1526971286607, value=50
1 row(s)
Took 0.0037 seconds
发现查询结果为最后一次写入的值
查看历史版本:
hbase(main):174:0> get 't_name',1,{COLUMN=>'st1:age',VERSIONS=>1}
COLUMN CELL
st1:age timestamp=1526971520170, value=88
1 row(s)
Took 0.0055 seconds
hbase(main):175:0> get 't_name',1,{COLUMN=>'st1:age',VERSIONS=>2}
COLUMN CELL
st1:age timestamp=1526971520170, value=88
st1:age timestamp=1526971419514, value=100
1 row(s)
Took 0.0032 seconds
hbase(main):176:0> get 't_name',1,{COLUMN=>'st1:age',VERSIONS=>3}
COLUMN CELL
st1:age timestamp=1526971520170, value=88
st1:age timestamp=1526971419514, value=100
st1:age timestamp=1526971266685, value=30
1 row(s)
Took 0.0044 seconds
hbase(main):193:0> get 't_name','1',{COLUMN=> 'st1:age',TIMERANGE => [1526971266685,1526971520170] ,VERSIONS => 4}
COLUMN CELL
st1:age timestamp=1526971419514, value=100
st1:age timestamp=1526971266685, value=30
1 row(s)
Took 0.0039 seconds
hbase(main):194:0> get 't_name','1',{COLUMN=>'st1:age',TIMESTAMP=>1526971419514,VERSIONS=>4}
COLUMN CELL
st1:age timestamp=1526971419514, value=100
1 row(s)
Took 0.0028 seconds
hbase表的多版本读写的更多相关文章
- hbase操作(shell 命令,如建表,清空表,增删改查)以及 hbase表存储结构和原理
两篇讲的不错文章 http://www.cnblogs.com/nexiyi/p/hbase_shell.html http://blog.csdn.net/u010967382/article/de ...
- 【Hbase学习之四】Hbase表设计案例
环境 虚拟机:VMware 10 Linux版本:CentOS-6.5-x86_64 客户端:Xshell4 FTP:Xftp4 jdk8 hadoop-2.6.5 hbase-0.98.12.1-h ...
- Hadoop HBase概念学习系列之HBase表的一些设置(强烈推荐好好领悟)(十三)
压缩格式:默认压缩格式是NONE.可选值有GZ.LZO.SNAPPY. 版本数:HBase默认定义为3个版本. 以秒为单位的存活时间TTL:使用对象是行中的列簇,一旦达到过期时间,HBase会删除这些 ...
- HBase表的备份
HBase表备份其实就是先将Table导出,再导入两个过程. 导出过程 //hbase org.apache.hadoop.hbase.mapreduce.Driver export 表名 数据文件位 ...
- pinpoint 修改hbase表TTL值
操作步骤 查找出数据大的hbase表 root@990fb5560f64:/opt/hbase/hbase-# ls CHANGES.txt LICENSE.txt README.txt conf h ...
- 数据分页处理系列之二:HBase表数据分页处理
HBase是Hadoop大数据生态技术圈中的一项关键技术,是一种用于分布式存储大数据的列式数据库,关于HBase更加详细的介绍和技术细节,朋友们可以在网络上进行搜寻,笔者本人在接下来的日子里也会写 ...
- 4 hbase表结构 + hbase集群架构及表存储机制
本博文的主要内容有 .hbase读取数据过程 .HBase表结构 .附带PPT http://hbase.apache.org/ 读写的时候,就需要用hbase了,换句话说,就是读写的时候. ...
- hadoop执行hdfs文件到hbase表插入操作(xjl456852原创)
本例中需要将hdfs上的文本文件,解析后插入到hbase的表中. 本例用到的hadoop版本2.7.2 hbase版本1.2.2 hbase的表如下: create 'ns2:user', 'info ...
- HBase表创建、删除、清空
HBase shell窗口进入 执行命令hbase shell HBase表的创建 # 语法:create <table>, {NAME => <family>, VER ...
随机推荐
- hdu1081 DP类最大子段和(二维压缩+前缀和数组/树状数组计数)
题意:给出一个 n * n 的数字矩阵,问最大子矩阵和是多少. 由于和最长子段和问题类似,一开始想到的就是 DP ,一开始我准备用两个循环进行 DP ,对于每一个 (i,j) ,考察(i - 1,j) ...
- List<Map<String, Integer>> 同key的value全部累加合并
public static void main(String[] args){ List<Map<String,Object>> list1 = new ArrayList&l ...
- jquery,从后台查数据,给页面上添加树形。
前台jquery+ajax请求往页面上添加树形的js代码 //传入当前点击节点的id,在后台代码查询出parentid=当前节点id的记录数,从而实现点击当前节点,往后台发送ajax请求,查询出子节点 ...
- struts2访问ServletAPI方式和获取参数的方式
一.访问ServletAPI的三种方式 方式1:通过让Action类去实现感知接口. 此时项目依赖:servlet-api.jar. ServletRequestAware:感知HttpServlet ...
- web 分享代码片段
<div class="bshare-custom icon-medium-plus"><a title="分享到QQ空间" class=&q ...
- VisualSVN安装配置与使用
VisualSVN安装配置与使用 1. 所选服务器安装包:VisualSVN-Server-2.1.3.msi. 2. 客户端安装包:TortoiseSVN-1.6.2.16344-win32-s ...
- JS 得细心的坑位
<script> function test(link) { link = link || 'none'; alert(link); } function test2(){ var lin ...
- commonJS规范基本结构
commonJS规范:使用 module.exports 和 require ,基本结构如下: // foo.js 输出模块 module.exports = function(x) { consol ...
- vmware 安装 ios 苹果系统
我用的系统是win10... 一.所需软件: 1.下载并安装VMware Workstation Pro 12 密码:7ybc和序列号 密码是:bwm0 2.下载unlocker 203(for OS ...
- Bluez相关的各种tools的使用
7.1 Bccmd Bccmd是用来和CSR的芯片进行BCCMD(Bluecore command protocol)通讯的一个工具.BCCMD并非蓝牙协议栈的标准,而是CSR芯片的专属 ...