当部署eureka集群的时候发现available-replicas一直都为空,有可能是一下问题引起的:
1、eureka.client.register-with-eureka没有设为true
2、eureka.instance.prefer-ip-address没有设为false
3、如果设置了eureka.instance.appname,则所有eureak的这个值要设置为同一个
如果没有设置,则所有eureka的spring.application.name要设置为同一个
peer1的application.yml
#tomcat
server:
port: 6001
#spring
spring:
application:
name: eureka1
eureka:
client:
service-url:
defaultZone: http://peer2:6002/eureka
register-with-eureka: true
instance:
appname: eurekaServer #所有eureka设置为一个值
hostname: peer1
prefer-ip-address: false
peer2的application.yml
#tomcat
server:
port: 6002
#spring
spring:
application:
name: eureka2
eureka:
client:
service-url:
defaultZone: http://peer1:6001/eureka
register-with-eureka: true
instance:
appname: eurekaServer #所有eureka设置为同一个
hostname: peer2
prefer-ip-address: false