找回密码
 注册
查看: 98|回复: 2

hadoop 清理hbase相关数据

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2025-3-11 17:00:01 | 显示全部楼层 |阅读模式
/vdata/software/hbase/bin/hbase shell                                                                                                                                                                                                                                                                                                                                                                                                                ! f( z1 g' l- A$ x& D
SLF4J: Class path contains multiple SLF4J bindings.                           
+ A0 P) p1 h/ [hbase(main):001:0> list                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
9 U6 f/ g! B6 l3 `) M5 DTABLE                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               $ b! Y6 c  E# Y3 [! T+ \. \
pinpoint:AgentEvent                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         * Y' R0 N7 J/ I# h
pinpoint:AgentInfo                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               # s9 @8 C: ^) f3 b7 L% d
pinpoint:AgentLifeCycle                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
5 z5 m0 \, O! z4 y3 C& Mpinpoint:AgentStatV2                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           / F; J! u3 F: `( a# A2 b1 t. ]6 ~
pinpoint:ApiMetaData                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
8 m2 g2 ?; H- c" {" ~pinpoint:ApplicationIndex                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        $ K8 F2 t6 `0 ~1 {. h1 D
pinpoint:ApplicationMapStatisticsCallee_Ver2                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
. B3 `2 t- m$ q: o& Fpinpoint:ApplicationMapStatisticsCaller_Ver2                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     6 _) V0 ?) \  t9 B
pinpoint:ApplicationMapStatisticsSelf_Ver2                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
& i; q8 Z  }2 X' j7 p. @1 X$ |, o2 Rpinpoint:ApplicationStatAggre                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
7 a0 T6 k8 f2 F& a) k5 B' A$ ppinpoint:ApplicationTraceIndex                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          9 v9 k8 _, P& T$ w
pinpoint:HostApplicationMap_Ver2                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       3 f' {( `# h5 A2 b, g# }5 N4 F/ {
pinpoint:SqlMetaData_Ver2                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 - c* F# t' ]) t
pinpoint:StringMetaData                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      " r; `& q: \9 p3 u% i$ L' o- ^# P4 \
pinpoint:TraceV2                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     ; }" V4 w' a( H6 h. c2 v3 n
15 row(s)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
. n/ r. P  o% X1 nTook 0.3029 seconds                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ( n5 r9 Y- U/ c( W
=> ["pinpoint:AgentEvent", "pinpoint:AgentInfo", "pinpoint:AgentLifeCycle", "pinpoint:AgentStatV2", "pinpoint:ApiMetaData", "pinpoint:ApplicationIndex", "pinpoint:ApplicationMapStatisticsCallee_Ver2", "pinpoint:ApplicationMapStatisticsCaller_Ver2", "pinpoint:ApplicationMapStatisticsSelf_Ver2", "pinpoint:ApplicationStatAggre", "pinpoint:ApplicationTraceIndex", "pinpoint:HostApplicationMap_Ver2", "pinpoint:SqlMetaData_Ver2", "pinpoint:StringMetaData", "pinpoint:TraceV2"]                                                                                                                                                                                                           3 G  j6 j, J: T
hbase(main):002:0>                                                                                                                                                                                                                                                                                                                                                                                                      * x* N5 t5 |$ f' W4 t! T
hbase(main):003:0> compact 'pinpoint:AgentStatV2'                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       4 }0 E2 o6 i3 d4 z
Took 1.0937 seconds                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  ' _$ b5 }. v1 J6 J8 h1 I
hbase(main):004:0>                          2 f7 B( |+ v4 O3 `, x$ q, f7 l5 P
hbase(main):005:0>  list_snapshots                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            ! D* g3 N$ x1 f4 J7 }7 n, A
SNAPSHOT                                         TABLE + CREATION TIME                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         " l! {& d- }. D- H6 ?5 d: s0 W- P5 K
0 row(s)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
% R: B; [/ t/ t, G/ mTook 0.0139 seconds                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
( S8 g" a" f9 w9 @=> []                                                                             
3 ~* f3 f8 a& Y) I# ^) Z4 V/ _: j4 o* x6 Y
  u# k; h" R$ B8 c! _

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2025-3-11 17:00:02 | 显示全部楼层
[devops@hadoop1 data]$ pwd                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
# `& e( }  I' w! D/vdata/software/hbase/hbase_data/archive/data                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ( E& C/ R, X0 r- q- [
[devops@hadoop1 data]$ cd ..                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    2 |( k9 t1 F2 [+ L' a
[devops@hadoop1 archive]$ cd ..                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 , [$ J# L! ]" f5 X) [! R( p0 g
[devops@hadoop1 hbase_data]$ cd ..                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              $ W1 L$ x5 i2 Y$ \5 I% f
[devops@hadoop1 hbase]$ cd bin/                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 , R, `- {5 F0 @6 c
[devops@hadoop1 bin]$ ls                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ; W4 C2 h6 Q' B3 n1 b6 F
considerAsDead.sh     hbase             hbase-config.cmd  hbase-jruby             master-backup.sh  replication               start-hbase.sh            test                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    / {, P+ Z8 i7 ]5 \6 k- ~
draining_servers.rb   hbase-cleanup.sh  hbase-config.sh   hirb.rb                 region_mover.rb   rolling-restart.sh        start-hbase-zookeeper.sh  zookeepers.sh                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           * B& z7 p$ `( W- w  E& A/ M3 d
get-active-master.rb  hbase.cmd         hbase-daemon.sh   local-master-backup.sh  regionservers.sh  shutdown_regionserver.rb  stop-hbase.cmd                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
' u. b! A3 X& k4 u1 Ggraceful_stop.sh      hbase-common.sh   hbase-daemons.sh  local-regionservers.sh  region_status.rb  start-hbase.cmd           stop-hbase.sh                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     0 Y$ _$ u6 u& }- v
[devops@hadoop1 bin]$ more hbase-                                      
2 O+ g7 T8 P7 p$ \" L
  Y' I& j; L, x" k5 L3 i. \& b! W& ~' \' D1 t, r8 |- z/ `
[devops@hadoop1 bin]$ pwd9 l. q- b3 f/ e+ B; K* t# p2 a
/vdata/software/hbase/bin
5 c& o8 o4 [- k9 U# Q9 O[devops@hadoop1 bin]$ 6 [7 w9 O- J# i9 u
4 Y& B/ j! E* r; n% m0 Z* s5 E% x8 M
9 P9 ^$ L- j, d& R

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2025-3-11 17:00:03 | 显示全部楼层
使用hbase shell . o$ z- |, q+ C" p

& C" w( b6 L5 K6 w' W& n2 m8 p& O打开终端,进入hbase shell 环境:
0 X0 o+ U3 Y, Y/ K( C9 ~; Fhbase shell
6 n" ^7 W9 |* t! V( d* L, [6 `6 s, {6 e9 Y9 c" L
进入hbase shell 之后,首先禁用表格的自动flush功能,以提高清空效率:! C( X8 J+ |  X" g0 S' l0 k/ n

5 T+ L% N$ Z1 x8 t% S8 bhbase> disable  'table_name'
6 t: }0 b2 S$ u- D2 {) l6 X( B! l; t) V6 o3 d% R0 a
hbase> alter 'table_name',{NAME => 'cf' ,METHOD => 'table_att','MAX_FILESIZE' => '0'}- U% h' P9 T$ I7 G5 k  r

7 @) c4 n# K# l! Q5 t# Y清空表格中的数据:; |5 {8 }2 L2 c' `5 C- z3 U
    hbase >truncate 'table_name'
9 |- S2 ?7 [) N& C* }
: Y, B8 Z# `6 z# \启动用表格的自动flush功能:( j( {! R# m$ P/ ^
hbase> enable  'table_name'  ' L1 _3 C  E# c% Y4 b
; K, a$ e7 X  P# u/ F

2 r7 T/ z5 ?  p1 S5 F. _- \以上就清空hbase的表格数据了。$ E& j/ l# V& {* O

" W: E. S* }' Q2 G4 H; D% j) a
您需要登录后才可以回帖 登录 | 注册

本版积分规则

返回首页|Archiver|手机版|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )

GMT+8, 2026-6-12 03:03 , Processed in 0.016487 second(s), 21 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表