Eureka常用配置详解

Part XVII. Appendix: Compendium of Configuration Properties

现在来讨论一下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服务器上拉数据,eureka.client.g-zip-content发现他默认是true,说明eureka他传输的内容是不是通过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 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.可用区的一个map,可用区的一个映射,可以理解为一个完整的URL,然后多个之间可以用逗号分隔,可以是一个URL,如果是多个的话可以用逗号分隔,通常包含很多东西,协议http,host,端口,上下文,版本信息,我们可以去改变配置,他有一个刷新周期eureka.dashboard.enabledeureka.dashboard.enabled=false会有什么效果呢,发现404了,dashboard是什么,其实就是eureka的首页,就是他的界面eureka.dashboard.path默认是/,那这个有什么应用场景呢,假设我现在用的是高可用的eureka,那是不是每一个eureka都可以访问,我可能不想记那么多,只允许一个可以进行dashboard,其他的把它禁用,我只要记住端口IP就可以了,另外一个他可以自定义路径,这样我可以做一些伪装之类的,就像有的时候一些系统,他默认的管理路径是admin,我就可以自定义,当然适用场景也非常有限了eureka.instance.appnamedruid德鲁伊 eureka我找到了! eureka.instance.appname=USER-SERVICE-HAHA
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结合使用是有一定的冲突的,appname才是最原本的注册到eureka上面的app的名称eureka.instance.data-center-info也是AWS的eureka.instance.hostname在高可用的Eureka里面,指定这个eureka的主机名是什么,假设我现在在用户微服务上面,配置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有关系的键值对,信息发送给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状态页面的URLeureka.instance.virtual-host-name使用HTTP的虚拟主机名eureka.server.peer-eureka-status-refresh-time-interval-mseureka对等体状态的刷新时间,刷新周期是毫秒

 


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部