在 CentOS 上升级 HBase 一般分为:准备 → 停止服务 → 备份 → 替换软件 → 升级元数据 → 验证。下面给你一套通用、稳妥的升级步骤(以 tarball 安装为例,适用于大多数生产环境)。
hbase version
或
cat $HBASE_HOME/lib/hbase-common-*.jar | grep -a "Version"
HBase 升级必须参考官方文档:
⚠️ 大版本升级(如 1.x → 2.x)必须看官方 Upgrade Notes
官方文档:
https://hbase.apache.org/book.html#upgrading
$HBASE_HOME/bin/stop-hbase.sh
确认已完全停止:
jps | grep HMaster
jps | grep HRegionServer
hdfs dfs -mkdir /hbase-backup-$(date +%F)
hdfs dfs -cp /hbase /hbase-backup-$(date +%F)/hbase
cp -r $HBASE_HOME/conf /opt/hbase-conf-backup
hbase shell
snapshot 'table_name', 'snapshot_20250101'
cd /opt
wget https://archive.apache.org/dist/hbase/2.5.8/hbase-2.5.8-bin.tar.gz
tar -zxvf hbase-2.5.8-bin.tar.gz
例如旧版本是:
/opt/hbase-2.4.0
新版本:
/opt/hbase-2.5.8
不要直接覆盖 conf 目录,手动合并:
cp /opt/hbase-conf-backup/hbase-site.xml /opt/hbase-2.5.8/conf/
cp /opt/hbase-conf-backup/hbase-env.sh /opt/hbase-2.5.8/conf/
cp /opt/hbase-conf-backup/regionservers /opt/hbase-2.5.8/conf/
⚠️ 注意:
hbase-site.xml 是否有废弃参数vi /etc/profile
修改:
export HBASE_HOME=/opt/hbase-2.5.8
使生效:
source /etc/profile
$HBASE_HOME/bin/start-hbase.sh
hbase upgrade
或(旧版本):
hbase hbck -fixMeta
hbase shell
status
hbase version
检查日志:
tail -f $HBASE_HOME/logs/hbase-*.log
hbase upgradestop-hbase.sh
hdfs dfs -rm -r /hbase
hdfs dfs -cp /hbase-backup-20250101/hbase /hbase
恢复旧 HBASE_HOME 并启动。
如果你能告诉我:
我可以给你精确到命令的升级方案。