hbase 某台regionserver更换ip后出现块不同步的现象

本文介绍HBase集群中RegionServer的两种平滑重启方法:一是使用修复元数据脚本重新分配块;二是采用graceful_stop.sh脚本先迁移Region再重启,避免服务中断。同时,强调了配置修改后的重启策略及不当重启可能带来的问题。

方式一: 重新hbase集群让metedata识别新ip,使用修复元数据,重新分配块的脚本 rephbase.sh

#!/bin/bash
su - hbase <<EOF
hbase hbck -fixMeta -fixAssignments
hbase hbck -repair
hbase hbck -fixEmptyMetaCells
hbase hbck
EOF

方式二:如果一没有成功,例如出现如下错误
在这里插入图片描述
进入ambari hbase master uI 观察节点状态发现新节点ip已经存在并且数据在上面,但是旧节点的主机名也存在,块在新ip节点上,所以需要通过graceful脚本

graceful_stop.sh 命令为 在hbase/bin 下 执行此脚本 graceful_stop.sh 10.0.30.139
graceful_stop.sh脚本内容:

#!/usr/bin/env bash
#
#/**
# * Licensed to the Apache Software Foundation (ASF) under one
# * or more contributor license agreements.  See the NOTICE file
# * distributed with this work for additional information
# * regarding copyright ownership.  The ASF licenses this file
# * to you under the Apache License, Version 2.0 (the
# * "License"); you may not use this file except in compliance
# * with the License.  You may obtain a copy of the License at
# *
# *     http://www.apache.org/licenses/LICENSE-2.0
# *
# * Unless required by applicable law or agreed to in writing, software
# * distributed under the License is distributed on an "AS IS" BASIS,
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# * See the License for the specific language governing permissions and
# * limitations under the License.
# */

# Move regions off a server then stop it.  Optionally restart and reload.
# Turn off the balancer before running this script.
function usage {
   
   
  echo "Usage: graceful_stop.sh [--config <conf-dir>] [-d] [-e] [--restart [--reload]] [--thrift] [--rest] <hostname>"
  echo " thrift         If we should stop/start thrift before/after the hbase stop/start"
  echo " rest           If we should stop/start rest before/after the hbase stop/start"
  echo " restart        If we should restart after graceful stop"
  echo " reload         Move offloaded regions back on to the restarted server"
  echo " d|debug        Print helpful debug information"
  echo " maxthreads xx  Limit the number of threads used by the region mover. Default value is 1."
  echo " hostname       Hostname of server we are to stop"
  echo " e|failfast     Set -e so exit immediately if any command exits with non-zero status"
  exit 1
}

if [ $# -lt 1 ]; then
  usage
fi

bin=`dirname "$0"`
bin=`cd "$bin">/dev/null; 
<think>我们正在解决HBase启动时Master运行的问题,且之前使用jps命令查到相关进程。根据引用[1]和引用[2]的内容,我们可以总结出以下关键点: 1. HBase启动需要依赖Hadoop(HDFS)和ZooKeeper服务。如果这些服务没有正确启动,HMaster进程可能无法启动。 2. 使用jps命令查看进程时,Hadoop成功启动应该看到NameNode、DataNode和SecondaryNameNode(至少这三个基本进程),而HBase启动后应该看到HMaster和HRegionServer等进程。 3. 问题现象中还包括ZooKeeper连接问题(从ZooKeeper获取master地址失败)和Java参数警告(PermSize在Java8中已移除)。 因此,我们的解决骤应该包括: 1. 确保Hadoop服务正常启动,并且jps能够看到Hadoop的进程。 2. 确保ZooKeeper服务正常启动,并且配置正确。 3. 检查HBase的配置,特别是与ZooKeeper和Hadoop相关的配置,以及主机名配置。 4. 检查HBase的日志文件,定位启动失败的具体原因。 5. 修正Java参数警告(移除过时的JVM参数)。 下面给出详细的解决骤: </think>### 解决HBase启动时Master运行且jps查到进程的完整指南 当启动HBase时Master进程未运行且`jps`命令查到相关进程时,通常由服务依赖未启动、配置错误或端口冲突导致。以下是系统化的解决方案(基于引用[1][2]): #### 1️⃣ 验证基础服务状态 (关键骤) - **启动Hadoop服务**(引用[2]): ```bash $ ./sbin/start-dfs.sh # 启动HDFS $ jps | grep -E 'NameNode|DataNode|SecondaryNameNode' ``` 确保输出包含这三个核心进程:`NameNode`, `DataNode`, `SecondaryNameNode` - **启动ZooKeeper服务**: ```bash $ ./bin/zkServer.sh start # 启动ZooKeeper $ jps | grep QuorumPeerMain ``` 必须出现`QuorumPeerMain`进程(HBase注册依赖ZK服务)[^1] #### 2️⃣ 修复HBase配置问题 - **检查主机名一致性**: ```bash # 所有节点执行: $ hostname # 查看主机名 $ cat /etc/hosts # 检查IP-hostname映射 $ ping <master-hostname> # 测试解析 ``` 确保`hbase-site.xml`中配置一致: ```xml <property> <name>hbase.master.hostname</name> <value>master</value> <!-- 需与实际主机名一致 --> </property> ``` - **移除过时JVM参数**(引用[1]): 编辑`hbase-env.sh`: ```bash # 注释掉废弃参数 # export HBASE_MASTER_OPTS="$HBASE_MASTER_OPTS -XX:PermSize=128m" # export HBASE_REGIONSERVER_OPTS="$HBASE_REGIONSERVER_OPTS -XX:PermSize=128m" ``` #### 3️⃣ 诊断端口冲突 - **检查默认端口占用**: ```bash $ netstat -tuln | grep -E '60000|60010|60020|60030' ``` 关键端口: - `60000`: HMaster RPC - `60010`: HMaster Web UI - `60020`: RegionServer RPC - `60030`: RegionServer Web UI 若端口被占用: ```bash $ lsof -i :60000 # 查占用进程 $ kill -9 <PID> # 强制终止 ``` #### 4️⃣ 排查日志定位根源 - **查看实时日志**: ```bash $ tail -f $HBASE_HOME/logs/hbase-*-master-*.log ``` 重点关注以下错误模式: ``` ERROR [main] master.HMaster: Failed to become active master java.net.BindException: Address already in use ``` 或 ``` ERROR [main] zookeeper.RecoverableZooKeeper: ZooKeeper exists failed ``` #### 5️⃣ 强制清理残留状态 - **删除临时文件**: ```bash $ rm -rf $HBASE_HOME/tmp/* # 清除旧会话数据 $ hdfs dfs -rm -r /hbase # 删除HDFS上的HBase目录(谨慎操作!) ``` - **ZK元数据清理**: ```bash $ zkCli.sh > rmr /hbase # 在ZK shell中删除HBase根节点 ``` #### 6️⃣ 重启验证 ```bash # 启动顺序 $ ./sbin/start-dfs.sh $ ./bin/zkServer.sh start $ ./bin/start-hbase.sh # 验证进程 $ jps | grep -E 'HMaster|HRegionServer' ``` 成功时应输出: ``` HMaster HRegionServer ``` > **关键提示**:若仍失败,检查`$HBASE_HOME/conf/regionservers`文件是否包含正确的工作节点主机名,并确保所有节点时间同(NTP服务)。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值