Eureka
eureka:
instance:
hostname: euk1.com
---
eureka:
instance:
hostname: euk2.com
核心特性
- renew: 续租, eureka-client 需要每30秒发送一次心跳来续租
- 如果服务器在90s 内没有收到 eureka-client 的更新, 会将其从服务注册列表中剔除
- 发送 down 不会剔除, 只是status=down
- time-lag: 客户端的更新可能需要有一段时间才能反映到服务器(有效载荷缓存, 定期刷新), 再过一段时间才能反映到连接到此服务器的客户端(30s心跳), 更改传播到所有客户机可能需要2分钟;
- 通讯机制: http restful 操作: https://github.com/Netflix/eureka/wiki/Eureka-REST-operations
- 可以使用http 请求操作eureka
- localhost:7001/eureka/apps
服务注册配置url
eureka:
client:
service-url:
defaultZone: http://euk1.com:7001/eureka/
健康检查配置
eureka:
client:
healthcheck:
enabled: true
安全配置
spring:
security:
user:
name: x407
password: 123
自我保护机制
- 不剔除不可用的客户端信息
- 同时保留健康的和不健康的节点, 也不盲目注销任何健康的节点/服务;
- 关闭自我保护:
eureka:
server:
enable-self-preservation: false
eviction-interval-timer-in-ms: 3000
触发自我保护机制
- 客户端每分钟续约/心跳 数量小于客户端总数的 85% 时会触发保护机制;
Actuator 收集节点信息配置
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
Actuator 的一些访问地址
http://localhost:81/actuator
http://localhost:81/actuator/metrics/jvm.memory.used
http://localhost:81/actuator/metrics/jvm.memory.max
暴露断点
management:
endpoint:
shutdown:
enabled: true
endpoints:
web:
exposure:
include: '*'
|