Eureka常用配置详解
生活随笔
收集整理的這篇文章主要介紹了
Eureka常用配置详解
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
Part XVII. Appendix: Compendium of Configuration Properties
現(xiàn)在來討論一下Eureka的常用配置,Eureka有非常多的配置項Appendix:Compendium of Configuration Propertieshttps://cloud.spring.io/spring-cloud-static/Finchley.RELEASE/multi/ multi__appendix_compendium_of_configuration_properties.html所有SpringCloud的配置項都在這里那我們看一下Eureka有哪些,可能有上百個eureka.client.allow-redirects允許重定向eureka.client.availability-zones這個是AWS里面用的eureka.client.decoder-name解碼器的名稱This is a transient config and once the latest codecs are stable, can be removed (as there will only be one)eureka.client.enabledFlag to indicate that the Eureka client is enabled.表明Eureka Client是否可用的一個標識eureka.client.fetch-registry在standalone里面我們有用過Indicates whether this client should fetch eureka registry information from eureka server.表明此客戶端是否從eureka服務器端拉取eureka注冊表的信息,也就是他要不要從eureka服務器上拉數(shù)據(jù),eureka.client.g-zip-content發(fā)現(xiàn)他默認是true,說明eureka他傳輸?shù)膬?nèi)容是不是通過gzip壓縮的eureka.client.heartbeat-executor-thread-pool-size線程池的大小eureka.client.prefer-same-zone-eurekaeureka.client.region在us-east-1里面,默認是美東,這個region,Gets the region (used in AWS datacenters) where this instance resides.eureka.client.register-with-eurekaIn some cases, you do not want your instances to be discovered whereas you just want do discover other instances.單點的eureka模式eureka.client.registry-fetch-interval-seconds這個是30秒Indicates how often(in seconds) to fetch the registry information from the eureka server.從eureka服務器獲取注冊信息的頻率,一秒為單位eureka.client.service-url他是個map,/*** Map of availability zone to list of fully qualified URLs to communicate with eureka* server. Each value can be a single URL or a comma separated list of alternative* locations.** Typically the eureka server URLs carry protocol,host,port,context and version* information if any. Example:* http://ec2-256-156-243-129.compute-1.amazonaws.com:7001/eureka/** The changes are effective at runtime at the next service url refresh cycle as* specified by eurekaServiceUrlPollIntervalSeconds.*/ private Map<String, String> serviceUrl = new HashMap<>();看下它是什么Map of availability zone to list of fully qualified URLs to communicate with eureka server. Each value can be a single URL or a comma separated list of alternative locations.Typically the eureka server URLs carry protocol,host,port,context and version information if any. Example: http://ec2-256-156-243-129.compute-1.amazonaws.com:7001/eureka/The changes are effective at runtime at the next service url refresh cycle as specified by eurekaServiceUrlPollIntervalSeconds.可用區(qū)的一個map,可用區(qū)的一個映射,可以理解為一個完整的URL,然后多個之間可以用逗號分隔,可以是一個URL,如果是多個的話可以用逗號分隔,通常包含很多東西,協(xié)議http,host,端口,上下文,版本信息,我們可以去改變配置,他有一個刷新周期eureka.dashboard.enabledeureka.dashboard.enabled=false會有什么效果呢,發(fā)現(xiàn)404了,dashboard是什么,其實就是eureka的首頁,就是他的界面eureka.dashboard.path默認是/,那這個有什么應用場景呢,假設我現(xiàn)在用的是高可用的eureka,那是不是每一個eureka都可以訪問,我可能不想記那么多,只允許一個可以進行dashboard,其他的把它禁用,我只要記住端口IP就可以了,另外一個他可以自定義路徑,這樣我可以做一些偽裝之類的,就像有的時候一些系統(tǒng),他默認的管理路徑是admin,我就可以自定義,當然適用場景也非常有限了eureka.instance.appnamedruid德魯伊 eureka我找到了! eureka.instance.appname=USER-SERVICE-HAHA #debug=true server.port=7900#server.context-path=/boot02spring.http.encoding.charset=UTF-8 spring.http.encoding.enabled=true spring.http.encoding.force=truelogging.level.com.learn=trace #logging.file=D:/springboot.log logging.file=springboot.log logging.pattern.console=%d{yyyy-MM-dd} [%thread] %-5level %logger{50} - %msg%n logging.pattern.file=%d{yyyy-MM-dd} ==== [%thread] %-5level ==== %logger{50} ==== %msg%n #spring.resources.static-locations=classpath:/hello,classpath:/learnspring.datasource.username=root spring.datasource.password=123456 spring.datasource.url=jdbc:mysql://59.110.158.145:3306/SpringCloud?useSSL=false&useUnicode=true&characterEncoding=UTF-8 spring.datasource.driver-class-name=com.mysql.jdbc.Driver spring.datasource.type=com.alibaba.druid.pool.DruidDataSource spring.datasource.initialSize=5 spring.datasource.minIdle=5 spring.datasource.maxActive=20 spring.datasource.maxWait=60000mybatis.config-location=classpath:mybatis/mybatis-config.xml mybatis.mapper-locations=classpath:mybatis/mapper/*.xmleureka.client.serviceUrl.defaultZone=http://admin:1234@10.40.8.152:8761/eurekaspring.application.name=microservice-simple-provider-user eureka.instance.prefer-ip-address=true eureka.instance.instance-id=${spring.application.name}:${spring.cloud.client.ipAddress}:${spring.application.instance_id:${server.port}} #eureka.client.healthcheck.enabled=true spring.redis.host=10.40.8.152 spring.redis.password=aztech spring.redis.port=6379eureka.instance.appname=USER-SERVICE-HAHA eureka:client:healthcheck:enabled: trueserviceUrl:defaultZone: http://admin:1234@10.40.8.152:8761/eureka org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean.appname/*** Get the name of the application to be registered with eureka.*/ private String appname = UNKNOWN;private static final String UNKNOWN = "unknown";他的作用是填坑,swagger(api document)它是可以支持聲明式的注解,然后通過注解幫我們自動的生成API文檔,它是這樣的一個工具https://swagger.io/簡單的說就是我寫幾個注解,Swagger的注解,跟Spring Cloud結(jié)合使用是有一定的沖突的,appname才是最原本的注冊到eureka上面的app的名稱eureka.instance.data-center-info也是AWS的eureka.instance.hostname在高可用的Eureka里面,指定這個eureka的主機名是什么,假設我現(xiàn)在在用戶微服務上面,配置hostname等于user,說明user的主機名是user,我就可以用http:user:7900/去訪問,我就會把這個信息注冊給eureka了Changing the Eureka Instance IDhttps://cloud.spring.io/spring-cloud-static/spring-cloud-netflix/1.3.1.RELEASE/A vanilla Netflix Eureka instance is registered with an ID that is equal to its host name (i.e. only one service per host). Spring Cloud Eureka provides a sensible default that looks like this: ${spring.cloud.client.hostname}:${spring.application.name} :${spring.application.instance_id:${server.port}}}. For example myhost:myappname:8080.eureka.instance.ip-addresseureka.instance.metadata-map獲取metadata的鍵值對,跟instance有關(guān)系的鍵值對,信息發(fā)送給eureka serverGets the metadata name/value pairs associated with this instance. This information is sent to eureka server and can be used by other instances.eureka.instance.namespaceGet the namespace used to find properties. Ignored in Spring Cloud.eureka.instance.non-secure-porteureka.instance.prefer-ip-address鼠標拖上去的時候顯示的是IP,也就是鏈接是IP,注冊到eureka上面的是IPeureka.instance.secure-health-check-urleureka.instance.secure-port默認HTTPS的端口,是否啟用HTTPS默認是不啟用eureka.instance.secure-virtual-host-name虛擬的主機名eureka.instance.status-page-url狀態(tài)頁面的URLeureka.instance.virtual-host-name使用HTTP的虛擬主機名eureka.server.peer-eureka-status-refresh-time-interval-mseureka對等體狀態(tài)的刷新時間,刷新周期是毫秒?
總結(jié)
以上是生活随笔為你收集整理的Eureka常用配置详解的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Eureka深入理解
- 下一篇: Eurek Ribbon Feign常见