天天看点

pinpoint的Hbase数据库的数据优化

pinpoint的Hbase数据库的数据优化

写的原因:

因为是测试服务器,在运行测试项目时,需要日志的打印输出,由于发现磁盘空间不足,想删除些东西,释放空间,然后发现pinpoint服务的Hbase数据库占据了18G空间,其中TraceV2表占据了13G。

解决的方法:

进入Hbase数据库后,使用

desc 'TraceV2'

看了TraceV2的表结构,他的一个TTL值默认是60 DAY(这是我按照pinpoint的官方默认表结构),意思是保留60天内的记录,超出后才清理。我就寻思想把这个记录保留时间变为3 DAY。

我写了一个hbase,shell命令文本,是把这里边的表都改为3 day

bin/hbase shell test.hbase

以下是test.habse文本内容。

cat test.hbase

disable 'AgentInfo'
disable 'AgentLifeCycle'
disable 'AgentStatV2'
disable 'ApiMetaData'
disable 'ApplicationIndex'
disable 'ApplicationMapStatisticsCallee_Ver2'
disable 'ApplicationMapStatisticsCaller_Ver2'
disable 'ApplicationMapStatisticsSelf_Ver2'
disable 'ApplicationStatAggre'
disable 'ApplicationTraceIndex'
disable 'HostApplicationMap_Ver2'
disable 'SqlMetaData_Ver2'
disable 'StringMetaData'
disable 'TraceV2'


alter 'AgentEvent',{NAME => 'E',TTL => '259200'}
alter 'AgentInfo',{NAME => 'Info',TTL => '259200'}
alter 'AgentLifeCycle',{NAME => 'S',TTL => '259200'}
alter 'AgentStatV2',{NAME => 'S',TTL => '259200'}
alter 'ApiMetaData',{NAME => 'Api',TTL => '259200'}
alter 'ApplicationIndex',{NAME => 'Agents',TTL => '259200'}
alter 'ApplicationMapStatisticsCallee_Ver2',{NAME => 'C',TTL => '259200'}
alter 'ApplicationMapStatisticsCaller_Ver2',{NAME => 'C',TTL => '259200'}
alter 'ApplicationMapStatisticsSelf_Ver2',{NAME => 'C',TTL => '259200'}
alter 'ApplicationStatAggre',{NAME => 'S',TTL => '259200'}
alter 'ApplicationTraceIndex',{NAME => 'I',TTL => '259200'}
alter 'HostApplicationMap_Ver2',{NAME => 'M',TTL => '259200'}
alter 'SqlMetaData_Ver2',{NAME => 'Sql',TTL => '259200'}
alter 'StringMetaData',{NAME => 'Str',TTL => '259200'}
alter 'TraceV2',{NAME => 'S',TTL => '259200'}



enable 'AgentEvent'
enable 'AgentInfo'
enable 'AgentLifeCycle'
enable 'AgentStatV2'
enable 'ApiMetaData'
enable 'ApplicationIndex'
enable 'ApplicationMapStatisticsCallee_Ver2'
enable 'ApplicationMapStatisticsCaller_Ver2'
enable 'ApplicationMapStatisticsSelf_Ver2'
enable 'ApplicationStatAggre'
enable 'ApplicationTraceIndex'
enable 'HostApplicationMap_Ver2'
enable 'SqlMetaData_Ver2'
enable 'StringMetaData'
enable 'TraceV2'

exit
           

当执行完后,到hbase数据库目录下看到,使用du -sh *就看到表的大小正在慢慢变小

pinpoint的Hbase数据库的数据优化

这是我的,先前的占用13G变4.1G了。

过一会再看df -h 就能看到磁盘空间被释放

df -h 这个可能等的时间有点点长,因为,它在删除的时候,释放的比较慢,一般不会超出十分钟,除了你当前服务器上的负载有些高

继续阅读