Eureka 搭建高可用,副本出现 unavailable-replicas
问题描述
Eureka 搭建高可用集群,在管理控制台发现副本出现在unavailable-replicas
这一栏,表明副本不可用,正确的情况,副本信息应该出现在available-replicas
错误原因
Application.yml
配置文件中,对于application.name
的配置有误
## profileA
server:
port: 8762
spring:
application:
name: eureka8762
eureka:
instance:
hostname: eureka8762
client:
service-url:
defaultZone: http://eureka8761:8761/eureka
register-with-eureka: true
fetch-registry: true
## profileB
server:
port: 8761
spring:
application:
name: eureka8761
eureka:
instance:
hostname: eureka8761
client:
service-url:
defaultZone: http://eureka8762:8762/eureka
register-with-eureka: true
fetch-registry: true
需要把两个实例的application.name
配置成相同的名称,下面是正确的配置
## profileA
server:
port: 8762
spring:
application:
name: eurekaServer
eureka:
instance:
hostname: eureka8762
client:
service-url:
defaultZone: http://eureka8761:8761/eureka
register-with-eureka: true
fetch-registry: true
## profileB
server:
port: 8761
spring:
application:
name: eurekaServer
eureka:
instance:
hostname: eureka8761
client:
service-url:
defaultZone: http://eureka8762:8762/eureka
register-with-eureka: true
fetch-registry: true