当前位置:网站首页>Eureka相互注册,只显示对方或只在一个中显示问题
Eureka相互注册,只显示对方或只在一个中显示问题
2022-07-28 19:11:00 【_小许_】
在使用eureka编写微服务程序时,遇到了一个问题,就是在两个eureka_server相互注册时,每个eureka中要么只显示对方,要么只在一个中显示。
两个配置如下:
# 配置服务名称 == 注册中心server
spring.application.name=eureka_server_copy
# 服务端口号
server.port=7000
# 配置服务实例ip
eureka.instance.hostname=localhost
#是否将eureka注册到注册中心(本自身注册)
eureka.client.register-with-eureka=true
#是否从eureka中获取注册地址(后台已ip显示而不是域名)
eureka.client.fetch-registry=false
# 配置eureka客户端要连接的服务端信息
eureka.client.service-url.defaultZone=http://localhost:9000/eureka/,http://localhost:7000/eureka/
# 配置服务名称 == 注册中心server
spring.application.name=eureka_server
# 服务端口号
server.port=9000
# 配置服务实例ip
eureka.instance.hostname=localhost
#是否将eureka注册到注册中心(本自身注册)
# 将本身注册到注册中心
eureka.client.register-with-eureka=true
#是否从eureka中获取注册地址(后台已ip显示而不是域名)
eureka.client.fetch-registry=false
# 配置eureka客户端要连接的服务端信息
eureka.client.service-url.defaultZone=http://localhost:7000/eureka/,http://localhost:9000/eureka/
我修改了eureka.client.service-url.defaultZone地址的顺序问题,当本机的端口在前时,只显示对方的,自己不显示,当本机端口的地址在后时只显示在一个上:


造成这个结果的原因时主机名相同且使用localhost作为注册地址:
# 配置服务实例ip
eureka.instance.hostname=localhost
eureka.client.service-url.defaultZone=http://localhost:9000/eureka/,http://localhost:7000/eureka/
以上两个时造成注册中心不能相互注册的原因,将主机名随意命名,使用172.0.0.1代替localhost即可:
eureka.instance.hostname=machine2
#是否将eureka注册到注册中心(本自身注册)
eureka.client.register-with-eureka=true
#是否从eureka中获取注册地址(后台已ip显示而不是域名)
eureka.client.fetch-registry=false
# 配置eureka客户端要连接的服务端信息
eureka.client.service-url.defaultZone=http://127.0.0.1:9000/eureka/,http://127.0.0.1:7000/eureka/
修改后既可以相互注册了:


边栏推荐
- Explain in detail the rays and radiographic testing in unity
- Explain the imported 3D model in unity
- Using viewpager to slide through pages in fragment
- 图书馆借阅系统「建议收藏」
- Dom4J的Bug
- 58岁安徽人,干出瑞士今年最大IPO 投资界
- Laser slam:logo-loam --- code compilation, installation and gazebo test
- Two written interview questions about regular
- The 678th operation
- Space shooting Lesson 11: sound and music
猜你喜欢

Lvs+keepalived high availability deployment practical application

MoCo V1:视觉领域也能自监督啦

阿里云 MSE 支持 Go 语言流量防护

Alibaba cloud MSE supports go language traffic protection

Explain prefabrication in unity in detail

Unity foundation 1 - event execution sequence, custom events

How to turn on or off the disk LED of EMC Vmax

云原生编程挑战赛火热开赛,51 万奖金等你来挑战!

H5 wechat shooting game source code

58岁安徽人,干出瑞士今年最大IPO 投资界
随机推荐
瀚高数据库最佳实践配置工具HG_BP日志采集内容
Basic operations of unity3d scene production
Beautiful blue background form input box style
Prize essay solicitation | 2022 cloud native programming challenge draft activity opens
什么是低代码?哪些平台适合业务人员?用来开发系统靠不靠谱?
setPreviewCallbackWithBuffer的出帧效率会变低
Explain in detail the rays and radiographic testing in unity
GIS数据漫谈(六)— 投影坐标系统
How can enterprises successfully complete cloud migration?
Alibaba cloud MSE supports go language traffic protection
【周周有奖】云原生编程挑战赛“边缘容器”赛道邀你来战!
Three deletion strategies and eviction algorithm of redis
Yyds dry inventory interview must brush top101: every k nodes in the linked list are turned over
Prometheus complete process of configuring alertmanager
程序员最大的浪漫~
不懂就问,快速成为容器服务进阶玩家!
C language function program example (super complete)
【1331. 数组序号转换】
ntp服务器 时间(查看服务器时间)
Unity foundation 4 common plug-ins