I am using the below configuration for Eureka Servers.

Eureka Server1 (application.properties)

server.port=8761

eureka.client.register-with-eureka=true
eureka.client.fetch-registry=true
eureka.client.health-check.enabled=true

logging.level.com.netflix.eureka=DEBUG
logging.level.com.netflix.discovery=DEBUG

eureka.server.eviction-interval-timer-in-ms: 25000
eureka.server.enableSelfPreservation=false

eureka.instance.hostname=localhost
eureka.client.service-url.defaultZone=http://localhost:8762/eureka/

Eureka Server2 (application.properties)

server.port=8762

eureka.client.register-with-eureka=true
eureka.client.fetch-registry=true
eureka.client.health-check.enabled=true

logging.level.com.netflix.eureka=DEBUG
logging.level.com.netflix.discovery=DEBUG

eureka.server.eviction-interval-timer-in-ms: 25000
eureka.server.enableSelfPreservation=false

eureka.instance.hostname=localhost
eureka.client.service-url.defaultZone=http://localhost:8761/eureka/

Micro service configuration (appsettings.json)

{
  "Logging": {
    "IncludeScopes": true,
    "LogLevel": {
      "Default": "Information",
      "Pivotal": "Debug",
      "Steeltoe": "Debug"
    }
  },
  "spring": {
    "application": {
      "name": "fortuneService"
    }
  },
  "eureka": {
    "client": {
      "serviceUrl": {
        "defaultZone": "http://localhost:8761/eureka/,http://localhost:8762/eureka/"
      },
      "shouldFetchRegistry": true,
      "ValidateCertificates": false,
      "registryFetchIntervalSeconds": 10
    },
    "instance": {
      "appName": "FortuneService",
      "hostName": "localhost",
      "port": 52701,
      "instanceId": "FortuneService2",
      "leaseRenewalIntervalInSeconds": 10,
      "leaseExpirationDurationInSeconds": 5
    }
  }
}

I am facing an issue with when I connect the Multi instance of the Eureka Servers to Eureka Client(Microservices) that is not working for below scenario – Let’s consider I have two Eureka Servers(ES1 – 8761 and ES2-8762)

ES1 server registered with ES2 Server and vice-versa. When I start the Microservices, both services are registered with ES1 Server only, but not registered with ES2 server. After sometime intentionally, I have stopped the ES1 server. Which are registered with ES1 server’s services are not replicating with ES2 server.

Please help me.

Comment From: ryanjbaxter

Can you try giving each Eureka server a unique hostname property?

Comment From: ManteshJ

Hi @ryanjbaxter, thanks for your response, I gave the unique hostname property for each Eureka Server, but no luck.

Comment From: ryanjbaxter

@habuma I know you just went through this, do you see anything out of place here?

Comment From: ManteshJ

I am running 3 Eureka Servers, all three are up, but the Eureka Server's Dashboard displaying the replicas in the unavailable-replicas section. I don't know, why replicas displaying in the unavailable-replicas section? I am using below configuration for Eureka Servers and Micro service.

Eureka Server1 (application.properties)

server.port=8761

eureka.client.register-with-eureka=true
eureka.client.fetch-registry=true
eureka.client.health-check.enabled=true

logging.level.com.netflix.eureka=DEBUG
logging.level.com.netflix.discovery=DEBUG

eureka.server.eviction-interval-timer-in-ms: 25000
eureka.server.enableSelfPreservation=false

eureka.instance.hostname=localhost1
eureka.client.service-url.defaultZone=http://localhost:8762/eureka/,http://localhost:8763/eureka/

eureka.shouldBatchReplication=true
eureka.instance.appname=eureka-cluster
eureka.instance.metadataMap.zone=Zone1

Eureka Server2 (application.properties)

server.port=8762

eureka.client.register-with-eureka=true
eureka.client.fetch-registry=true
eureka.client.health-check.enabled=true

logging.level.com.netflix.eureka=DEBUG
logging.level.com.netflix.discovery=DEBUG

eureka.server.eviction-interval-timer-in-ms: 25000
eureka.server.enableSelfPreservation=false

eureka.instance.hostname=localhost2
eureka.client.service-url.defaultZone=http://localhost:8761/eureka/,http://localhost:8763/eureka/

eureka.shouldBatchReplication=true
eureka.instance.appname=eureka-cluster
eureka.instance.metadataMap.zone=Zone1

Eureka Server3 (application.properties)

server.port=8763

eureka.client.register-with-eureka=true
eureka.client.fetch-registry=true
eureka.client.health-check.enabled=true

logging.level.com.netflix.eureka=DEBUG
logging.level.com.netflix.discovery=DEBUG

eureka.server.eviction-interval-timer-in-ms: 25000
eureka.server.enableSelfPreservation=false

eureka.instance.hostname=localhost3
eureka.client.service-url.defaultZone=http://localhost:8761/eureka/,http://localhost:8762/eureka/

eureka.shouldBatchReplication=true
eureka.instance.appname=eureka-cluster
eureka.instance.metadataMap.zone=Zone1

Micro service configuration (appsettings.json)

{
  "Logging": {
    "IncludeScopes": true,
    "LogLevel": {
      "Default": "Information",
      "Pivotal": "Debug",
      "Steeltoe": "Debug"
    }
  },
  "spring": {
    "application": {
      "name": "fortuneService"
    }
  },
  "eureka": {
    "client": {
      "serviceUrl": {
        "defaultZone": "http://localhost:8761/eureka/,http://localhost:8762/eureka/,http://localhost:8763/eureka/"
      },
      "shouldFetchRegistry": true,
      "ValidateCertificates": false,
      "registryFetchIntervalSeconds": 10
    },
    "instance": {
      "appName": "FortuneService",
      "hostName": "localhost",
      "port": 52701,
      "instanceId": "FortuneService2",
      "leaseRenewalIntervalInSeconds": 10,
      "leaseExpirationDurationInSeconds": 5,

      "metadataMap": {
        "zone": "Zone1"
      }
    }
  }
}

Please find the below screen shot of the Eureka Server's Dashboard screenshot_1

Please help me.

Comment From: illingtonFlex

Hello everybody.

I've been kicking my way through this issue as well, and as I was typing up my detailed complaint to add to this thread, I inadvertently fixed my problem. Maybe I can help you as well.

I had to do two things.

  1. Edit my hosts file (I am currently running locally in preparation for a deployment) so that the values in eureka.client.serviceUrl.defaultZone have different host names. I read in several threads that you should not use localhost, or the same ip or dns name for replicated Eureka instances.

  2. Make sure the value of eureka.instance.hostname is the same value from my hosts file.

So, here is my config.

hosts file:

    127.0.0.1       eureka1
    127.0.0.1       eureka2

Base properties:

eureka.client.register-with-eureka=true
eureka.client.fetch-registry=true
eureka.instance.appName=ServiceRegistryCluster
eureka.environment=local

peer1 profile properties:

server.port=8761
eureka.client.serviceUrl.defaultZone=http://eureka2:8762/eureka/,http://eureka1:8761/eureka/
eureka.instance.hostname=eureka1
spring.application.name=EUREKA_SERVICE_REGISTRY_DEV

peer2 profile properties:

server.port=8762
eureka.client.serviceUrl.defaultZone=http://eureka1:8761/eureka/,http://eureka2:8762/eureka/
eureka.instance.hostname=eureka2
spring.application.name=EUREKA_SERVICE_REGISTRY_DEV

Now when I look at the Eureka console for eureka1, I see eureka2 listed as an available replica, and vice-versa for the eureka2 console.

Comment From: indraneelb1903

I have tried what is mentioned above, but I am facing the same issue. The available replicas is empty. Also, what is mentioned in the official documentation, it does not work. Is there a sample available which can help us?

Comment From: ryanjbaxter

Can you provide your code so we have more details?

Comment From: liuzwei

I hava a question, in my yml, i set a properties prefer-ip-address: true, that's the problem, could explain why ?

Comment From: ryanjbaxter

@liuzwei i dont see how your question is related. If you have a question please post something on StackOverflow or in Gitter. If you think there is a bug please open an issue with a project that reproduces the problem.

Comment From: ryanjbaxter

Closing due to lack of feedback

Comment From: bobaikato

Hi @illingtonFlex,

I followed the guide you provided. I seem to replicate my instances. However, there isn't any value for available-replicas peer1 peer2

Is this the expected behavior?

Comment From: illingtonFlex

Is this the expected behavior?

No, this means your two Eureka registries are not replicated, they are running independently of each other. One apparent difference I see between your config and mine is that you have different values for spring.application.name. Both of my Eureka instances are named the same, yours have different names.

I'm not sure if this is your issue or not. I would check the logs. They will fail to replicate if they can't find each other, or if they can't authenticate to each other also.

Comment From: bobaikato

Hi @illingtonFlex,

You are right about instance name, I now have the servers having same name and now, I can see: available-replicas having a value

My next question is: What will be the right configuration for the application using Eureka? More specifically: eureka.client.service-url.defaultZone

I'm currently using: eureka.client.service-url.defaultZone = http://localhost:8761/eureka/,http://localhost:8762/eureka/ is this correct? or Do I only need to set eureka.client.service-url.defaultZone = http://localhost:8761/eureka/?

Cheers!

Comment From: illingtonFlex

My next question is: What will be the right configuration for the application using Eureka? More specifically: eureka.client.service-url.defaultZone

I'm currently using: eureka.client.service-url.defaultZone = http://localhost:8761/eureka/,http://localhost:8762/eureka/ is this correct? or Do I only need to set eureka.client.service-url.defaultZone = http://localhost:8761/eureka/?

According to the documentation, which I recommend reading, the value for that property is a list of eureka servers the client will iterate through if the first one is unavailable. I don't recommend using localhost. Use the DNS/host name you configured for the replication.

eureka.client.service-url.defaultZone=http://eureka1:8761/eureka/,http://eureka2:8762/eureka/

Comment From: ecornely

I see it has been closed but though I read all the comments and tried to apply the solutions I'm still stuck with those unavailable replicas. I have a very simple docker project here that you can try as example: https://github.com/ecornely/eureka-docker

I'm made sure one container can ping the other by name (aliases are working well) I have set the same application name as it is suppose to come from application.yml packaged in the jar, I use the hostname to reference the other replicas...

I also have a no-security branch without spring-security aso... really I don't understand what make my replicas unavaliable...

Please help