0%

Eureka配置

Eureka配置

Eureka注册中心配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
eureka:
instance:
hostname: localhost
# 过期时间,默认90s, 可不配置
lease-expiration-duration-in-seconds: 90
# 续约时间,默认30s,可不配置
lease-renewal-interval-in-seconds: 30
# ip地址优先
prefer-ip-address: true
server:
# 关闭注册中心自我保护模式,避免注册中心不移除失效的服务,默认为true
enable-self-preservation: true
# 去除失效服务的时间间隔(毫秒)
eviction-interval-timer-in-ms: 4000
client:
# 启用eureka客户端,默认为true, 可不配置
enabled: true
# 取注册信息,默认为true,可不配置
fetchRegistry: false
# 两个心跳参数,默认都是30s,可不配置
instance-info-replication-interval-seconds: 30
registry-fetch-interval-seconds: 30
# 注册到注册中心,默认为true,可不配置
registerWithEureka: false
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/

业务微服务配置

1
2
3
4
5
6
7
8
9
10
11
12
13
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka
instance:
instance-id: ${spring.cloud.client.ip-address}:${server.port}
prefer-ip-address: true #以IP地址注册到服务中心
ip-address: 192.168.217.211
non-secure-port: 8767
#Eureka客户端向服务端发送心跳的时间间隔,单位为秒(客户端告诉服务端自己会按照该规则),默认30
lease-renewal-interval-in-seconds: 10
#Eureka服务端在收到最后一次心跳之后等待的时间上限,单位为秒,超过则剔除(客户端告诉服务端按照此规则等待自己),默认90
lease-expiration-duration-in-seconds: 30