Eureka resolve common configuration

[Original content, reproduced, please indicate the source]

1. parsing configuration items

1.1-class arrangement

# 应用名称,将会显示在Eureka界面的应用名称列
spring.application.name=config-service

# 应用端口,Eureka服务端默认为:8761
server.port=3333

1.2 eureka.server prefix configuration items

# 是否允许开启自我保护模式,缺省:true
# 当Eureka服务器在短时间内丢失过多客户端时,自我保护模式可使服务端不再删除失去连接的客户端
eureka.server.enable-self-preservation = false

# Peer节点更新间隔,单位:毫秒
eureka.server.peer-eureka-nodes-update-interval-ms = 

# Eureka服务器清理无效节点的时间间隔,单位:毫秒,缺省:60000,即60秒
eureka.server.eviction-interval-timer-in-ms = 60000

1.3 eureka.instance prefix configuration items

# 服务名,默认取 spring.application.name 配置值,如果没有则为 unknown
eureka.instance.appname = eureka-client

# 实例ID
eureka.instance.instance-id = eureka-client-instance1

# 应用实例主机名
eureka.instance.hostname = localhost

# 客户端在注册时使用自己的IP而不是主机名,缺省:false
eureka.instance.prefer-ip-address = false

# 应用实例IP
eureka.instance.ip-address = 127.0.0.1

# 服务失效时间,失效的服务将被剔除。单位:秒,默认:90
eureka.instance.lease-expiration-duration-in-seconds = 90

# 服务续约(心跳)频率,单位:秒,缺省30
eureka.instance.lease-renewal-interval-in-seconds = 30

# 状态页面的URL,相对路径,默认使用 HTTP 访问,如需使用 HTTPS则要使用绝对路径配置,缺省:/info
eureka.instance.status-page-url-path = /info

# 健康检查页面的URL,相对路径,默认使用 HTTP 访问,如需使用 HTTPS则要使用绝对路径配置,缺省:/health
eureka.instance.health-check-url-path = /health

1.4 eureka.client prefix

# Eureka服务器的地址,类型为HashMap,缺省的Key为 defaultZone;缺省的Value为 http://localhost:8761/eureka
# 如果服务注册中心为高可用集群时,多个注册中心地址以逗号分隔。 
eureka.client.service-url.defaultZone=http://${eureka.instance.hostname}:${server.port}/eureka

# 是否向注册中心注册自己,缺省:true
# 一般情况下,Eureka服务端是不需要再注册自己的
eureka.client.register-with-eureka = true

# 是否从Eureka获取注册信息,缺省:true
# 一般情况下,Eureka服务端是不需要的
eureka.client.fetch-registry = true

# 客户端拉取服务注册信息间隔,单位:秒,缺省:30
eureka.client.registry-fetch-interval-seconds = 30

# 是否启用客户端健康检查
eureka.client.health-check.enabled = true

# 
eureka.client.eureka-service-url-poll-interval-seconds = 60

# 连接Eureka服务器的超时时间,单位:秒,缺省:5
eureka.client.eureka-server-connect-timeout-seconds = 5

# 从Eureka服务器读取信息的超时时间,单位:秒,缺省:8
eureka.client.eureka-server-read-timeout-seconds = 8

# 获取实例时是否只保留状态为 UP 的实例,缺省:true
eureka.client.filter-only-up-instances = true

# Eureka服务端连接空闲时的关闭时间,单位:秒,缺省:30
eureka.client.eureka-connection-idle-timeout-seconds = 30

# 从Eureka客户端到所有Eureka服务端的连接总数,缺省:200
eureka.client.eureka-server-total-connections = 200

# 从Eureka客户端到每个Eureka服务主机的连接总数,缺省:50
eureka.client.eureka-server-total-connections-per-host = 50

2. Item Description

Eureka has some configuration items, you can probably know it by looking at the meaning of the information online, but if there is no intuitive guidance, and can not clearly understand their actual effects. Following are explanation of the configuration items by partial screenshot.

2.1 spring.application.name和eureka.instance.appname

At the same time configuration, eureka.instance.appnamea higher priority.

If no eureka.instance.appname, then use spring.application.namethe value, even if spring.application.namenot configured, the Unknown .

The configuration item corresponding to the contents of the red box interface Eureka:

2.2 eureka.instance.instance-id

CI eureka.instance.instance-idvalue determines display contents of the right side in the red box:

If not set eureka.instance.instance-id, then the value displayed will be generated by a number automatically determine Eureka:

2.3 eureka.instance.prefer-ip-address、eureka.instance.hostname、eureka.instance.ip-address

CI eureka.instance prefix, these burning absolute configuration items brain, according to Zhou's blog , at eureka.instance.prefer-ip-address = truethe time, using the examples of priority eureka.instance.ip-addressvalues to register, if not configured eureka.instance.ip-address, then the first non-loopback IP address to register .

At this point, we open the Eureka interface, in the example on the right, copy link address; or the mouse on the link under the map at the top right (do not click), you can get the address of the instance, as shown bottom left corner, you can see examples of this time registration is IP:

而当eureka.instance.prefer-ip-address = false时,同样的方式可以查看实例注册地址采用了主机名eureka.instance.hostname的值:

3. 配置Bean源码

最后,对应于本文出现的配置项,Eureka中定义的源码类如下。

eureka.server前缀的配置项

org.springframework.cloud.netflix.eureka.server.EurekaServerConfigBean

eureka.instance前缀的配置项

org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean

eureka.client前缀的配置项

org.springframework.cloud.netflix.eureka.EurekaClientConfigBean

参考博文:

周立的博客

https://www.cnblogs.com/liaojie970/p/8807023.html

https://www.cnblogs.com/li3807/p/7282492.html

https://www.jianshu.com/p/c18d140ad9f6

Guess you like

Origin www.cnblogs.com/zyon/p/11023750.html