一、前言
1.1、分布式面临的问题
微服务意味着将单个应用程序中的业务拆分为子服务。每个服务的粒度相对较小,因此系统中会有大量的服务。由于每个服务都需要必要的配置信息才能运行,因此集中式和动态配置管理工具是必不可少的。
[En]
Microservice means to split the business in a single application into a sub service. The granularity of each service is relatively small, so there will be a large number of services in the system. Since each service needs the necessary configuration information to run, a centralized and dynamic configuration management facility is essential.
SpringCloud提供了ConfigServer来解决这个问题,我们每一个微服务自己带着一个application.yml,上百个配置文件的管理....../(ㄒoㄒ)/~~
1.2、config 和 bus 的概述
SpringCloud Config为微服务架构中的微服务提供集中化的外部配置支持,配置服务器为各个不同微服务应用的所有环境提供了一个中心化的外部配置。
SpringCloud Config分为服务端和客户端两部分。服务端也称为分布式配置中心,它是一个独立的微服务应用,用来连接配置服务器并为客户端提供获取配置信息,加密/解密信息等访问接口
客户端则是通过指定的配置中心来管理应用资源,以及与业务相关的配置内容,并在启动的时候从配置中心获取和加载配置信息配置服务器默认采用git来存储配置信息,这样就有助于对环境配置进行版本管理,并且可以通过git客户端工具来方便的管理和访问配置内容。
Spring Cloud Bus 配合 Spring Cloud Config 使用可以实现配置的动态刷新。
Bus支持两种消息代理:RabbitMQ 和 Kafka