当前位置:网站首页>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/
修改后既可以相互注册了:


边栏推荐
- [server data recovery] HP StorageWorks series storage RAID5 two disk failure offline data recovery case
- Prometheus complete process of configuring alertmanager
- 【1331. 数组序号转换】
- Oracle库访问很慢,是什么原因?
- GIS数据漫谈(六)— 投影坐标系统
- [C language brush questions] explanation of linked list application
- Guo Mingxuan: meta contraction is conducive to the development of VR competitors, and apple XR headshow will change the industry rules
- Interesting pictures and words
- 有奖征文 | 2022 云原生编程挑战赛征稿活动开启
- Alibaba cloud MSE supports go language traffic protection
猜你喜欢

Why on earth is it not recommended to use select *?

After Europe, it entered Japan and South Korea again, and the globalization of Pico consumer VR accelerated

JS page black and white background switch JS special effect

Want to draw a picture that belongs to you? AI painting, you can also

Explain the imported 3D model in unity

58岁安徽人,干出瑞士今年最大IPO 投资界

Unit editor details

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

What is data center? What value does the data center bring_ Light spot technology

JS picture hanging style photo wall JS special effect
随机推荐
Unity knowledge points summary (1)
蓝队入门之效率工具篇
Learn about the native application management platform of rainbow cloud
Yyds dry inventory interview must brush top101: every k nodes in the linked list are turned over
C # basic 3-value type and reference type, packing and unpacking
How to modify the ID of NetApp expansion enclosure disk shelf
[工具类] Map的util包, 常用 实体类转化为map等操作
C # basic 5-asynchronous
MoCo V2:MoCo系列再升级
Redis 3.0 source code analysis - data structure and object SDS list Dict
7/27 training log (bit operation + suffix array)
Subcontracting loading of wechat applet
Why on earth is it not recommended to use select *?
Introduction to singleton mode
Space game Lesson 12: shield
Want to draw a picture that belongs to you? AI painting, you can also
Three deletion strategies and eviction algorithm of redis
3D laser slam: Interpretation of logo-loam paper - Introduction
C # basic 1-events and commissions
又一款装机神器