由浅入深分布式(5)dubbo提供者用内网地址注册provider以及 spring boot admin client用主机名注册spring boot admin server
之前遇到过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相关推荐
- nginx根据项目名实现内网地址转发
nginx根据访问的项目名进行内网地址转发 以下是nginx的配置信息: server {listen 8081;server_name localhost;#charset koi8-r;#acce ...
- 今天谈一下内网地址,外网地址
今天更加了解了一下生活中的IP地址: 比如我的电脑上地址是:192开头的,但是我的电脑是一个路由器发出来. 路由器的IP地址是:172发出来的. 但是用浏览器查"IP地址",是22 ...
- springboot连接阿里云redis集群内网会连内网地址
springboot配置了redis集群(阿里云的),然后也可以运行,就是第一次连接会特别慢,检查发现控制台warn ,连接不上 ip:端口 , 发现ip是内网地址,端口是集群的端口. (我是一个服务 ...
- 为什么内网地址普遍是192.168.1.1
链接:https://www.zhihu.com/question/19813460/answer/13042143 IPv4地址分为A.B.C.D.E五类,出去特殊作用的D.E两类,剩下的A.B.C ...
- 通过花生壳,把内网地址转公网地址
在测试软件功能时,遇到要和其他城市的电脑使用socket进行通讯的需求,但是内网之间需要一个公网地址才能通讯. 查了一下,可以使用花生壳软件解决这个问题,花生壳官网:花生壳内网穿透|ddns动态域名解 ...
- 局域网内网地址暴露到公网-内网穿透
1.为什么使用 web开发中,难免会遇到在某些情况下,我们必须借助外网才能调用某个API,然而,如果我们按照下面的方式来做,显得就很繁琐: a.在一个具有外网可访问的服务器上搭建一个web环境 b.上 ...
- mac电脑确认已连接网略,却无法访问内网地址
1.选择系统偏好设置 2.选择网略 3.选择高级 4.查看代理
- Meraki X84+ FortiGate 100F映射内网地址到外网
Cisco Meraki 设置 登陆 Cisco Meraki 控制面板 选择SD-WAN 路由器下的防火墙 下滑到转发规则,点击添加 一对一 NAT 映射 填写IP,LAN IP 就是内外的ip地址 ...
- openwrt的dns无法解析内网地址的问题解决方案
知乎上看到大佬的解决方案 最近买了电犀牛的R66S,想整个那个上网,下面挂个ap,给树莓派.香橙派的一些linux用,免得换源改地址什么的,然后网络环境是校园网,就遇到了这个问题,刚开始一直以为问题是 ...
最新文章
- webpack初学笔记 之 小案例篇demo1
- Linux Shell脚本编程 --split命令
- Unity SRP自定义渲染管线 -- 2.Custom Shaders
- 执行全文索引时出现权限不足的解决方法
- python从url获取pdf文件并保存在本地
- SubclassDlgItem函数
- ValueError: No JSON object could be decoded?此种异常的解决方案之一
- Code-NFine:变量修改
- 博思得标签打印机驱动_博思得打印机驱动
- 计算机进入安全模式,电脑无法进入安全模式如何解决
- sql server 2008服务无法启动的原因和解决办法
- 年审是当月还是当天_车辆年审到期是指当月吗?
- java毕业设计车辆违规信息管理系统Mybatis+系统+数据库+调试部署
- Linux粘滞位简析
- Webpack的使用
- 【编程与物理】从打造的适用型pdf电子书谈起
- Verdi 改变字体大小额方法
- 1加6投屏_全球首批!一场最“快”的OnePlus 6 加油聚会
- 考研OS备考|计算机操作系统|汤小丹慕课版|课后习题答案|复试拓展
- 助力“一带一路”信息化建设,银河麒麟操作系统(藏文版)V10 全新发布!