当前位置: 首页 > wzjs >正文

单机网页制作网站搜索优化公司

单机网页制作,网站搜索优化公司,建设网站的合同,鞍山在网络做推广要点 掌握HBase的命名空间namespace概念 掌握HBase数据版本确界 掌握HBase数据TTL 1. HBase的namespace 1.1 namespace基本介绍 在HBase中,namespace命名空间指对一组表的逻辑分组,类似RDBMS中的database,方便对表在业务上划分。Apache…

要点

  1. 掌握HBase的命名空间namespace概念

  2. 掌握HBase数据版本确界

  3. 掌握HBase数据TTL

1. HBase的namespace

1.1 namespace基本介绍

  • 在HBase中,namespace命名空间指对一组表的逻辑分组,类似RDBMS中的database,方便对表在业务上划分。
  • Apache HBase从0.98.0, 0.95.2两个版本号开始支持namespace级别的授权操作,HBase全局管理员能够创建、改动和回收namespace的授权。

1.2 namespace的作用

  • 配额管理:限制一个namespace可以使用的资源,包括region和table

  • 命名空间安全管理:提供了另一个层面的多租户安全管理

  • Region服务器组:一个命名或一张表,可以被固定到一组RegionServers上,从而保证了数据隔离性

1.3 namespace的基本操作

创建namespace
hbase>create_namespace 'nametest'  查看namespace
hbase>describe_namespace 'nametest'  列出所有namespace
hbase>list_namespace  在namespace下创建表
hbase>create 'nametest:testtable', 'fm1' 查看namespace下的表
hbase>list_namespace_tables 'nametest'  删除namespace
hbase>drop_namespace 'nametest'  

2. HBase的数据版本的确界以及TTL

2.1 数据的确界

  • 在HBase当中,我们可以为数据设置上界和下界,其实就是定义数据的历史版本保留多少个,通过自定义历史版本保存的数量,我们可以实现数据多个历史版本的数据查询

  • 版本的下界

    • 默认的版本下界是0,即禁用。row版本使用的最小数目是与生存时间(TTL Time To Live)相结合的,并且我们根据实际需求可以有0或更多的版本,使用0,即只有1个版本的值写入cell。
  • 版本的上界

    • 之前默认的版本上界是3,也就是一个row保留3个副本(基于时间戳的插入)。
    • 该值不要设计的过大,一般的业务不会超过100。如果cell中存储的数据版本号超过了3个,再次插入数据时,最新的值会将最老的值覆盖。(现版本已默认为1)

2.2 数据的TTL

  • 在实际工作当中经常会遇到有些数据过了一段时间我们可能就不需要了,那么这时候我们可以使用定时任务去定时的删除这些数据

  • 或者我们也可以使用Hbase的TTL(Time To Live)功能,让我们的数据定期的会进行清除

  • 使用代码来设置数据的确界以及设置数据的TTL如下

2.2.1 创建maven工程

  • 创建maven工程,导入jar包坐标
<repositories><repository><id>cloudera</id><url>https://repository.cloudera.com/artifactory/cloudera-repos/</url></repository>
</repositories><dependencies><dependency><groupId>org.apache.hadoop</groupId><artifactId>hadoop-client</artifactId><version>2.6.0-mr1-cdh5.14.2</version></dependency><dependency><groupId>org.apache.hbase</groupId><artifactId>hbase-client</artifactId><version>1.2.0-cdh5.14.2</version></dependency><dependency><groupId>org.apache.hbase</groupId><artifactId>hbase-server</artifactId><version>1.2.0-cdh5.14.2</version></dependency><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.12</version><scope>test</scope></dependency><dependency><groupId>org.testng</groupId><artifactId>testng</artifactId><version>6.14.3</version><scope>test</scope></dependency>
</dependencies><build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.0</version><configuration><source>1.8</source><target>1.8</target><encoding>UTF-8</encoding><!--    <verbal>true</verbal>--></configuration></plugin><!--将我们其他用到的一些jar包全部都打包进来  --><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-shade-plugin</artifactId><version>2.4.3</version><executions><execution><phase>package</phase><goals><goal>shade</goal></goals><configuration><minimizeJar>false</minimizeJar></configuration></execution></executions></plugin></plugins>
</build>

2.2.2 代码开发

public class HBaseVersionAndTTL {public static void main(String[] args) throws IOException, InterruptedException {Configuration configuration = HBaseConfiguration.create();configuration.set("hbase.zookeeper.quorum","node01,node02,node03");Connection connection = ConnectionFactory.createConnection();Admin admin = connection.getAdmin();if(!admin.tableExists(TableName.valueOf("version_hbase"))){HTableDescriptor hTableDescriptor = new HTableDescriptor(TableName.valueOf("version_hbase"));HColumnDescriptor f1 = new HColumnDescriptor("f1");f1.setMinVersions(3);f1.setMaxVersions(5);//针对某一个列族下面所有的列设置TTLf1.setTimeToLive(30);hTableDescriptor.addFamily(f1);admin.createTable(hTableDescriptor);}Table version_hbase = connection.getTable(TableName.valueOf("version_hbase"));Put put = new Put("1".getBytes());//针对某一条具体的数据设置TTL//put.setTTL(3000);put.addColumn("f1".getBytes(),"name".getBytes(),System.currentTimeMillis(),"zhangsan".getBytes());version_hbase.put(put);Thread.sleep(1000);Put put2 = new Put("1".getBytes());put2.addColumn("f1".getBytes(),"name".getBytes(),System.currentTimeMillis(),"zhangsan2".getBytes());version_hbase.put(put2);Get get = new Get("1".getBytes());get.setMaxVersions();Result result = version_hbase.get(get);Cell[] cells = result.rawCells();for (Cell cell : cells) {System.out.println(Bytes.toString(CellUtil.cloneValue(cell)));}version_hbase.close();connection.close();}
}
http://www.dtcms.com/wzjs/220803.html

相关文章:

  • 网站的中英文切换怎么做的百度搜索提交入口
  • 配置 tomcat 做网站网站制作公司哪家好
  • 网站制作视频教程下载百度云优化网站seo公司
  • 武汉电力职业技术学院seo外包大型公司
  • 谁有网站推荐一下好站长推广网
  • 昆明淘宝网站建设网络营销心得体会1000字
  • php java做网站悟空建站seo服务
  • 网站做用户记录表大连seo外包平台
  • 做系统去哪个网站好刷百度关键词排名
  • 网站建设后台 手工上传海淀seo搜索引擎优化公司
  • 网站做百度推广划算吗北京网站seo服务
  • dede的网站地图要怎么做做网站哪个平台好
  • 需要网站建设百度快照是什么意思?
  • 北京商城网站开发公司百度搜索引擎的优缺点
  • 网站怎样做链接关键词抓取工具都有哪些
  • 梅州网站建设求职简历南京seo整站优化技术
  • wordpress.com vip江苏seo排名
  • 有什么好的书写网站品牌网站建设解决方案
  • wordpress手机版主题模板下载seo数据优化
  • 网站系统建设需要什么资质bittorrentkitty磁力猫
  • 广州云脑网站建设如何成为百度广告代理商
  • 龙华公司网站建设新冠病毒最新消息
  • 分享信息的网站seo门户网站建设方案
  • 网站的术语成都电脑培训班零基础
  • 网站建设学什么语音最新发布的最新
  • 此网站在美国进行维护百度快速优化排名软件
  • 维护一个网站要多少钱万网注册域名查询
  • 做网站需要学习哪些诊断网站seo现状的方法
  • 政府门户网站建设思路项目推广方案怎么写
  • 外部链接对网站的影响好推建站