项目hbase数据库出现很诡异的assignment ,region移动的src和dest都是同一台regionserver,不过时间戳不同,启动的只有一个regionserver, 不知道怎么出现了两个时间戳

分析下源码解决一下

loadbalance只有一个实现 org.apache.hadoop.hbase.master.DefaultLoadBalancer
在HMaster中会启动一个线程 org.apache.hadoop.hbase.Chore,按照设定的hbase.balancer.period(默认300000ms,五分钟),遍历所有表,根据每个表在regionserver中的region数量做balance,有一个平衡系数hbase.regions.slop(默认0.2),根据region总数算出平均region值,avg×0.8 取整作为最小值,avg×1.2取整作为最大值,regionserver上超过最大值要移走,小于最小值要移动region过来。否则打印目前的平衡状态。
assignmentManager 根据上述步骤生成的RegionPlan, 从src移动region到desc  src和desc都是ServerName对象
HMaster启动时会等待region servers注册到serverManager
// Wait for region servers to report in.
this.serverManager.waitForRegionServers(status);
// Check zk for regionservers that are up but didn't register
for (ServerName sn: this.regionServerTracker.getOnlineServers()) {
    if (!this.serverManager.isServerOnline(sn)) {
    // Not registered; add it.LOG.info("Registering server found up in zk but who has not yet " +"reported in: " + sn);this.serverManager.recordNewServer(sn, HServerLoad.EMPTY_HSERVERLOAD);}
}

serverManager线程sleep一定时间,等待HRegionServer注册

HRegionServer.java:

      // Try and register with the Master; tell it we are here.  Break if// server is stopped or the clusterup flag is down or hdfs went wacky.while (keepLooping()) {MapWritable w = reportForDuty();if (w == null) {LOG.warn("reportForDuty failed; sleeping and then retrying.");this.sleeper.sleep();} else {handleReportForDutyResponse(w);break;}}

HRegionServer 注册之后进入mainloop

 // The main run loop.while (!this.stopped && isHealthy()) {  long now = System.currentTimeMillis();

   if ((now - lastMsg) >= msgInterval) {
      doMetrics();
      tryRegionServerReport();
      lastMsg = System.currentTimeMillis();
    }

}

每隔hbase.regionserver.msginterval时间(默认3秒),进行一次注册尝试,如果服务器ip和端口不在已注册列表中,则添加ServerName进map

ServerManager.java

 void regionServerReport(ServerName sn, HServerLoad hsl)throws YouAreDeadException, PleaseHoldException {checkIsDead(sn, "REPORT");if (!this.onlineServers.containsKey(sn)) {// Already have this host+port combo and its just different start code?
      checkAlreadySameHostPort(sn);// Just let the server in. Presume master joining a running cluster.// recordNewServer is what happens at the end of reportServerStartup.// The only thing we are skipping is passing back to the regionserver// the ServerName to use. Here we presume a master has already done// that so we'll press on with whatever it gave us for ServerName.
      recordNewServer(sn, hsl);} else {this.onlineServers.put(sn, hsl);}}

recordNewServer 会打印 ServerName对象的ip 端口和时间戳信息

同一个region server注册的ServerName对象 会拥有同样的时间戳

this.startcode = System.currentTimeMillis();...result = this.hbaseMaster.regionServerStartup(port, this.startcode, now);...this.serverNameFromMasterPOV = new ServerName(hostnameFromMasterPOV,
this.isa.getPort(), this.startcode);...this.hbaseMaster.regionServerReport(this.serverNameFromMasterPOV.getVersionedBytes(), hsl);

region server启动时startCode是固定死的,按照这个流程是不会出现相同IP和端口,但时间戳不同的region server跑在线上的

如果一台机器上启动了两个region server 会把时间戳小的移出,下次添加进时间戳大的进去

我们遇到的问题是时间戳不同的regionserver被注册在了master上,并且相互之间做region move

转载于:https://www.cnblogs.com/shenguanpu/archive/2012/07/30/2615214.html

hadoop loadBalance源码分析相关推荐

  1. 第二章:小朱笔记hadoop之源码分析-脚本分析

    第二章:小朱笔记hadoop之源码分析-脚本分析 第一节:start-all.sh 第二节:hadoop-config.sh 第三节:hadoop-env.sh 第四节:start-dfs.sh 第五 ...

  2. 第七章:小朱笔记hadoop之源码分析-hdfs分析 第四节:namenode-LeaseManagerMonitor

    第七章:小朱笔记hadoop之源码分析-hdfs分析 第四节:namenode分析 4.4 namenode文件租约分析LeaseManagerMonitor 文件租约就是将操作的文件和操作它的客户端 ...

  3. 第七章:小朱笔记hadoop之源码分析-hdfs分析 第三节:hdfs实现分析

    第七章:小朱笔记hadoop之源码分析-hdfs分析 第三节:hdfs实现分析 3.3 namenode (1)FSDirectory FSDirectory用来管理HDFS整个文件系统的namesp ...

  4. 第七章:小朱笔记hadoop之源码分析-hdfs分析 第四节:namenode分析-namenode启动过程分析...

    第七章:小朱笔记hadoop之源码分析-hdfs分析 第四节:namenode分析 4.1 namenode启动过程分析 org.apache.hadoop.hdfs.server.namenode. ...

  5. 第七章:小朱笔记hadoop之源码分析-hdfs分析 Datanode 心跳分析

    第七章:小朱笔记hadoop之源码分析-hdfs分析 第五节:Datanode 分析 5.2 Datanode 心跳分析 (1)offerService分析 写道 (a)检查心跳间隔是否超时,如是向n ...

  6. 第七章:小朱笔记hadoop之源码分析-hdfs分析 第五节:Datanode 分析

    第七章:小朱笔记hadoop之源码分析-hdfs分析 第五节:Datanode 分析 5.1 Datanode 启动过程分析 5.2 Datanode 心跳分析 5.3 Datanode 注册分析 5 ...

  7. 第七章:小朱笔记hadoop之源码分析-hdfs分析 第四节:namenode-ReplicationMonitor

    第四节:namenode分析 4.3 namenode 副本监控分析ReplicationMonitor ReplicationMonitor主要有两个作用: (1)负责为副本不足的数据块选择sour ...

  8. 第四章:小朱笔记hadoop之源码分析-conf分析

    第三章:小朱笔记hadoop之conf分析 一.Configurable void setConf(Configuration conf);     //获取配置信息的方法:     Configur ...

  9. hadoop作业初始化过程详解(源码分析第三篇)

    (一)概述 我们在上一篇blog已经详细的分析了一个作业从用户输入提交命令到到达JobTracker之前的各个过程.在作业到达JobTracker之后初始化之前,JobTracker会通过submit ...

最新文章

  1. 2022-2028年中国喷涂速凝橡胶行业市场调研分析及未来前景分析报告
  2. 元宇宙中可跨语种交流!Meta 发布新语音模型,支持128种语言无障碍对话
  3. Windows7瘦身和备份
  4. UVA10382喷水装置
  5. Linux系统IO分析工具之iotop常用参数介绍
  6. 充分利用Microsoft Planner的6种方法
  7. php循环checkbox,php循环删除checkbox | 学步园
  8. Jenkins打卡Day19-Jenkins重启关闭服务
  9. 字符集在本地化过程中的影响
  10. 精选32个最新Python实战项目(附源码),拿走就用
  11. 蓝桥杯C++AB算法辅导
  12. 阿里云服务器搭建Ghost博客教程
  13. JimuReport积木报表 — SQL数据源报表制作
  14. Qt添加工具栏按钮————附详细步骤
  15. python 学生成绩统计
  16. 面向对象文字游戏,蜈蚣怪和蛇怪
  17. uni-app 报错getUserProfile:fail can only be invoked by user TAP gesture.
  18. 在家怎么做炸酱面 炸酱面做法
  19. 一位网友的网络求职经历
  20. 爬虫系列 | 4、详解Requests的用法

热门文章

  1. 【NOIP2017模拟6.25】小W的动漫
  2. c# linq的差集,并集,交集,去重【转】
  3. select * 和select 所有字段的区别
  4. Struts2学习总结(完整版)
  5. PHP的time函数返回时间不正确
  6. 求s=a+aa+aaa+aaaa+aa...a的值,其中a是一个数字。例如2+22+222+2222+22222(此时共有5个数相加...
  7. hasLayout和filter滤镜的细节
  8. IIS 崩溃的后的感受
  9. myabtis 数字+逗号 传参问题 $和#
  10. niceyoo的2020年终总结-2021年Flag