Eureka replicas unavailable
I'm guessing your eurekas don't register themselves with localhost
as their hostnames so this is why you're seeing them as unavailable in the eureka dashboards. Eureka uses this pattern a lot, it matches the service url with the caller hostname to determine replication context.
Peer eureka nodes are fetched in com.netflix.eureka.cluster.PeerEurekaNodes::resolvePeerUrls
from the list of eureka service urls (eureka.client.serviceUrl
key or DNS based). Later on, this list is matched against currently registered eureka applications in com.netflix.eureka.util.StatusUtil::getStatusInfo
by using the hostname to get the replica statuses.
Since your application most likely doesn't register itself with localhost
, it'll get added to the unavailable replicas.
Mont
Updated on June 04, 2022Comments
-
Mont almost 2 years
I have problem with configuring eureka replicas :
Eureka service :
@EnableEurekaServer @SpringBootApplication public class DiscoveryService { public static void main(String[] args) { SpringApplication.run(DiscoveryService.class, args); } }
bootstrap.properties
spring.application.name=discovery spring.cloud.config.uri=http://localhost:8888
I also have two yml files
for server 1 runing on 8761
eureka.client.serviceUrl.defaultZone:http://localhost:8762/eureka/ eureka.client.registerWithEureka:false eureka.client.fetchRegistry:false
for server 2 running on 8762
eureka.client.serviceUrl.defaultZone:http://localhost:8761/eureka/ eureka.client.registerWithEureka:false eureka.client.fetchRegistry:false
I can enter both dashboards, but I see that both instance have this:
registered-replicas http://localhost:8761/eureka/ unavailable-replicas http://localhost:8761/eureka/, available-replicas
Why is that ?
-
Doug about 6 yearsSo you are saying we need to set
eureka.instance.hostname=localhost
? -
Doug about 6 yearsI changed
eureka.instance.hostname=peer0
toeureka.instance.hostname=machine_ip
. I also hadeureka.client.register-with-eureka
set to false, so I had to change that to true. Now it works. thanks -
jebeaudet about 6 yearsThe hostname used in
eureka.client.serviceUrl
should match the one ineureka.instance.hostname
for the eureka server. -
Jef about 3 yearsthanks, bro. I was struggling with this for a long time. Replaced my Host IP based configuration to hostname based and now it works like a charm.