HBase的日志是排查故障的核心依据,通常位于/var/log/hbase/目录下(如hbase-<username>-master-<hostname>.log、hbase-<username>-regionserver-<hostname>.log)。使用tail -f命令实时查看日志,重点关注以下关键词:
Could not bind to address(如HMaster或RegionServer端口被占用);Unable to create ZooKeeper connection(ZK地址错误或未启动);No valid filesystem found(hbase.rootdir配置的HDFS路径无法访问);OutOfMemoryError(JVM堆内存不足)。使用jps命令查看HBase关键进程是否运行:
jps | grep -E "HMaster|HRegionServer"
HMaster或HRegionServer进程,说明进程未启动或崩溃,需手动启动:${HBASE_HOME}/bin/start-hbase.sh
HBase的核心配置文件(hbase-site.xml、hbase-env.sh)需确保参数设置正确:
hbase-site.xml关键参数:
hbase.cluster.distributed:分布式模式下必须设为true;hbase.rootdir:指向HDFS的正确路径(如hdfs://namenode:9000/hbase);hbase.zookeeper.quorum:ZooKeeper集群地址(如zk1.example.com,zk2.example.com,zk3.example.com)。hbase-env.sh关键参数:
JAVA_HOME:指向正确的Java安装路径(如export JAVA_HOME=/usr/lib/jvm/default-java);HBASE_REGIONSERVER_OPTS:调整RegionServer堆内存(如-Xms4G -Xmx4G)。HBase依赖ZooKeeper和HDFS,需确保二者正常运行:
jps查看QuorumPeerMain进程是否存在;zkCli.sh连接ZooKeeper(./zkCli.sh -server localhost:2181),执行ls /确认节点数据正常。hdfs dfsadmin -report查看NameNode和DataNode状态;hbase.rootdir指向的HDFS路径存在且有写入权限(如hdfs dfs -mkdir -p /hbase/data,hdfs dfs -chown -R hbase:hbase /hbase)。free -h查看系统内存,确保HBase进程有足够的可用内存(如-Xmx设置的堆内存不超过系统总内存的70%);df -h查看HDFS和本地磁盘空间,确保/hbase/data目录所在分区有足够空间(建议剩余空间大于总容量的20%);top查看CPU使用率,避免RegionServer进程占用过高(如超过80%需优化查询或扩容)。若RegionServer无法启动,需重点检查以下方面:
hbase hbck -details查看Region是否处于FAILED_OPEN状态,若是则执行hbase hbck -fixAssignments修复;CorruptWAL错误,说明WAL日志损坏,可使用hbase hbck -fixHdfsOrphans修复;split 'regionID')。若出现写入超时或失败,需排查以下问题:
hbase shell查看Region分布(scan 'hbase:meta'),若数据集中在少数Region,需通过RowKey散列(如添加MD5前缀)或预分区(create 'table', 'cf', {NUMREGIONS => 10, SPLITALGO => 'HexStringSplit'})分散负载;hbase.hregion.memstore.flush.size(默认128MB)和hbase.regionserver.global.memstore.size(默认0.4)参数,若MemStore频繁刷写导致延迟,可适当增大阈值;针对常见的性能问题,可采取以下措施:
hbase.regionserver.thread.compaction.large=4、hbase.regionserver.thread.compaction.small=2),在业务低峰期手动触发Major Compaction(major_compact 'table');hfile.block.cache.size=0.4),提高读取命中率;rowkey = md5(user_id) + user_id)防止热点。