Eureka的配置:

自我保护:表示eureka进入了自我保护模式,eureka启动的时候会从高可用其他节点获取注册表信息,eureka client会每30秒发送心跳,如果eureka server进入了自我保护模式(他怀疑是高可用的问题,就不会把client节点非删掉)。

Eureka

Eureka Environment的配置:

eureka.environment: 字符串

参考文档:

https://github.com/Netflix/eureka/wiki/Configuring-Eureka

Eureka DataCenter的配置

eureka.datacenter: cloud

https://github.com/Netflix/eureka/wiki/Configuring-Eureka

这边说:配置-Deureka.datacenter=cloud,这样eureka将会知道是在AWS云上

Eureka开启自我保护的提示

EMERGENCY! EUREKA MAY BE INCORRECTLY CLAIMING INSTANCES ARE UP WHEN THEY'RE NOT. RENEWALS ARE LESSER THAN THRESHOLD AND HENCE THE INSTANCES ARE NOT BEING EXPIRED JUST TO BE SAFE.

Eureka注册服务慢的问题如何解决?

eureka.instance.leaseRenewalIntervalInSeconds

参考文档:

http://cloud.spring.io/spring-cloud-static/Camden.SR1/#_why_is_it_so_slow_to_register_a_service

原文:

Why is it so Slow to Register a Service?

Being an instance also involves a periodic heartbeat to the registry (via the client’s serviceUrl) with default duration 30 seconds. A service is not available for discovery by clients until the instance, the server and the client all have the same metadata in their local cache (so it could take 3 heartbeats). You can change the period using eureka.instance.leaseRenewalIntervalInSeconds and this will speed up the process of getting clients connected to other services. In production it’s probably better to stick with the default because there are some computations internally in the server that make assumptions about the lease renewal period.

翻译:

作为实例还涉及到与注册中心的周期性心跳,默认持续时间为30秒(通过serviceUrl)。在实例、服务器、客户端都在本地缓存中具有相同的元数据之前,服务不可用于客户端发现(所以可能需要3次心跳)。你可以使用eureka.instance.leaseRenewalIntervalInSeconds 配置,这将加快客户端连接到其他服务的过程。在生产中,最好坚持使用默认值,因为在服务器内部有一些计算,他们对续约做出假设。

1.1. 如何解决Eureka Server不踢出已关停的节点的问题?

server端:

eureka.server.enable-self-preservation (设为false,关闭自我保护主要)

eureka.server.eviction-interval-timer-in-ms     清理间隔(单位毫秒,默认是60*1000)

client端:

eureka.client.healthcheck.enabled = true 开启健康检查(需要spring-boot-starter-actuator依赖)

eureka.instance.lease-renewal-interval-in-seconds =10 租期更新时间间隔(默认30秒)

eureka.instance.lease-expiration-duration-in-seconds =30  租期到期时间(默认90秒)

示例:

服务器端配置:

eureka:

server:

enableSelfPreservation: false

evictionIntervalTimerInMs: 4000

客户端配置:

eureka:

instance:

leaseRenewalIntervalInSeconds: 10

leaseExpirationDurationInSeconds: 30

注意

更改Eureka更新频率将打破服务器的自我保护功能

https://github.com/spring-cloud/spring-cloud-netflix/issues/373

1.2. Eureka配置instanceId显示IP

eureka:

client:

serviceUrl:

defaultZone: http://localhost:8761/eureka/

instance:

preferIpAddress: true

instance-id: ${spring.cloud.client.ipAddress}:${server.port}

1.3. Eureka配置最佳实践总结

https://github.com/spring-cloud/spring-cloud-netflix/issues/203

Ribbon

自定义配置时,@Configuration和@ComponentScan包不应重叠

使用RestTemplate时,想要获得一个List时,应该用数组,而不应该直接用List

Feign

自定义配置时,@Configuration和@ComponentScan包不应重叠

@FeignClient所在的接口中,不支持@GetMapping等组合注解

使用@PathVariable时,需要指定其value

Feign暂不支持复杂对象作为一个参数

springcloud6---Eureka的配置:的更多相关文章

  1. Eureka服务配置与进阶

    1. Eureka服务配置与进阶 1.1. 主要配置 1.1.1. 服务端(eureka.server.*) enableSelfPreservation默认true,启用注册中心的自保护机制,Eur ...

  2. SpringCloud系列四:Eureka 服务发现框架(定义 Eureka 服务端、Eureka 服务信息、Eureka 发现管理、Eureka 安全配置、Eureka-HA(高可用) 机制、Eureka 服务打包部署)

    1.概念:Eureka 服务发现框架 2.具体内容 对于服务发现框架可以简单的理解为服务的注册以及使用操作步骤,例如:在 ZooKeeper 组件,这个组件里面已经明确的描述了一个服务的注册以及发现操 ...

  3. JAVA Spring Cloud 注册中心 Eureka 相关配置

    转载至  https://www.cnblogs.com/fangfuhai/p/7070325.html Eureka客户端配置       1.RegistryFetchIntervalSecon ...

  4. spring cloud Eureka client配置(consumer通过Eureka发起对provider的调用)

    参考:http://www.ityouknow.com/springcloud/2017/05/12/eureka-provider-constomer.html springboot版本:2.0.3 ...

  5. SpringCloud学习笔记(4)----Spring Cloud Netflix之Eureka的配置

    1. Eureka监控配置 Eureka的客户端需要加入依赖 <dependency> <groupId>org.springframework.boot</groupI ...

  6. springcloud(四):Eureka的配置详解

    在Eureka的服务治理体系中,主要分为服务端和客户端两个不同的角色,服务端为服务注册中心,客户端为提供各个接口的微服务应用,这里介绍一下Eureka的配置. Eureka服务端配置 在实际应用中,我 ...

  7. eureka server 配置

    启动类 import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure. ...

  8. 笔记:Spring Cloud Eureka 常用配置及说明

    配置参数 默认值 说明 服务注册中心配置    Bean类:org.springframework.cloud.netflix.eureka.server.EurekaServerConfigBean ...

  9. Spring Cloud Eureka 常用配置详解,建议收藏!

    前几天,栈长分享了 <Spring Cloud Eureka 注册中心集群搭建,Greenwich 最新版!>,今天来分享下 Spring Cloud Eureka 常用的一些参数配置及说 ...

  10. Spring Cloud Eureka 常用配置及说明

    配置参数 默认值 说明 服务注册中心配置 Bean类:org.springframework.cloud.netflix.eureka.server.EurekaServerConfigBean eu ...

随机推荐

  1. Winform的学习

    昨天由于一些原因没有上课啦,虽然也看啦一些东西,但是感觉太少也就没有来啦,嘿嘿,今天认真地了解啦winform,学习了一些控件的使用,但是感觉好多属性知道怎么用的,却还是记得不太清楚,感觉看到啦知道, ...

  2. HTML5中新的结构元素

    HTML5中新的结构元素 1. HTML5初始文件 1.1.doctype 在之前,doctype的声明是这样的: "http://www.w3. org/TR/html4/strict.d ...

  3. 银联支付-产品测试sdk使用流程

    准备工作: 到https://open.unionpay.com/ajweb/help/file/techFile?productId=66下载开发文档和sdk 下载之后进行解压将Java Versi ...

  4. sencha touch 扩展篇之将sencha touch打包成安装程序(上)- 使用sencha cmd打包安装程序

    由于最近一直忙着android原生的开发,很久没有更新博客了,官方的sencha cmd工具功能非常强大,创建项目,压缩项目,打包安装程序都能轻松实现,这讲我们就给大家介绍下如何使用sencha cm ...

  5. Linux系统下 Supervisor 安装搭建

    在 web 应用部署到线上后,需要保证应用一直处于运行状态,在遇到程序异常.报错等情况,导致 web 应用终止时,需要保证程序可以立刻重启,继续提供服务. 所以,就需要一个工具,时刻监控 web 应用 ...

  6. request常用的方法

    request方法综合:-- 返回请求方式:-request.getMethod()-----GET返回URI中的资源名称(位于URL中端口后的资源路径):-request.getRequestURI ...

  7. oracle 日期常用函数(转载)

      日期运算函數     ADD_MONTHS(d,n)    --时间点d再加上n个月      ex.     select sysdate, add_months(sysdate,2) aa f ...

  8. mongodb实现对某列求和SUM

    mongodb数据如下: db.cpc_0103.find() { "a" : 8, "b" : "108177_200701010000" ...

  9. 使用_Capistrano_进行自动化部署(2)

    之前的一篇文章是为了解决问题而写的,很多东西都没有介绍清楚,这一篇文章就是完整介绍一下 Capistrano,主要的参考来源是 Modern PHP 这本书. Capistrano 是用于自动部署应用 ...

  10. HRBUST - 1153 意外 HRBUST - 1153 (数论)

    意外 Time Limit: 1000 MS Memory Limit: 65536 K Total Submit: 326(87 users) Total Accepted: 97(63 users ...