Reputation: 175
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 ?
Upvotes: 4
Views: 13971
Reputation: 1613
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.
Upvotes: 7