Spring Cloud Config(一):聊聊分布式配置中心 Spring Cloud Config
目录
Spring Cloud Config(一):聊聊分布式配置中心 Spring Cloud Config
Spring Cloud Config(二):基于Git搭建配置中心
Spring Cloud Config(三):基于JDBC搭建配置中心
Spring Cloud Config(四):配置信息动态刷新
Spring Cloud Config(五):配置中心服务端Config Server源码解析
Spring Cloud Config(六):配置中心客户端Client源码解析
Spring Cloud Config(七):配置中心自定义扩展
Spring Cloud Config(八):Client 端覆盖Server端配置属性
Spring Cloud Config(九):Config Server 端配置文件安全保护
Spring Cloud Config(十):快速响应失败和重试机制
1、Spring Cloud Config 定义
Spring Cloud Config provides server and client-side support for externalized configuration in a distributed system. With the Config Server you have a central place to manage external properties for applications across all environments. The concepts on both client and server map identically to the Spring Environment and PropertySource abstractions, so they fit very well with Spring applications, but can be used with any application running in any language. As an application moves through the deployment pipeline from dev to test and into production you can manage the configuration between those environments and be certain that applications have everything they need to run when they migrate. The default implementation of the server storage backend uses git so it easily supports labelled versions of configuration environments, as well as being accessible to a wide range of tooling for managing the content. It is easy to add alternative implementations and plug them in with Spring configuration.
Spring Cloud Config 为分布式系统中的外部化配置提供服务器和客户端支持。 使用Config Server,您可以在所有环境中管理应用程序的外部属性。客户端和服务器上的概念与Spring Environment和PropertySource抽象相同,因此它们非常适合Spring应用程序,但可以与任何语言运行的任何应用程序一起使用。当应用程序通过部署管道从开发到测试并进入生产时,您可以管理这些环境之间的配置,并确保应用程序具有迁移时需要运行的所有内容。他默认的服务器存储后端实现使用git,因此它可以轻松支持配置环境的标签版本,并且可以访问各种用于管理内容的工具。 基于spring配置可以很方便的实现扩展。
2、为什么选择 Spring Cloud Config
那么有人可能会问了,业界关于分布式配置中心有多种开源的组件,如携程开源的 Apollo、 百度的 Disconf、淘宝的 Diamond 等,已经不少了,为啥还会诞生Spring Cloud Config呢?
应用服务除了实现系统功能,还需要连接资源和其它应用,经常需要调整服务的配置来改变应用的行为,如切换不同数据库,设置功能开关等。随着微服务数量的不断增加,需要系统具备可伸缩性和可扩展性,除此之外就是需要管理服务实例的配置数据。在开发阶段配置信息由各个服务自己管理,但是到了生产环境会给运维带来很多不便。因此系统需要建立一个统一的配置管理中心,常见配置中心的实现方法有:
硬编码,缺点就是需要修改代码
放在xml等配置文件中和应用一起打包,缺点就是配置修改需要重新打包和重启
放在文件系统中,缺点就是依赖操作系统
配置到系统环境变量,缺点是需要大量的配置工作,不方便管理
个人看来,Spring Cloud Config 在以下几方面还是有比较明显的优势,所以可能是为什么要再造一个轮子的原因吧:
1、基于应用、环境、版本三个维度管理
应用(application)
每个配置都是属于某一个应用的
环境(profile)
每个配置都是区分环境的,如dev, test, prod等
版本(label)
这个可能是一般的配置中心所缺乏的,就是对同一份配置的不同版本管理
Spring Cloud Config提供版本的支持,也就是说对于一个应用的不同部署实例,可以从服务端获取到不同版本的配置,这对于一些特殊场景如:灰度发布,A/B测试等提供了很好的支持。
2、多种存储方式
基于Git存储,一方面程序员非常熟悉,另一方面在部署上会非常简单,而且借助于Git天生就能非常好的支持版本,同时它还支持其它的存储如本地文件、SVN、jdbc等
3、Spring无缝集成
它无缝支持Spring里面Environment和PropertySource的接口
所以对于已有的Spring应用程序的迁移成本非常低,在配置获取的接口上是完全一致的
3、Spring Cloud Config 简介

上图简要描述了一个普通Spring Cloud Config应用的场景。其中主要有以下几个组件:
- Config Client
Client很好理解,就是使用了Spring Cloud Config的应用
Spring Cloud Config提供了基于Spring的客户端,应用只要在代码中引入Spring Cloud Config Client的jar包即可工作
- Config Server
Config Server是需要独立部署的一个web应用,它负责把git上的配置返回给客户端
- Remote Git Repository
远程Git仓库,一般而言,我们会把配置放在一个远程仓库,通过git客户端来管理配置
- Local Git Repostiory
Config Server接到来自客户端的配置获取请求后,会先把远程仓库的配置clone到本地的临时目录,然后从临时目录读取配置并返回
4、总结
Spring Cloud Config 项目
提供 服务端 和 客户端 支持
集中式 管理分布式环境下的应用配置
基于 Spring 环境,无缝 与 Spring 应用集成
可用于 任何 语言开发的程序
默认实现基于 git 仓库,可以进行 版本管理
可替换 自定义实现
Spring Cloud Config Server 作为配置中心服务端
拉取配置时更新 git 仓库副本,保证是最新结果
支持数据结构丰富,yml, json, properties 等
配合 eureke 可实现服务发现,配合 cloud bus 可实现配置推送更新
配置存储基于 git 仓库,可进行版本管理
简单可靠,有丰富的配套方案
Spring Cloud Config Client 默认客户端实现
SpringBoot 项目不需要改动任何代码,加入一个启动配置文件指明使用 ConfigServer 上哪个配置文件即可
Spring Cloud Config(一):聊聊分布式配置中心 Spring Cloud Config的更多相关文章
- SpringCloud(6)分布式配置中心Spring Cloud Config
1.Spring Cloud Config 简介 在分布式系统中,由于服务数量巨多,为了方便服务配置文件统一管理,实时更新,所以需要分布式配置中心组件.在Spring Cloud中,有分布式配置中心组 ...
- SpringCloud教程 | 第六篇: 分布式配置中心(Spring Cloud Config)
一.简介 在分布式系统中,由于服务数量巨多,为了方便服务配置文件统一管理,实时更新,所以需要分布式配置中心组件.在Spring Cloud中,有分布式配置中心组件spring cloud config ...
- 史上最简单的SpringCloud教程 | 第六篇: 分布式配置中心(Spring Cloud Config)
一.简介 在分布式系统中,由于服务数量巨多,为了方便服务配置文件统一管理,实时更新,所以需要分布式配置中心组件. 在Spring Cloud中,有分布式配置中心组件spring cloud confi ...
- 第六篇: 分布式配置中心(Spring Cloud Config)
一.简介 在分布式系统中,由于服务数量巨多,为了方便服务配置文件统一管理,实时更新,所以需要分布式配置中心组件. 在Spring Cloud中,有分布式配置中心组件spring cloud confi ...
- SpringCloud教程 | 第六篇: 分布式配置中心(Spring Cloud Config)(Finchley版本)
在上一篇文章讲述zuul的时候,已经提到过,使用配置服务来保存各个服务的配置文件.它就是Spring Cloud Config. 一.简介 在分布式系统中,由于服务数量巨多,为了方便服务配置文件统一管 ...
- 【SpringCloud】第六篇: 分布式配置中心(Spring Cloud Config)
前言: 必需学会SpringBoot基础知识 简介: spring cloud 为开发人员提供了快速构建分布式系统的一些工具,包括配置管理.服务发现.断路器.路由.微代理.事件总线.全局锁.决策竞选. ...
- 一起来学Spring Cloud | 第七章:分布式配置中心(Spring Cloud Config)
上一章节,我们讲解了服务网关zuul,本章节我们从git和本地两种存储配置信息的方式来讲解springcloud的分布式配置中心-Spring Cloud Config. 一.Spring Cloud ...
- Spring Cloud(九)高可用的分布式配置中心 Spring Cloud Config 集成 Eureka 服务
上一篇文章,讲了SpringCloudConfig 集成Git仓库,这一篇我们讲一下SpringCloudConfig 配和 Eureka 注册中心一起使用 在分布式系统中,由于服务数量巨多,为了方便 ...
- Spring Cloud(八)高可用的分布式配置中心 Spring Cloud Config
在分布式系统中,由于服务数量巨多,为了方便服务配置文件统一管理,实时更新,所以需要分布式配置中心组件.在Spring Cloud中,有分布式配置中心组件spring cloud config,它支持配 ...
随机推荐
- Linux装好系统之后配置环境
1.配置IP地址vi /etc/sysconfig/network-scripts/ifcfg-eth0 ONBOOT=yes NM_CONTROLLED=yes BOOTPROTO=static D ...
- MVC5项目转.Net Core 2.2学习与填坑记录(1)
流程都是自己摸索,错误地方随便指正... 老项目过于臃肿,并且所有请求都是提交到一个api中,这样当api挂掉的时候,基本所有的项目都瘫痪掉了. 在4月底的时候,下决心将项目用微服务进行重写,刚开始的 ...
- Python练习_函数进阶_day10
1. 1.作业 1,写函数,接收n个数字,求这些参数数字的和.(动态传参) 2,读代码,回答:代码中,打印出来的值a,b,c分别是什么?为什么? a=10 b=20 def test5(a,b): p ...
- js大数计算之计算
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- iOS8中UIActionSheet弹出UIImagePickerController异常处理
iOS8之后,UIActionSheet改父于UIAlertController.带来了一丢丢兼容性的问题. 比如在弹出的actionsheet中选择从相册选择图片或者拍照,之后弹出UIImagePi ...
- Linux下安装php报错:libxml2 not found. Please check your libxml2 installation
ubuntu/debian: apt-get install libxml2-dev centos/redhat: yum install libxml2-devel
- vue嵌套数据多层级里面的数据不自动更新渲染dom
可以尝试手动调用更新 主要代码: vm.$forceUpdate() 官网
- Server SAN
http://blog.sina.com.cn/s/blog_5946bd590102veni.html http://blog.sina.com.cn/s/blog_5946bd590102vemm ...
- java_赋值与初始化
一.赋值(是给变量指定一个值或者是改变 一个变量的值) 变量类型 变量名=表达式 int i=10; 二.初始化 生成一个变量以后,必须通过明确的赋值语句进行初始化,然后在使用这个变量. 局部变量: ...
- PAT Advanced 1071 Speech Patterns (25 分)
People often have a preference among synonyms of the same word. For example, some may prefer "t ...