spring-cloud-config笔记

忽略元数据末尾
回到原数据开始处

     spring-cloud-config 简单来讲就是spring-cloud实现的分布式配置中心.与之前介绍的开源配置服务方案 disconf是一样的,spring-cloud-config分为服务与客户两端

     spring-cloud-config 使用git或者svn 甚至是本地的文件系统作为配置文件的仓库

   

     spring-cloud-config 用application,profile,label 三个维度来实现分布式配置管理和发布.

     application  : 使用spring-cloud-config服务的客户端名称

     profile :  这个很好理, manve的profile概念基本一致 可以理解成环境

     lable  :  这个可以理解成版本,如果使用的是git作为配置管理的仓库,label可以是分支名,tag的名称

   

    

       spring-cloud-config的原理就是 将远程git仓库中的配置文件clone到本地临时目录并加载至内存中

       spring-cloud-config客户端通过URL的形式来获取配置,spring官网的介绍如下

   /{application}/{profile}[/{label}]    /{application}-{profile}.yml    /{label}/{application}-{profile}.yml    /{application}-{profile}.properties    /{label}/{application}-{profile}.properties

       客户端可以通过http GET 请求直接获取spring-cloud-server的配置,实际应用中则不需要这样获取,只需要配置服务的host即可,如果使用Eureka,则只需要配置服务端的服务即可

      与开源方案disconf的对比

      控制台:

                disconf : 拥有自己的web界面管理配置

                spring-cloud-config: 没有web界面维护配置,主要靠git,svn等操作管理配置

      推拉模型:

                disconfi: 通过zookeeper实现推模型,拉模型

                spring-cloud-config: 通过git,svn实现 推拉模型

     配置存储:

                disconf: 通过数据库存储配置

                spring-cloud-config:通过git,以及本地文件的形式存储配置文件

    配置管理及发布:

                disconf : 拥有 环境,app,version 管理及发布配置.

                spring-cloud-config :  通过 application,profile , label 管理发布配置

    部署:

               disconf: web程序,既是控制台也是服务,高可用方案依赖nginx,zookeeper

               spring-cloud-config: spring-boot程序, 高可用方案依赖spring-cloud技术方案

 

    通过对比,disconf的优势是管理配置简单,而spring-cloud-config的优势是与我们的spring-cloud技术方案完美的集成,不需要单独的考虑高可用方案

    而且spring-cloud-config部署方式也优于disconf,使用git对于程序员非常的熟悉,而且git天生对版本的支持也是spring-cloud-config的优势 鸣谢崔老大. 

原文地址:https://www.cnblogs.com/xmanblue/p/6702641.html