由浅入深分布式(5)dubbo提供者用内网地址注册provider以及 spring boot admin client用主机名注册spring boot admin server
来源:互联网 发布:淘宝收藏宝贝没反应 编辑:程序博客网 时间:2024/06/10 16:32
之前遇到过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
0 0
- 由浅入深分布式(5)dubbo提供者用内网地址注册provider以及 spring boot admin client用主机名注册spring boot admin server
- Spring cloud eureka+Client+Spring boot admin 服务注册监控
- Spring Boot Admin
- Spring Boot Admin实践
- Spring boot admin介绍
- Spring Boot Admin Reference Guide
- Spring Boot Admin 的使用
- Spring-boot-admin功能说明
- Spring Boot Admin的使用
- Spring-boot-admin功能说明
- Spring Boot Admin 的使用
- Spring Boot Admin 的使用
- Spring Boot Admin的使用
- spring boot 添加admin监控
- Spring Boot Admin的使用
- Spring Boot Admin 的使用
- Spring Boot Admin服务监控
- spring boot 添加admin监控
- 生物电(ECG、EMG、EEG)科普研究
- Mac上安装Homebrew 以及 MongoDB(附win安装教程)
- Webpack
- 5-8 单词长度 (15分)
- [bzoj4573][UOJ#195][ZJOI2016]大森林
- 由浅入深分布式(5)dubbo提供者用内网地址注册provider以及 spring boot admin client用主机名注册spring boot admin server
- 架构设计:负载均衡层设计方案(3)——Nginx进阶
- php数字证书的签名和验签
- 在socket系统调用中,如何完成三次握手和四次挥手
- JQuery _ $.extend(true,{},object...) 的不完全深复制 与 源代码详解
- 基于HTML5+bootstrap实现类似贪吃蛇游戏
- angularjs中的指令
- 数据库水平切分的实现原理解析——分库,分表,主从,集群,负载均衡器(转)
- Java自动生成Mvp框架目录结构