spring-guides / gs-service-registration-and-discovery

Service Registration and Discovery :: Learn how to register and find services with Eureka
https://spring.io/guides/gs/service-registration-and-discovery/
Apache License 2.0
151 stars 192 forks source link

2 server on same host getting different instances list #3

Closed yangzii0920 closed 1 year ago

yangzii0920 commented 7 years ago

Hi there,

I have a Eureka Server A running on Eureka default port 8761, configuration looks looks this: spring.application.name=eureka server 1 server.port=8761 eureka.client.register-with-eureka=true eureka.client.fetch-registry=true logging.level.com.netflix.eureka=OFF logging.level.com.netflix.discovery=OFF

Another Server B running on default port 8080, configuration looks like this: spring.application.name=eureka server 2 eureka.client.register-with-eureka=true eureka.client.fetch-registry=true logging.level.com.netflix.eureka=OFF logging.level.com.netflix.discovery=OFF

And I have two Eureka clients both specified defaultZone at Server B. Their properties look like this: server.port=8000 eureka.client.serviceUrl.defaultZone:http://localhost:8080/eureka/ spring.application.name=eureka-client-one For client 2 server.port=8888 spring.application.name=eureka-client-two eureka.client.serviceUrl.defaultZone:http://localhost:8080/eureka/

Both server are registered to Eureka themselves. However at Server B's home page I could not see itself, instead at the Server A can I see all registered services including itself. Why is that? Is it because A is on Eureka default port?

Another thing I've noticed is that on both Server, replicas address is always http://localhost:8761/eureka/.

Thanks.

dsyer commented 7 years ago

You didn't set the eureka.client.serviceUrl on the eureka servers (so they both register with the default one A).

P.S. I don't think spaces in service ids are a good idea.

yangzii0920 commented 7 years ago

Hi @dsyer ,

Thanks for pointing out the naming.

After I set eureka.client.serviceUrl as B itself on B's properties file, I can see B (but A dissapeared???).

But following that I have question. 1. Why all clients and servers and visible on Server A (localhost: 8761)? 2. Why Server A is visible on Server B's home without specifing A's eureka.client.serviceUrl?

Thanks.