Search code examples
spring-cloudnetflix-eurekaspring-cloud-netflix

Spring Cloud - Eureka service discovery clustering


I have tried starting Eureka service in peer to peer awareness with following profiles.

#profile 1:

spring:
  application:
    name: service-registry
  profiles: p1
server:
  port: 8761
eureka:
  dashboard:
    enabled: false
    override: true
  enableselfPresentation: true
  shouldUseDns: true
  instance:
    appname: ${spring.application.name}
    instanceId: ${random.value}
  client:
    registerWithEureka: false
    fetchRegistry: false

#profile 2:

spring:
  application:
    name: service-registry
  profiles: p2
server:
  port: 8762
eureka:
  dashboard:
    enabled: false
    override: true
  enableselfPresentation: true
  shouldUseDns: true
  instance:
    appname: ${spring.application.name}
    instanceId: ${random.value}
  client:
    registerWithEureka: false
    fetchRegistry: false

After starting eureka with these profiles, at eureka dashboard for port 8761 I see DS replica as localhost:8761 but not as localhost:8762 and on localhost:8762 DS replica as localhost:8761 How to make the replica of localhost:8761 as localhost:8762 and vice versa


Solution

  • Found the solution for this added following config:

    #profile p1
    eureka
      client:
        registerWithEureka: false
        fetchRegistry: false
        serviceUrl:
          defaultZone: http://localhost:8762/eureka/
    #profile p2
    eureka
      client:
        registerWithEureka: false
        fetchRegistry: false
        serviceUrl:
          defaultZone: http://localhost:8761/eureka/