微服務Spring Cloud Eureka 客戶端-實例配置(eureka.instance.xxx) 原

Eureka配置系列:

Eureka 客戶端-基本配置 https://my.oschina.net/langxSpirit/blog/1821247
Eureka 客戶端-實例配置(本文)  https://my.oschina.net/langxSpirit/blog/1821251
Eureka 服務端-基本配置  http://https://my.oschina.net/langxSpirit/blog/1821256
Eureka 服務端-其他配置  https://my.oschina.net/langxSpirit/blog/1821257

 

提取自 spring-cloud-netflix-eureka-client-1.4.4.RELEASE.jar!/META-INF/spring-configuration-metadata.json
Bean類:org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean
參考配置說明:https://github.com/Netflix/eureka/blob/master/eureka-client/src/main/java/com/netflix/appinfo/EurekaInstanceConfig.java

常見配置

name(eureka.instance.xxx開頭配置) defaultValue description
instance-id   Get the unique Id (within the scope of the appName) of this instance to be registered with eureka.
此實例註冊到eureka服務端的唯一的實例ID,其組成爲${spring.application.name}:${spring.application.instance_id:${random.value}}
appname unknown Get the name of the application to be registered with eureka.
服務名,默認取 spring.application.name 配置值
hostname   The hostname if it can be determined at configuration time (otherwise it will be guessed from OS primitives).
主機名,不配置的時候講根據操作系統的主機名來獲取
prefer-ip-address false Flag to say that, when guessing a hostname, the IP address of the server should be used in prference to the hostname reported by the OS.
是否優先使用IP地址作爲主機名的標識
如果設置了tru,則使用該屬性配置的IP,否則自動獲取除環路IP外的第一個IP地址
ip-address   Get the IPAdress of the instance. This information is for academic purposes only as the communication from other instances primarily happen using the information supplied in {@link #getHostName(boolean)}.
IP地址
lease-expiration-duration-in-seconds 90 Indicates the time in seconds that the eureka server waits since it received the last heartbeat before it can remove this instance from its view and there by disallowing traffic to this instance. Setting this value too long could mean that the traffic could be routed to the instance even though the instance is not alive. Setting this value too small could mean, the instance may be taken out of traffic because of temporary network glitches.This value to be set to atleast higher than the value specified in leaseRenewalIntervalInSeconds.
定義服務續約任務(心跳)的調用間隔,單位:秒
表示eureka client發送心跳給server端的頻率。如果在leaseExpirationDurationInSeconds後,server端沒有收到client的心跳,則將摘除該instance。除此之外,如果該instance實現了HealthCheckCallback,並決定讓自己unavailable的話,則該instance也不會接收到流量。
lease-renewal-interval-in-seconds 30 Indicates how often (in seconds) the eureka client needs to send heartbeats to eureka server to indicate that it is still alive. If the heartbeats are not received for the period specified in leaseExpirationDurationInSeconds, eureka server will remove the instance from its view, there by disallowing traffic to this instance. Note that the instance could still not take traffic if it implements HealthCheckCallback and then decides to make itself unavailable.
定義服務失效的時間,單位:秒
表示eureka server至上一次收到client的心跳之後,等待下一次心跳的超時時間,在這個時間內若沒收到下一次心跳,則將移除該instance。
該值至少應該大於leaseRenewalIntervalInSeconds
home-page-url   Gets the absolute home page URL for this instance. The users can provide the homePageUrlPath if the home page resides in the same instance talking to eureka, else in the cases where the instance is a proxy for some other server, users can provide the full URL. If the full URL is provided it takes precedence. It is normally used for informational purposes for other services to use it as a landing page. The full URL should follow the format http://
獲取此實例的絕對主頁URL路徑,爲其他服務提供信息時使用的路徑,默認爲null
home-page-url-path / Gets the relative home page URL Path for this instance. The home page URL is then constructed out of the hostName and the type of communication - secure or unsecure. It is normally used for informational purposes for other services to use it as a landing page.
獲取此實例的相關主頁URL路徑,然後構造出主機名,安全端口等,默認爲/
health-check-url   Gets the absolute health check page URL for this instance. The users can provide the healthCheckUrlPath if the health check page resides in the same instance talking to eureka, else in the cases where the instance is a proxy for some other server, users can provide the full URL. If the full URL is provided it takes precedence. <p> It is normally used for making educated decisions based on the health of the instance - for example, it can be used to determine whether to proceed deployments to an entire farm or stop the deployments without causing further damage. The full URL should follow the format http://
配置健康檢查頁面的URL,絕對路徑
health-check-url-path /health Gets the relative health check URL path for this instance. The health check page URL is then constructed out of the hostname and the type of communication - secure or unsecure as specified in securePort and nonSecurePort. It is normally used for making educated decisions based on the health of the instance - for example, it can be used to determine whether to proceed deployments to an entire farm or stop the deployments without causing further damage.
健康檢查頁面的URL,相對路徑,默認使用 HTTP 訪問,如果需要使用 HTTPS則需要使用絕對路徑
secure-health-check-url   Gets the absolute secure health check page URL for this instance. The users can provide the secureHealthCheckUrl if the health check page resides in the same instance talking to eureka, else in the cases where the instance is a proxy for some other server, users can provide the full URL. If the full URL is provided it takes precedence. <p> It is normally used for making educated decisions based on the health of the instance - for example, it can be used to determine whether to proceed deployments to an entire farm or stop the deployments without causing further damage. The full URL should follow the format http://
獲取此實例的絕對安全健康檢查網頁的URL路徑,默認爲null

其他配置

name(eureka.instance.xxx開頭配置) defaultValue description
a-s-g-name   Gets the AWS autoscaling group name associated with this instance. This information is specifically used in an AWS environment to automatically put an instance out of service after the instance is launched and it has been disabled for traffic..
與此實例相關聯 AWS自動縮放組名稱。此項配置是在AWS環境專門使用的實例啓動,它已被用於流量停用後自動把一個實例退出服務。
app-group-name   Get the name of the application group to be registered with eureka.
data-center-info   Returns the data center this instance is deployed. This information is used to get some AWS specific instance information if the instance is deployed in AWS.
該實例被部署在數據中心
default-address-resolution-order   獲取實例的網絡地址,默認爲[]
environment    
initial-status   Initial status to register with rmeote Eureka server.
instance-enabled-onit false Indicates whether the instance should be enabled for taking traffic as soon as it is registered with eureka. Sometimes the application might need to do some pre-processing before it is ready to take traffic.
實例註冊到eureka服務器時,是否開啓通訊,默認爲false
metadata-map   Gets the metadata name/value pairs associated with this instance. This information is sent to eureka server and can be used by other instances.
獲取與此實例相關聯的元數據(key,value)。這個信息被髮送到eureka服務器,其他實例可以使用。
namespace eureka Get the namespace used to find properties. Ignored in Spring Cloud.
獲取用於查找屬性的命名空間,默認爲eureka
non-secure-port 80 Get the non-secure port on which the instance should receive traffic.
獲取該實例應該接收通信的非安全端口。默認爲80
non-secure-port-enabled true Indicates whether the non-secure port should be enabled for traffic or not.
該實例應該接收通信的非安全端口是否啓用,默認爲true
secure-port 443 Get the Secure port on which the instance should receive traffic.
 獲取該實例應該接收通信的安全端口,默認爲443
secure-port-enabled false Indicates whether the secure port should be enabled for traffic or not.
該實例應該接收通信的安全端口是否啓用,默認爲false
secure-virtual-host-name unknown Gets the secure virtual host name defined for this instance. This is typically the way other instance would find this instance by using the secure virtual host name.Think of this as similar to the fully qualified domain name, that the users of your services will need to find this instance.

by 斯武丶風晴 https://my.oschina.net/langxSpirit

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章