hbase-ops

An operations and troubleshooting skillset for Apache HBase 2.4.x, covering cluster deployment and configuration, Region and node management, HBCK2 repairs, performance tuning, backup and recovery, replication management, monitoring and alerts, log analysis, capacity planning, and common fault handling. Suitable for operators for routine inspection and incident response.

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "hbase-ops" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-3b39f42b8424a1dda1e1294c3749dba35c337f4c6956a276b4c766cbeecbc892. Verify the upstream source and version against https://skillhub.cn/skills/user_2b964043/hbase-ops before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

An operations and troubleshooting skillset for Apache HBase 2.4.x, covering cluster deployment and configuration, Region and node management, HBCK2 repairs, performance tuning, backup and recovery, replication management, monitoring and alerts, log analysis, capacity planning, and common fault handling. Suitable for operators for routine inspection and incident response.

0 Downloads

Introduction source: third_party · user_2b964043 · 1.0.0 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Inputs and outputs
```
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: hbase-ops
description: >
  Apache HBase 2.4.x 运维排障综合技能。涵盖:集群部署配置、Region管理、节点管理、
  HBCK2修复、性能调优、备份恢复、复制管理、监控告警、日志分析、容量规划、
  常见故障处理(Region卡住、Master初始化失败、meta表损坏、写WAL超时、GC问题等)。
  适用于HBase 2.4.x版本,运维人员排障、日常巡检、集群变更等场景。
metadata:
  version: "2.4.12"
  category: database-ops
  hbase-version: "2.4.x"

HBase 运维排障技能

本技能基于 Apache HBase 2.4.x 官方文档、HBCK2 工具文档及社区最佳实践,提供 HBase 集群运维排障的完整指南。

1. 基础信息

1.1 关键端口

组件 端口
HMaster Web UI 16010
HRegionServer Web UI 16030
HMaster RPC 16000
HRegionServer RPC 16020

1.2 重要配置文件

文件 说明
conf/hbase-site.xml 主配置文件
conf/hbase-env.sh 环境变量(JAVA_HOME, JVM参数等)
conf/regionservers RegionServer主机列表
conf/backup-masters 备Master主机列表
conf/log4j2.properties 日志配置

1.3 关键目录

路径 说明
hbase.rootdir HBase数据目录(HDFS上)
hbase.zookeeper.property.dataDir ZooKeeper数据目录
/hbase/MasterProcWALs/ Master Procedure WAL目录
/hbase/WALs/ RegionServer WAL目录
/hbase/oldWALs/ 已归档WAL目录
/hbase/data/ 表数据目录

2. 核心运维命令

2.1 hbase shell 常用运维命令

# 连接HBase Shell
${HBASE_HOME}/bin/hbase shell

# 查看集群状态
hbase> status 'detailed'
hbase> status 'simple'
hbase> status 'replication'

# 表操作
hbase> list
hbase> describe 'table_name'
hbase> disable 'table_name'
hbase> enable 'table_name'
hbase> drop 'table_name'
hbase> exists 'table_name'

# Region操作
hbase> locate_region 'table_name', 'rowkey'
hbase> move 'encoded_region_name', 'server_name'
hbase> assign 'encoded_region_name'
hbase> unassign 'encoded_region_name'
hbase> split 'table_name', 'split_key'
hbase> merge_region 'encoded_region_name1', 'encoded_region_name2'
hbase> balancer
hbase> balancer_enabled
hbase> balance_switch true/false
hbase> normalize

# 集群管理
hbase> is_enabled 'table_name'
hbase> list_regions_in_transition
hbase> list_locks
hbase> list_procedures
hbase> list_deadservers
hbase> get_balancer_decisions
hbase> get_split_decisions
hbase> get_merge_decisions

# 元数据查询
hbase> scan 'hbase:meta', {COLUMN => 'info:state'}
hbase> scan 'hbase:meta', {ROWPREFIXFILTER => 'table_name,', COLUMN => 'info:state'}
hbase> get 'hbase:meta', 'table_name,row_key'
hbase> get 'hbase:meta', 'table_name', 'table:state'

2.2 region 状态码

状态 说明
OFFLINE Region离线
OPENING Region正在打开
OPEN Region已打开(正常)
CLOSING Region正在关闭
CLOSED Region已关闭
SPLITTING Region正在分裂
SPLIT Region已分裂
FAILED_OPEN Region打开失败
FAILED_CLOSE Region关闭失败
MERGING Region正在合并
MERGED Region已合并
SPLITTING_NEW 分裂出的新Region
MERGING_NEW 合并出的新Region
ABNORMALLY_CLOSED Region异常关闭

2.3 hbtop 命令行监控

# 启动hbtop
${HBASE_HOME}/bin/hbase hbtop

# 常用模式
hbtop> m  # 切换模式(RegionServer/Namespace/Table/Region)
hbtop> s  # 排序
hbtop> f  # 过滤
hbtop> d  # 刷新间隔
hbtop> q  # 退出

2.4 canary 工具

# 集群级检查
${HBASE_HOME}/bin/hbase canary -f false -t 600000

# 指定表检查
${HBASE_HOME}/bin/hbase canary table_name

# 仅检查region可用性
${HBASE_HOME}/bin/hbase canary -f false -t 600000 2>&1 | grep ERROR

2.5 HBCK2 修复工具

# 运行HBCK2
${HBASE_HOME}/bin/hbase --config /etc/hbase-conf hbck \
  -j ~/hbase-hbck2-1.0.0-SNAPSHOT.jar

# options
-d, --debug                                    # debug输出
-h, --help                                     # 帮助
-p, --hbase.zookeeper.property.clientPort      # ZK端口
-q, --hbase.zookeeper.quorum                   # ZK集群
-s, --skip                                     # 跳过版本检查
-v, --version                                  # 版本
-z, --zookeeper.znode.parent                   # ZK父节点

3. HBCK2 命令详解

3.1 assigns — 强制分配Region

HBCK2 assigns [OPTIONS] [<ENCODED_REGIONNAME>...|-i <INPUT_FILE>...]
  -o, --override     覆盖其他procedures
  -i, --inputFiles   从文件读取region列表
  -b, --batchSize    批量处理数量

# 强制分配hbase:meta region (编码名称: 1588230740)
HBCK2 -skip assigns 1588230740

# 分配用户表region
HBCK2 assigns de00010733901a05f5a2a3a382e27dd4

3.2 unassigns — 强制卸载Region

HBCK2 unassigns [<ENCODED_REGIONNAME>...]
  -o, --override     覆盖其他procedures
  -i, --inputFiles   从文件读取region列表
  -b, --batchSize    批量处理数量

3.3 bypass — 跳过卡住Procedure

HBCK2 bypass [OPTIONS] [<PID>...]
  -o, --override     覆盖正在运行的procedure
  -r, --recursive    跳过父procedure及其子procedure(慢! 危险!)
  -w, --lockWait     等待锁的时间(毫秒,默认1)
  -b, --batchSize    批量处理数量

# 跳过指定PID
HBCK2 bypass 123 456 789

# 递归跳过父PID及其子PID
HBCK2 bypass -r 123

3.4 addFsRegionsInMeta/region — META内重建Region

HBCK2 addFsRegionsMissingInMeta [OPTIONS] [<NAMESPACE|NAMESPACE:TABLENAME>...]
  -i, --inputFiles   输入文件
  -o, --outputFile   输出文件
  -n, --numLines     每文件行数

# 修复丢失region的表
HBCK2 addFsRegionsMissingInMeta default:tbl_1 n1:tbl_2 n2
# 输出assigns命令,保存后在Master重启后运行

3.5 reportMissingRegionsInMeta — 报告缺失Region

HBCK2 reportMissingRegionsInMeta [<NAMESPACE|NAMESPACE:TABLENAME>...]
  -i, --inputFiles   输入文件

3.6 extraRegionsInMeta — 清理多余Region

HBCK2 extraRegionsInMeta [<NAMESPACE|NAMESPACE:TABLENAME>...]
  -f, --fix   从meta中删除多余region
  -i, --inputFiles   输入文件

3.7 fileSystem — 文件系统检查与修复

HBCK2 filesystem [OPTIONS] [<TABLENAME>...]
  -f, --fix   隔离损坏的hfiles/bad links/references
  -i, --inputFiles   输入文件

3.8 fixMeta — 服务端修复META表

HBCK2 fixMeta
# 修复hbase:meta中的洞、重叠等不一致
# 需HBase 2.2.1+ / 2.1.6+
# 先确保Master UI的HBCK Report中有问题报告

3.9 setRegionState — 强制设置Region状态

# WARNING: 极其危险,仅作为最后手段
HBCK2 setRegionState <ENCODED_REGIONNAME> <STATE>
# 设置从region时: setRegionState <PRIMARY_ENCODED_REGIONNAME>,<replicaId> <STATE>

# 示例:将卡住的region设置为CLOSING
HBCK2 setRegionState de00010733901a05f5a2a3a382e27dd4 CLOSING

3.10 setTableState — 强制设置表状态

HBCK2 setTableState <TABLENAME> <STATE>
# STATE: ENABLED, DISABLED, DISABLING, ENABLING

# 示例
HBCK2 setTableState users ENABLED

3.11 scheduleRecoveries — 调度ServerCrashProcedure

# 为已宕机但未被识别的RegionServer创建SCP
HBCK2 scheduleRecoveries <HOSTNAME>,<PORT>,<STARTCODE>
# 示例
HBCK2 scheduleRecoveries a.example.org,29100,1540348649479

3.12 replication — 复制队列清理

HBCK2 replication [OPTIONS] [<TABLENAME>...]
  -f, --fix  修复复制问题

3.13 regionInfoMismatch — 修复RegionInfo不一致

# 检查/report 因HBASE-23328导致的encoded name不一致
# 先不加-f查看报告
HBCK2 regionInfoMismatch
# 确认后再修复
HBCK2 regionInfoMismatch -f

3.14 generateMissingTableDescriptorFile — 生成缺失的TableInfo文件

# 为orphan表生成缺失的.tableinfo文件
HBCK2 generateMissingTableDescriptorFile [<TABLENAME>...]

4. 常见故障排查与处理

4.1 Master启动卡住

现象: Master无法完成初始化

WARN HMaster: hbase:meta,,1.1588230740 is NOT online; state={...state=CLOSING...}

处理步骤:

  1. 使用HBCK2注入hbase:meta分配
    HBCK2 -skip assigns 1588230740
  2. 如果是hbase:namespace同样卡住:
    # 获取namespace的encoded region name(从Master日志中查找)
    HBCK2 -skip assigns <namespace_encoded_name>
  3. 检查Master日志确认分配完成

4.2 META表损坏

现象: region丢失、表不可访问

第一步: 在线修复(推荐)

  1. 检查meta是否可读:
    echo "scan 'hbase:meta', {COLUMN => 'info:regioninfo'}" | hbase shell
  2. 使用reportMissingRegionsInMeta检查缺失
  3. 使用addFsRegionsMissingInMeta添加缺失region
  4. 重启Master(版本<2.3.0)
  5. 运行输出的assigns命令

第二步: 离线重建(catastrophic)

  1. 停止集群
  2. 运行OfflineMetaRepair:
    HBASE_CLASSPATH_PREFIX=./hbase-hbck2-1.0.0-SNAPSHOT.jar \
      ${HBASE_HOME}/bin/hbase org.apache.hbase.hbck1.OfflineMetaRepair -details
  3. 启动集群(预期namespace卡住)
  4. 使用HBCK2注入namespace region assign
  5. 在shell中启用表

4.3 Procedure卡住

现象: Region无法分配/卸载,Master日志中看不到进度

排查步骤:

  1. 查看卡住的Procedure:
    echo "list_procedures" | hbase shell
    echo "list_locks" | hbase shell
  2. Master UI -> Procedures & Locks
  3. 检查MasterProcWALs目录是否增长:
    hdfs dfs -ls /hbase/MasterProcWALs/
  4. 如需强制跳过:
    HBCK2 bypass <PID>
  5. 极端情况:可清空MasterProcWALs(最后手段)
    hdfs dfs -mv /hbase/MasterProcWALs /hbase/MasterProcWALs.bak
    # 重启Master后,需手动处理所有RIT

4.4 Region卡在OPENING/CLOSING

现象: 表处于ENABLED但region不在OPEN状态

处理步骤:

  1. 确认表状态
  2. 查找非OPEN region:
    echo "scan 'hbase:meta', {ROWPREFIXFILTER => 'table_name,', COLUMN => 'info:state'}" | hbase shell
  3. 强制卸载后重新分配:
    HBCK2 unassigns -o <encoded_region_name>
    # 等待
    HBCK2 assigns <encoded_region_name>
  4. 如果unassigns无法执行,强制设置状态:
    HBCK2 setRegionState <encoded_region_name> CLOSED
    HBCK2 assigns <encoded_region_name>

4.5 Write/Ap pen WAL超时

现象: 写入慢,日志出现WAL超时

排查:

  1. 检查HDFS状况(NameNode HA状态、DataNode健康)
  2. 检查磁盘IO(RegionServer和DataNode)
  3. 检查网络延迟
  4. 调整参数:
    • hbase.wal.regiongrouping.numgroups
    • hbase.wal.async.writer.thread.count
    • hbase.wal.sync.timeout.msec

4.6 GC问题

现象: RegionServer频繁GC暂停,请求超时

排查:

  1. 确认GC配置(hbase-env.sh)
  2. 检查GC日志
  3. 调整参数:
    • memstore大小: hbase.regionserver.global.memstore.size
    • block cache: hfile.block.cache.size
    • 吞吐控制: hbase.ipc.server.max.callqueue.length
  4. 建议JVM配置:
    export HBASE_REGIONSERVER_OPTS="-Xmx32g -Xms32g -Xmn4g \
      -XX:+UseG1GC -XX:MaxGCPauseMillis=100 \
      -XX:ParallelGCThreads=20 -XX:ConcGCThreads=5 \
      -XX:InitiatingHeapOccupancyPercent=35"

4.7 RegionServer宕机后恢复慢

排查:

  1. 检查WAL拆分进度(日志中"Splitting WAL")
  2. 确认HDFS是否健康
  3. 调优WAL拆分:
    • hbase.master.splitlog.workers
    • hbase.master.max.preassign.region
    • hbase.regionserver.wal.split.log.read.batch.size

4.8 磁盘空间不足

处理:

  1. 检查HDFS使用率
  2. 检查WAL目录和归档:
    hdfs dfs -count -q /hbase/WALs
    hdfs dfs -count -q /hbase/oldWALs
    hdfs dfs -count -q /hbase/archive
  3. 清理归档:
    # hbase shell中
    hbase> cleaner_chore_run
  4. 调优TTL(表级别):
    hbase> alter 'table_name', {NAME => 'cf', TTL => '864000'}
  5. hbase.archived.logs.ttl(默认1小时)

4.9 复制延迟

排查:

  1. 检查复制源和目的端状态:
    hbase> status 'replication'
  2. 检查复制队列:
    hbase> list_peers
    hbase> list_replicated_tables
  3. 处理堆积的复制队列(源RS宕机后):
    HBCK2 replication -f

4.10 Region分裂/合并失败

排查:

  1. 检查Master日志中split/merge相关报错
  2. 确认HDFS有足够空间
  3. 检查region大小:
    hbase> regioninfo 'table_name', 'region_name'
  4. 调整参数:
    • hbase.hregion.max.filesize (默认10G)
    • hbase.regionserver.region.split.policy

5. 性能调优

5.1 关键配置参数

<!-- memstore 配置 -->
<property>
  <name>hbase.regionserver.global.memstore.size</name>
  <value>0.4</value>
</property>
<property>
  <name>hbase.regionserver.global.memstore.size.lower.limit</name>
  <value>0.38</value>
</property>

<!-- block cache 配置 -->
<property>
  <name>hfile.block.cache.size</name>
  <value>0.4</value>
</property>

<!-- flush 配置 -->
<property>
  <name>hbase.hregion.memstore.flush.size</name>
  <value>134217728</value>  <!-- 128M -->
</property>
<property>
  <name>hbase.hregion.memstore.block.multiplier</name>
  <value>4</value>
</property>

<!-- compaction 配置 -->
<property>
  <name>hbase.hregion.compacting.memstore.type</name>
  <value>BASIC</value>
</property>
<property>
  <name>hbase.hstore.compactionThreshold</name>
  <value>3</value>
</property>
<property>
  <name>hbase.hstore.compaction.max.size</name>
  <value>10995116277760</value>  <!-- 10G -->
</property>

<!-- handler 配置 -->
<property>
  <name>hbase.regionserver.handler.count</name>
  <value>30</value>
</property>

<!-- bucket cache (off-heap) -->
<property>
  <name>hbase.bucketcache.ioengine</name>
  <value>offheap</value>
</property>
<property>
  <name>hbase.bucketcache.size</name>
  <value>8192</value>  <!-- MB -->
</property>

5.2 JVM调优

# Master JVM
export HBASE_MASTER_OPTS="-Xmx16g -Xms16g -Xmn2g \
  -XX:+UseG1GC -XX:MaxGCPauseMillis=50 \
  -XX:ParallelGCThreads=10 -XX:ConcGCThreads=4"

# RegionServer JVM(一般32-64G)
export HBASE_REGIONSERVER_OPTS="-Xmx32g -Xms32g -Xmn4g \
  -XX:+UseG1GC -XX:MaxGCPauseMillis=100 \
  -XX:ParallelGCThreads=20 -XX:ConcGCThreads=5 \
  -XX:InitiatingHeapOccupancyPercent=35 \
  -verbose:gc -Xloggc:/var/log/hbase/gc.log \
  -XX:+PrintGCDetails -XX:+PrintGCDateStamps"

6. 备份与恢复

6.1 快照操作

# 创建快照(表不必须disabled)
hbase> snapshot 'table_name', 'snapshot_name'

# 查看快照
hbase> list_snapshots

# 从快照恢复
hbase> clone_snapshot 'snapshot_name', 'new_table_name'

# 还原快照(表必须disabled)
hbase> disable 'table_name'
hbase> restore_snapshot 'snapshot_name'
hbase> enable 'table_name'

# 删除快照
hbase> delete_snapshot 'snapshot_name'

# 导出快照到另一个集群
${HBASE_HOME}/bin/hbase snapshot export \
  --snapshot-name snapshot_name \
  --copy-to hdfs://target-cluster:8020/hbase \
  --bandwidth 50

6.2 导出/导入

# 导出表到HDFS
${HBASE_HOME}/bin/hbase org.apache.hadoop.hbase.mapreduce.Export \
  table_name /path/to/export

# 从HDFS导入
${HBASE_HOME}/bin/hbase org.apache.hadoop.hbase.mapreduce.Import \
  table_name /path/to/export

7. 容量规划

7.1 估算公式

指标 估算方式
Region数 每个RS建议20-200个region
单Region大小 hbase.hregion.max.filesize(默认10G)
每RS打开文件数 (StoreFiles per CF) x (regions per RS)
ulimit -n 至少10240
Memstore 约堆内存的40%
Block Cache 约堆内存的40%

7.2 RS内存规划

Total Heap = Memstore + BlockCache + Other
Memstore = heap * hbase.regionserver.global.memstore.size (默认0.4)
BlockCache = heap * hfile.block.cache.size (默认0.4)
Other = heap * 0.2

8. 监控指标

8.1 关键Metric

指标 说明 重要级别
regionCount Region数 高
storeFileCount StoreFile数 高
memstoreSize Memstore大小 高
storeFileIndexSize StoreFile索引大小 中
compactionQueueLength Compaction队列长度 高
flushQueueLength Flush队列长度 高
blockedUpdates 阻塞的更新数(memstore满) 高
regionSplit Region分裂计数 中
replicationSource.shippedKBs 复制源发流量 中
replicationSink.ageOfLastShippedOp 复制延迟 高

8.2 日志位置

日志 路径(默认)
Master日志 ${HBASE_HOME}/logs/hbase-huser-master-*.log
RegionServer日志 ${HBASE_HOME}/logs/hbase-huser-regionserver-*.log
GC日志 配置在hbase-env.sh
历史日志 ${HBASE_HOME}/logs/ 下归档

9. 参考资料

Current listing version

1.0.0

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value85/100

Highlights

  • 提供完整的 HBase 2.4.x 运维排障指南,涵盖集群部署、Region管理、HBCK2修复、性能调优、备份恢复等核心运维场景
  • 面向运维人员的实际生产需求,实用性强,受众广泛
Trigger Precision95/100

Highlights

  • description 明确描述适用场景和版本范围,触发词精准完整,边界清晰
Structure and Standards80/100

Areas to improve

  • 文档过长 Reported severity: Minor

    文档内容超过500行,可能影响阅读体验

    Recommendation: 建议适当拆分或增加目录导航以提升可读性

Highlights

  • 结构清晰,分章节涵盖基础信息、核心命令、故障排查、性能调优等
  • 提供详细的命令示例和配置参数说明
Execution Reliability90/100

Highlights

  • 所有命令均基于官方文档和社区最佳实践,工具来源明确
  • 覆盖了常见故障场景的处理步骤,参数说明清晰,可靠性高
Evidence Verifiability (mean of the first four)88/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

Domains or addresses referenced in the document

These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.

  • github.com
  • hbase.apache.org
  • issues.apache.org

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.