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表的多版本读写的更多相关文章

  1. hbase操作(shell 命令,如建表,清空表,增删改查)以及 hbase表存储结构和原理

    两篇讲的不错文章 http://www.cnblogs.com/nexiyi/p/hbase_shell.html http://blog.csdn.net/u010967382/article/de ...

  2. 【Hbase学习之四】Hbase表设计案例

    环境 虚拟机:VMware 10 Linux版本:CentOS-6.5-x86_64 客户端:Xshell4 FTP:Xftp4 jdk8 hadoop-2.6.5 hbase-0.98.12.1-h ...

  3. Hadoop HBase概念学习系列之HBase表的一些设置(强烈推荐好好领悟)(十三)

    压缩格式:默认压缩格式是NONE.可选值有GZ.LZO.SNAPPY. 版本数:HBase默认定义为3个版本. 以秒为单位的存活时间TTL:使用对象是行中的列簇,一旦达到过期时间,HBase会删除这些 ...

  4. HBase表的备份

    HBase表备份其实就是先将Table导出,再导入两个过程. 导出过程 //hbase org.apache.hadoop.hbase.mapreduce.Driver export 表名 数据文件位 ...

  5. pinpoint 修改hbase表TTL值

    操作步骤 查找出数据大的hbase表 root@990fb5560f64:/opt/hbase/hbase-# ls CHANGES.txt LICENSE.txt README.txt conf h ...

  6. 数据分页处理系列之二:HBase表数据分页处理

      HBase是Hadoop大数据生态技术圈中的一项关键技术,是一种用于分布式存储大数据的列式数据库,关于HBase更加详细的介绍和技术细节,朋友们可以在网络上进行搜寻,笔者本人在接下来的日子里也会写 ...

  7. 4 hbase表结构 + hbase集群架构及表存储机制

      本博文的主要内容有    .hbase读取数据过程 .HBase表结构 .附带PPT http://hbase.apache.org/ 读写的时候,就需要用hbase了,换句话说,就是读写的时候. ...

  8. hadoop执行hdfs文件到hbase表插入操作(xjl456852原创)

    本例中需要将hdfs上的文本文件,解析后插入到hbase的表中. 本例用到的hadoop版本2.7.2 hbase版本1.2.2 hbase的表如下: create 'ns2:user', 'info ...

  9. HBase表创建、删除、清空

    HBase shell窗口进入 执行命令hbase shell HBase表的创建 # 语法:create <table>, {NAME => <family>, VER ...

随机推荐

  1. 强连通分量【k 算法、t 算法】

    连通分量就是一个各个顶点能互相达到的图 无向图的连通分量选取任意一个顶点使用DFS遍历即可,遍历完所有顶点所需的DFS的次数就是连通分量的数量 有向图的强连通分量由于是有向的[从A点开始DFS能访问到 ...

  2. 【多线程学习笔记整理】002_线程的停止、暂停、与yield

    一.停止线程的三种方式 停止线程是多线程中的一个很重要的点,停止线程意味着在线程处理完当前任务之前终止正在做的操作,但是如果不能正确的操作,可能会发生不可预期的结果. 1)使用退出标志,使线程正常退出 ...

  3. 【MVC】知识笔记

    MVC代表:模型-视图-控制器. Models:标识该应用程序的数据并使用验证逻辑来强制实施业务规则的数据类 Views  :应用程序动态生成HTML所使用的模版文件 Controllers:处理浏览 ...

  4. Eclipse使用前准备(转)

    Eclipse的发布流程 M1  08/19/2009      M2     09/30/2009     M3     11/11/2009     M4     12/16/2009     M ...

  5. vault 集群搭建(active standby 模式)

        参考架构图: consul server cluster 搭建 consul 基本配置格式 { "server": true, "node_name": ...

  6. stenciljs 学习九 使用jsx

    可以使用jsx 方便组件的开发 基本格式 主要是render 函数 class MyComponent { render() { return ( <div> <h1>Hell ...

  7. 【转】每天一个linux命令(48):watch命令

    原文网址:http://www.cnblogs.com/peida/archive/2012/12/31/2840241.html watch是一个非常实用的命令,基本所有的Linux发行版都带有这个 ...

  8. 【转】每天一个linux命令(38):cal 命令

    原文网址:http://www.cnblogs.com/peida/archive/2012/12/14/2817473.html cal命令可以用来显示公历(阳历)日历.公历是现在国际通用的历法,又 ...

  9. Maven的dependency type属性

    官方地址: http://maven.apache.org/ref/3.5.2/maven-model/maven.html (搜索:Some examples are jar, war, ejb-c ...

  10. protobuf生成

    1,文件路径匹配好在src/main/proto下面 https://blog.csdn.net/u010939285/article/details/78538927