1、监控页面显示ip
当前在eureka上注册的server/client实例(Instances currently registered with Eureka),ip显示,在server/client端配置application.yml配置如下:
eureka: client: service-url: defaultZone: http://xxx/eureka instance: prefer-ip-address: true instance-id: ${spring.application.name}:${spring.cloud.client.ipAddress}:${spring.application.instance_id:${server.port}} #eureka显示ip
2、自我保护模式
Eureka 在设计时,认为分布式环境的网络是不可靠的,可能会出现网络原因导致 EurekaServer 没有收到实例的心跳而这却并不能说明实例就宕了,所以 EurekaServer 缺省会打开保护模式,它主要是网络分区场景下的一种保护一旦进入保护模式,EurekaServer 将会尝试保护其服务注册表中的信息,不再删除里面的数据(即不会注销任何微服务)相关介绍,详见:
我们可以通过配置文件的方式关闭自我保护模式。
server端:
eureka: server: enable-self-preservation: false #关闭eureka的自我保护 eviction-interval-timer-in-ms: 4000 #清理间隔时间,单位为毫秒(默认值60 * 1000)
client端:
eureka: instance: lease-renewal-interval-in-seconds: 5 # 租期更新时间隔时间(缺省为30s) lease-expiration-duration-in-seconds: 15 # 租期到期时间(缺省为90s) client: healthcheck: enabled: true # 开启健康检查(依赖spring-boot-starter-actuator)