先做个记录,监控数据量过大时可以设置表的数据过期时间来清理数据。

1. 查找本地数据表大小

[root@ZWZF-CWY-LZY-12 ~]# cd /home/pinpoint/hbase/data/default/
[root@ZWZF-CWY-LZY-12 default]# du -sh *
16K AgentEvent
64K AgentInfo
16K AgentLifeCycle
72K AgentStat
632K AgentStatV2
40K ApiMetaData
16K ApplicationIndex
72K ApplicationMapStatisticsCallee_Ver2
72K ApplicationMapStatisticsCaller_Ver2
80K ApplicationMapStatisticsSelf_Ver2
72K ApplicationTraceIndex
20K HostApplicationMap_Ver2
72K SqlMetaData_Ver2
40K StringMetaData
264K Traces
1.1M TraceV2

2. 设置表的数据过期时间

2.1  查看hbase表:list

[root@monitor default]# cd /home/pinpoint/hbase-1.7.1/bin/
[root@monitor bin]# ./hbase shell
2022-10-19 15:03:48,097 WARN [main] util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
HBase Shell
Use "help" to get list of supported commands.
Use "exit" to quit this interactive shell.
Version 1.7.1, r2d9273667e418e7023f9104a830cdcb8233b6f25, Fri Jul 16 00:20:26 PDT 2021 hbase(main):001:0>list
TABLE
AgentEvent
AgentInfo
AgentLifeCycle
AgentStatV2
ApiMetaData
ApplicationIndex
ApplicationMapStatisticsCallee_Ver2
ApplicationMapStatisticsCaller_Ver2
ApplicationMapStatisticsSelf_Ver2
ApplicationStatAggre
ApplicationTraceIndex
HostApplicationMap_Ver2
SqlMetaData_Ver2
StringMetaData
TraceV2
15 row(s) in 0.1740 seconds => ["AgentEvent", "AgentInfo", "AgentLifeCycle", "AgentStatV2", "ApiMetaData", "ApplicationIndex", "ApplicationMapStatisticsCallee_Ver2", "ApplicationMapStatisticsCaller_Ver2", "ApplicationMapStatisticsSelf_Ver2", "ApplicationStatAggre", "ApplicationTraceIndex", "HostApplicationMap_Ver2", "SqlMetaData_Ver2", "StringMetaData", "TraceV2"]

2.2 查看表描述:desc 'table_name'

hbase(main):002:0>  desc 'AgentInfo'
Table AgentInfo is ENABLED
AgentInfo
COLUMN FAMILIES DESCRIPTION
{NAME => 'Info', BLOOMFILTER => 'ROW', VERSIONS => '1', IN_MEMORY => 'false', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'PREFIX', TTL
=> '31536000 SECONDS (365 DAYS)', COMPRESSION => 'NONE', MIN_VERSIONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_SCOPE => '
0'}
1 row(s) in 0.1760 seconds

2.3 修改表信息

  将AgentInfo表的过期时间(TTL)修改为180天(TTL单位:秒)。

2.3.1 停用表:disable 'table_name'

hbase(main):003:0> disable 'AgentInfo'
0 row(s) in 2.3130 seconds

2.3.2 修改表信息:alter 'table_name' , {NAME=>'xxx',TTL=>'xxx'}

hbase(main):004:0> alter 'AgentInfo', {NAME=>'Info',TTL=>'15552000'}
Updating all regions with the new schema...
1/1 regions updated.
Done.
0 row(s) in 1.9670 seconds

2.3.3 启用表:enable 'table_name'

hbase(main):005:0> enable 'AgentInfo'
0 row(s) in 1.3030 seconds

2.3.4 查看表信息(确认修改结果)

hbase(main):006:0> desc 'AgentInfo'
Table AgentInfo is DISABLED
AgentInfo
COLUMN FAMILIES DESCRIPTION
{NAME => 'Info', BLOOMFILTER => 'ROW', VERSIONS => '1', IN_MEMORY => 'false', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'PREFIX', TTL
=> '15552000 SECONDS (180 DAYS)', COMPRESSION => 'NONE', MIN_VERSIONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_SCOPE => '
0'}
1 row(s) in 0.0310 seconds

3. 修改表过期时间后,清除过期数据:major_compact 'table_name'

  定期运行一次Major Compact(通过crontab 任务),用来删除早于给定TTL值的所有数据。

  注意:如果只设置TTL而不定期运行 major_compact,只是标记删除,并不会真正从磁盘上删除。

hbase(main):007:0> major_compact 'AgentInfo'
0 row(s) in 0.4290 seconds

pinpoint:查看hbase表和修改数据过期时间的更多相关文章

  1. 利用闪回查看Oracle表历史时刻数据

    利用闪回查看Oracle表历史时刻数据 1.查看表历史时刻数据 select * from tab_test AS OF TIMESTAMP to_timestamp('20140917 10:00: ...

  2. Oracle查看所有表空间的数据使用情况

    -- 查看所有表空间的数据使用情况 SELECT Upper(F.TABLESPACE_NAME) "表空间名", D.TOT_GROOTTE_MB "表空间大小(M)& ...

  3. mapreduce 只使用Mapper往多个hbase表中写数据

    只使用Mapper不使用reduce会大大减少mapreduce程序的运行时间. 有时候程序会往多张hbase表写数据. 所以有如题的需求. 下面给出的代码,不是可以运行的代码,只是展示driver中 ...

  4. Mapreduce读取Hbase表,写数据到多个Hbase表中

    Job端的变化: 通过设置conf,配置输出表,在reduce中获取输出表名字 Configuration conf = job.getConfiguration(); //输出表1 conf.set ...

  5. php表单修改数据

    (接前面写的) 第一个页面xiugai.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ...

  6. hbase数据导出和恢复 设置双master + 查看hbase表占用磁盘大小

    1.备份TETST111hbase org.apache.hadoop.hbase.mapreduce.Export TEST111 /do1/hh2.drop 掉test111表  -- 只能dro ...

  7. 【查看数据占用空间】查看hbase表占用的磁盘情况

    使用命令:hdfs dfs -du /apps/hbase/data/data/default/

  8. 怎么查看HBase表的创建时间

    前几天HBase出现了RIT告警,忽然发现发出告警的Region所属的表并不是我创建出来的,于是就想看看这些表是怎么来的. 一时也没什么头绪,就先看看这些表是什么时候创建出来的吧,然后再根据时间点看看 ...

  9. Mapreduce读取Hbase表,写数据到一个Hbase表中

    public class LabelJob { public static void main(String[] args) throws Exception { Job job = Job.getI ...

随机推荐

  1. 【AGC】如何快速部署Serverless Url缩短模板

    使用场景 Serverless短URL生成模板实现您将在云数据库服务中URL缩短的诉求.使用此模板后,仅需在云数据库服务侧配置长URL值.Serverless短URL生成模板会在后台与Bitly AP ...

  2. HTML <option> 标签的属性:selected ; disabled ; label ; value;

    HTML <option> 标签的属性:selected ;  disabled ; label ; value; 1. selected="selected" sel ...

  3. 面试突击78:@Autowired 和 @Resource 有什么区别?

    @Autowired 和 @Resource 都是 Spring/Spring Boot 项目中,用来进行依赖注入的注解.它们都提供了将依赖对象注入到当前对象的功能,但二者却有众多不同,并且这也是常见 ...

  4. K8S服务滚动升级

    对于Kubernetes集群来说,一个service可能有多个pod,滚动升级(Rolling update)就是指每次更新部分Pod,而不是在同一时刻将该Service下面的所有Pod shutdo ...

  5. 第三十二篇:vue的响应式原理

    好家伙 什么是响应式?比较官方的回答: Vue.js 的核心包括一套"响应式系统". "响应式",是指当数据改变后,Vue 会通知到使用该数据的代码. 例如,视 ...

  6. LSB隐写术

    此为北京理工大学某专业某学期某课程的某次作业 一.项目背景 1.隐写术 隐写术是一门关于信息隐藏的技巧与科学,所谓信息隐藏指的是不让除预期的接收者之外的任何人知晓信息的传递事件或者信息的内容. 2.L ...

  7. 使用nginx代理nexus,不是/根路径

    location /nexus/ { proxy_pass http://192.168.0.218:8081/; proxy_set_header Host $host:$server_port; ...

  8. Elasticsearch:创建 API key 接口访问 Elasticsearch

    转载自:https://blog.csdn.net/UbuntuTouch/article/details/107181440 在之前我的文章 "Elastic:使用Postman来访问El ...

  9. EasyExcel实现文件导入

    导入 准备工作 见:https://www.cnblogs.com/wywblogs/p/16095576.html 异步导入 接口代码 public Map importMemberList(@Re ...

  10. vue3的Async Components异步组件

    前言: 当我们的项目达到一定的规模时,对于某些组件来说,我们并不希望一开始全部加载,而是需要的时候进行加载:这样的做得目的可以很好的提高用户体验. 传统方式引入组件如下,这样会一次先加载所以组件 先在 ...