springcloud 笔记

谁说我不能喝 提交于 2020-11-21 06:13:19

#官方教程

http://projects.spring.io/spring-cloud/

  • guide

https://github.com/spring-guides

伪官方教程

https://springcloud.cc https://legacy.gitbook.com/book/eacdy/spring-cloud-book/details

Actuator

https://blog.csdn.net/alinyua/article/details/80009435

management.endpoints.web.exposure.include="*" 或者 "hystrix.stream" 包含采集的数据.

健康检查

  • 配置法:
management:
  health:
    solr:
      enabled: false
    db:
      enabled: false
    elasticsearch:
      enabled: false
    jms:
      enabled: false
    mail:
      enabled: false
    mongo:
      enabled: false
    rabbit:
      enabled: false
    redis:
      enabled: false
  • 代码
/** 系统有以下项:
 * rabbitHealthIndicator
 * diskSpaceHealthIndicator
 * mongoHealthIndicator
 * refreshScopeHealthIndicator
 * discoveryClient
 * configServerHealthIndicator
 * hystrixHealthIndicator
 */
@Component("rabbitHealthIndicator")
open class rabbitHealthIndicator(var rabbitTemplate: RabbitTemplate) : RabbitHealthIndicator(rabbitTemplate) {
    override fun doHealthCheck(builder: Health.Builder?) {
        //跳过
    }
}

使用代码,也可以增加额外的分健康检查.

config

启用配置中心:

命令行参数不能覆盖 远程配置中心配置 的问题排查

spring-cloud-context-2.0.0.RC2-sources.jar!/org/springframework/cloud/bootstrap/config/PropertySourceBootstrapProperties.java 这个文件 三个属性:

  • allowOverride = true
  • overrideNone = false
  • overrideSystemProperties = true

看注释根本理解不了。 在get 方法上打断点开调试。

实验结果:

  1. config 使用文件系统, 不使用git (使用git ,修改配置需要提交 )

    spring.profiles.active: native spring.cloud.config.profile: native spring.cloud.config.server.native.search-locations: file:/home/udi/IdeaProjects/app.shop.java/config/git/{application}

  2. 在 配置中心相应的 application应用配置文件中 添加 spring.cloud.config.overrideNone: true 文件位置: /home/udi/IdeaProjects/app.shop.java/config/git/shop-api/application.yml

高可用

https://blog.csdn.net/w1054993544/article/details/78086840

unavailable-replicas

http://chenja.iteye.com/blog/2375104 https://blog.csdn.net/u012470019/article/details/77973156 https://www.cnblogs.com/sweetchildomine/p/8830863.html

有效: 1.eureka.instance.appname 必须等于 spring.application.name 并且不可缺省,所以直接占位符 appname: ${spring.application.name} 2.prefer-ip-address: 必须为false 或者缺省 3.fetch-registry 必须非false 或者缺省 4. 所有的设置: eureka.client.register-with-eureka=false eureka.client.fetch-registry=false

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!