HBase 在线删除oldWAL释放磁盘空间

HBase的WAL日志会从WAL转移到oldWAL目录,oldWAL可以通过参数来设置保留时效,如以下截图是将oldWAL设置为7天,通过配置hbase.master.logcleaner.ttl指定,这可能会导致磁盘空间占用较大。如果在线上环境碰到磁盘空间占用很大的情况时,可以考虑根据日期条件来删除部分oldWAL日志。(如果是直接删除oldWAL目录下面的所有文件,可能会因为当前正在有WAL移动的动作而导致RegioniServer宕机)
请添加图片描述
通过以下步骤来实现按日期来删除oldWAL文件:

  1. 切换到hdfs用户
su - hdfs
  1. 检查是否是想删除的旧日期的文件列表
hdfs dfs -ls /hbase/oldWALs | grep 2022-07-2[2-3]  <-- 列出包含日期字段的完整文件属性列表
hdfs dfs -ls /hbase/oldWALs | grep 2022-07-2[2-3] | awk '{print $8}' <-- 只输出对应日期内的oldWAL文件名列表
  1. 执行删除操作
hdfs dfs -ls /hbase/oldWALs | grep 2022-07-2[2-3] | awk '{print $8}' | xargs hdfs dfs -rm -skipTrash
  1. 运行检查hdfs健康情况
hdfs fsck /
..............................Status: HEALTHY
Total size:    1202147250905 B (Total open files size: 415 B)
Total dirs:    88969
Total files:   147730
Total symlinks:                0 (Files currently being written: 6)
Total blocks (validated):      139316 (avg. block size 8628924 B) (Total open file blocks (not validated): 5)
Minimally replicated blocks:   139316 (100.0 %)
Over-replicated blocks:        0 (0.0 %)
Under-replicated blocks:       0 (0.0 %)
Mis-replicated blocks:         0 (0.0 %)
Default replication factor:    3
Average block replication:     3.0
Corrupt blocks:                0
Missing replicas:              0 (0.0 %)
Number of data-nodes:          4
Number of racks:               1
FSCK ended at Sun Jul 24 11:43:03 CST 2022 in 1421 milliseconds
The filesystem under path '/' is HEALTHY
  1. 运行hbase hbck检查
hbase hbck
Number of Tables: 3176
22/07/24 12:06:53 INFO util.HBaseFsck: Loading region directories from HDFS
....................................
22/07/24 12:06:57 INFO util.HBaseFsck: Loading region information from HDFS
..........................................
22/07/24 12:07:07 INFO zookeeper.RecoverableZooKeeper: Process identifier=hconnection-0x46591e98 connecting to ZooKeeper ensemble=esggk01.esgyncn.local:2181,esggk04.esgyncn.local:2181,esggk05.esgyncn.local:2181
22/07/24 12:07:07 INFO zookeeper.ZooKeeper: Initiating client connection, connectString=esggk01.esgyncn.local:2181,esggk04.esgyncn.local:2181,esggk05.esgyncn.local:2181 sessionTimeout=90000 watcher=hconnection-0x46591e980x0, quorum=esggk01.esgyncn.local:2181,esggk04.esgyncn.local:2181,esggk05.esgyncn.local:2181, baseZNode=/hbase
22/07/24 12:07:07 INFO zookeeper.ClientCnxn: Opening socket connection to server esggk05.esgyncn.local/10.11.40.45:2181. Will not attempt to authenticate using SASL (unknown error)
22/07/24 12:07:07 INFO zookeeper.ClientCnxn: Socket connection established, initiating session, client: /10.11.40.42:53664, server: esggk05.esgyncn.local/10.11.40.45:2181
22/07/24 12:07:07 INFO zookeeper.ClientCnxn: Session establishment complete on server esggk05.esgyncn.local/10.11.40.45:2181, sessionid = 0xff821f58ad583f3e, negotiated timeout = 90000
22/07/24 12:07:07 INFO client.ConnectionManager$HConnectionImplementation: Closing zookeeper sessionid=0xff821f58ad583f3e
22/07/24 12:07:07 INFO zookeeper.ZooKeeper: Session: 0xff821f58ad583f3e closed
22/07/24 12:07:07 INFO zookeeper.ClientCnxn: EventThread shut down
22/07/24 12:07:07 INFO util.HBaseFsck: Checking and fixing region consistency
22/07/24 12:07:11 INFO util.HBaseFsck: Handling overlap merges in parallel. set hbasefsck.overlap.merge.parallel to false to run serially.
22/07/24 12:07:11 INFO util.HBaseFsck: Computing mapping of all store files
..................................................
22/07/24 12:07:15 INFO util.HBaseFsck: Validating mapping using HDFS state
22/07/24 12:07:16 INFO Configuration.deprecation: fs.default.name is deprecated. Instead, use fs.defaultFS
22/07/24 12:07:16 INFO replication.ReplicationPeersZKImpl: Added new peer cluster=esggk10.esgyncn.local,esggk11.esgyncn.local,esggk08.esgyncn.local:2181:/hbase
Summary:
Table TRAFODION.LTTSV7.KCEP_PZJBEI_IDX2 is okay.
    Number of regions: 1
..................此处省略其他表输出.....................
Table TRAF_RSRVD_1:TRAFODION._PRIVMGR_MD_.SCHEMA_PRIVILEGES is okay.
    Number of regions: 1
    Deployed on:  esggk02.esgyncn.local,60020,1658383339653
0 inconsistencies detected.
Status: OK
22/07/24 12:07:16 INFO zookeeper.ZooKeeper: Session: 0xff821f58acfc3eb2 closed
22/07/24 12:07:16 INFO zookeeper.ClientCnxn: EventThread shut down
22/07/24 12:07:16 INFO client.ConnectionManager$HConnectionImplementation: Closing master protocol: MasterService
22/07/24 12:07:16 INFO client.ConnectionManager$HConnectionImplementation: Closing zookeeper sessionid=0xff821f58ad583f3b
22/07/24 12:07:16 INFO zookeeper.ZooKeeper: Session: 0xff821f58ad583f3b closed
22/07/24 12:07:16 INFO zookeeper.ClientCnxn: EventThread shut down
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

数据源的港湾

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值