之前遇到过dubbo提供者用内网地址注册provider的问题 当时改了host文件成功了 但是没有想为什么会有这个问题

现在使用spring boot admin 来监控spring boot项目出现了如下问题, 如果是client和server端 分离,而且不在一台机器上,client会将主机名作为地址注册导致注册失败

要注意服务器之间是可以根据各自的主机名来访问的哦,如果不能访问也应该可以在hosts里设置。。

但是现在遇到了windows下spring boot admin的client注册到linux的server 失败的问题

下面的图显式的是linux的client的注册,道理一样。

直接查spring boot admin clientd 的源代码

/*** Scheduler that checks the registration of the application at the spring-boot-admin.*/
public class SpringBootAdminRegistratorTask implements Runnable {private static final Logger LOGGER = LoggerFactory.getLogger(SpringBootAdminRegistratorTask.class);@Autowiredprivate Environment env;@PostConstructpublic void check() {Assert.notNull(env.getProperty("spring.boot.admin.url"),"The URL of the spring-boot-admin application is mandatory");Assert.notNull(env.getProperty("server.port"), "The server port of the application is mandatory");Assert.notNull(env.getProperty("info.id"), "The id of the application is mandatory");}/*** @see java.lang.Runnable#run()*/@Overridepublic void run() {try {String id = env.getProperty("info.id");int port = env.getProperty("server.port", Integer.class);String adminUrl = env.getProperty("spring.boot.admin.url");RestTemplate template = new RestTemplate();template.getMessageConverters().add(new MappingJackson2HttpMessageConverter());ApplicationList list = template.getForObject(adminUrl + "/api/applications", ApplicationList.class);for (Application app : list) {if (id.equals(app.getId())) {// the application is already registered at the admin toolLOGGER.debug("Application already registered with ID '{}'", id);return;}}// register the application with the used URL and portString url = new URL("http", InetAddress.getLocalHost().getCanonicalHostName(), port, "").toString();Application app = new Application();app.setId(id);app.setUrl(url);template.postForObject(adminUrl + "/api/applications", app, String.class);LOGGER.info("Application registered itself at the admin application with ID '{}' and URL '{}'", id, url);} catch (Exception e) {LOGGER.warn("Failed to register application at spring-boot-admin, message={}", e.getMessage());}}private static class ApplicationList extends ArrayList<Application> {private static final long serialVersionUID = 1L;}}

InetAddress.getLocalHost().getCanonicalHostName() 这行代码有问题,获得的是主机名或者内网ip

修改hosts文件没有用

最后修改注册表

PS C:\Users\BAO> hostname
210.82.98.38

OK

由浅入深分布式(5)dubbo提供者用内网地址注册provider以及 spring boot admin client用主机名注册spring boot admin server相关推荐

  1. nginx根据项目名实现内网地址转发

    nginx根据访问的项目名进行内网地址转发 以下是nginx的配置信息: server {listen 8081;server_name localhost;#charset koi8-r;#acce ...

  2. 今天谈一下内网地址,外网地址

    今天更加了解了一下生活中的IP地址: 比如我的电脑上地址是:192开头的,但是我的电脑是一个路由器发出来. 路由器的IP地址是:172发出来的. 但是用浏览器查"IP地址",是22 ...

  3. springboot连接阿里云redis集群内网会连内网地址

    springboot配置了redis集群(阿里云的),然后也可以运行,就是第一次连接会特别慢,检查发现控制台warn ,连接不上 ip:端口 , 发现ip是内网地址,端口是集群的端口. (我是一个服务 ...

  4. 为什么内网地址普遍是192.168.1.1

    链接:https://www.zhihu.com/question/19813460/answer/13042143 IPv4地址分为A.B.C.D.E五类,出去特殊作用的D.E两类,剩下的A.B.C ...

  5. 通过花生壳,把内网地址转公网地址

    在测试软件功能时,遇到要和其他城市的电脑使用socket进行通讯的需求,但是内网之间需要一个公网地址才能通讯. 查了一下,可以使用花生壳软件解决这个问题,花生壳官网:花生壳内网穿透|ddns动态域名解 ...

  6. 局域网内网地址暴露到公网-内网穿透

    1.为什么使用 web开发中,难免会遇到在某些情况下,我们必须借助外网才能调用某个API,然而,如果我们按照下面的方式来做,显得就很繁琐: a.在一个具有外网可访问的服务器上搭建一个web环境 b.上 ...

  7. mac电脑确认已连接网略,却无法访问内网地址

    1.选择系统偏好设置 2.选择网略 3.选择高级 4.查看代理

  8. Meraki X84+ FortiGate 100F映射内网地址到外网

    Cisco Meraki 设置 登陆 Cisco Meraki 控制面板 选择SD-WAN 路由器下的防火墙 下滑到转发规则,点击添加 一对一 NAT 映射 填写IP,LAN IP 就是内外的ip地址 ...

  9. openwrt的dns无法解析内网地址的问题解决方案

    知乎上看到大佬的解决方案 最近买了电犀牛的R66S,想整个那个上网,下面挂个ap,给树莓派.香橙派的一些linux用,免得换源改地址什么的,然后网络环境是校园网,就遇到了这个问题,刚开始一直以为问题是 ...

最新文章

  1. webpack初学笔记 之 小案例篇demo1
  2. Linux Shell脚本编程 --split命令
  3. Unity SRP自定义渲染管线 -- 2.Custom Shaders
  4. 执行全文索引时出现权限不足的解决方法
  5. python从url获取pdf文件并保存在本地
  6. SubclassDlgItem函数
  7. ValueError: No JSON object could be decoded?此种异常的解决方案之一
  8. Code-NFine:变量修改
  9. 博思得标签打印机驱动_博思得打印机驱动
  10. 计算机进入安全模式,电脑无法进入安全模式如何解决
  11. sql server 2008服务无法启动的原因和解决办法
  12. 年审是当月还是当天_车辆年审到期是指当月吗?
  13. java毕业设计车辆违规信息管理系统Mybatis+系统+数据库+调试部署
  14. Linux粘滞位简析
  15. Webpack的使用
  16. 【编程与物理】从打造的适用型pdf电子书谈起
  17. Verdi 改变字体大小额方法
  18. 1加6投屏_全球首批!一场最“快”的OnePlus 6 加油聚会
  19. 考研OS备考|计算机操作系统|汤小丹慕课版|课后习题答案|复试拓展
  20. 助力“一带一路”信息化建设,银河麒麟操作系统(藏文版)V10 全新发布!

热门文章

  1. Latex中的特殊符号
  2. 办公室适合新中式的装修风格吗
  3. 外贸技巧之如何引导客户尽早下单
  4. ubuntu解决浏览器不支持HTML5播放器的方法
  5. 实现IE6、IE7、IE8多版本浏览器共存
  6. [巩固培元]Python文件操作案例——用户登录
  7. centos7系统k8s部署gitlib-runner
  8. 070-JAVA项目实训:仿QQ即时通讯软件系列讲座五(讲解用户注册功能)
  9. 订阅号 openid php,微信“订阅号”如何存放openid,并在其他页面使用
  10. 什么样的微信头像最撩人?