Service instances are registered as for peer services eureka

We work with the Eureka peer configuration. See below configuration.

  • So, when the services are started, they are registered until 10.202.10.95 (primary), and we see them there, which have no hits 10.202.10.97 (secondary)
  • If we kill 10.202.10.95 (primary), then we will see them at 10.202.10.97 (secondary eureka).
  • If we restart 10.202.10.95 (which was the main one), we will see that the services are displayed on 10.202.10.95, as well as on 10.202.10.97. Thus, services are displayed on both eureka servers.
  • If we restart 10.202.10.97 (secondary), the services disappear and are visible only on the primary (10.202.10.95)

Case 3 is unexpected to me. Is this an example of a misconfiguration of an Eureka partner?

The eureka configuration is as follows: (we specify these two instances to each other in the peer configuration)

spring: profiles: api06-prod-int-discoveryserver # 10.202.10.95 eureka host eureka: client: registerWithEureka: true fetchRegistry: true serviceUrl: defaultZone: http://10.202.10.97:8761/eureka/ --- spring: profiles: api05-prod-int-discoveryserver # 10.202.10.97 eureka host eureka: client: registerWithEureka: true fetchRegistry: true serviceUrl: defaultZone: http://10.202.10.95:8761/eureka/ 

Each service has its own configuration for eureka, set as follows: (we point to both instances, where xxx95 is the main one)

 eureka: # these are settings for the client that gets services client: # enable these two settings if you want discovery to work registerWithEureka: true fetchRegistry: true serviceUrl: defaultZone: http://10.202.10.95:8761/eureka/,http://10.202.10.97:8761/eureka/ 
+5
source share
1 answer

So, after some other messages and Spencer's answer, I checked and my configuration was wrong. After I changed it, it answers correctly.

These are the settings of Eureka. I am running 2 eureka servers, one with peer1 profile and the other with peer2 profile.

 --- spring: profiles: peer1 # not standalone server: port: 8761 eureka: instance: hostname: peer2 leaseRenewalIntervalInSeconds: 3 client: serviceUrl: defaultZone: http://localhost:8762/eureka/ --- spring: profiles: peer2 # not standalone server: port: 8762 eureka: instance: hostname: peer1 leaseRenewalIntervalInSeconds: 3 client: serviceUrl: defaultZone: http://localhost:8761/eureka/ server: waitTimeInMsWhenSyncEmpty: 0 

The service I'm connecting to is configured as follows

 eureka: client: registerWithEureka: true fetchRegistry: true serviceUrl: defaultZone: http://localhost:8761/eureka/,http://localhost:8762/eureka/ instance: statusPageUrlPath: /${info.app.name}/manage/info homePageUrlPath: /${info.app.name}/manage healthCheckUrlPath: /${info.app.name}/manage/health preferIpAddress: true 

After I started my service, I see that it connects to both discovery services, and if I kill it, it will be visible in another discovery service.

+1
source

All Articles