运维

运维

Products

当前位置:首页 > 运维 >

分布式配置中心有哪些?如何创建一个分布式配置中心?

96SEO 2025-06-26 16:01 1


可用于分布式配置中心的有哪些?分布式配置中心怎么创建?

一、 分布式配置中心的少许不了性

在分布式系统中,因为微服务架构的普及,配置文件的管理变得尤为关键嗯。单机配置文件管理方式已经无法满足新潮应用的需求。所以呢,分布式配置中心应运而生,它为配置文件给了集中管理和动态更新鲜功能。

二、 分布式配置中心的种类

目前买卖场上主流的分布式配置中心有以下几种:

  • Spring Cloud ConfigSpring Cloud Config 是 Spring Cloud 生态系统中的一个模块,它支持配置文件的集中管理,能通过 Git 仓库进行配置文件的存储和版本控制。
  • ConsulConsul 是一个分布式服务网格解决方案, 它给了配置中心功能,能将配置存储在 Consulp 服务器中,并通过服务找到机制进行配置信息的分发。
  • ApolloApollo 是携程开源的分布式配置中心, 它支持配置文件的集中管理和动态更新鲜,给了权限管理、发布审计等功能。
  • etcdetcd 是一个分布式键值存储系统, 常用于 Kubernetes 等容器编排系统中,作为配置中心和元数据存储。

三、 怎么创建一个分布式配置中心

1. 选择合适的分布式配置中心

根据实际需求选择合适的分布式配置中心,如 Spring Cloud Config、Consul、Apollo 或 etcd 等。

2. 配置存储和版本控制

配置存储和版本控制是分布式配置中心的核心功能。能选择 Git 仓库、Consul 数据中心、etcd 集群等方式进行配置存储和版本控制。

3. 配置中心服务搭建

搭建配置中心服务, 配置存储和版本控制服务,以及配置信息分发机制。

  1. 创建 Spring Cloud Config 服务器项目。
  2. 配置 Git 仓库地址和分支信息。
  3. 启动 Spring Cloud Config 服务器。

4. 客户端配置

客户端需要配置配置中心的地址和配置文件的路径。

spring:
  cloud:
    config:
      uri: http://config-server:8888
      profile: dev
      label: master
      fail-fast: true
    application:
      name: my-app
    config:
      activate:
        on-profile: dev
    endpoints:
      health:
        show-details: always
    management:
      endpoints:
        web:
          exposure:
            include: health,info
    server:
      port: 8888
      servlet:
        context-path: /config
    security:
      user:
        name: admin
        password: admin
    datasource:
      url: jdbc:mysql://localhost:3306/configcenter?useSSL=false&serverTimezone=UTC
      username: root
      password: root
    redis:
      host: localhost
      port: 6379
      password: ""
      lettuce:
        pool:
          max-active: 8
          max-idle: 8
          min-idle: 0
          max-wait: -1ms
          time-between-eviction-runs: 30000ms
          min-evictable-idle-time: 30000ms
          soft-evictable: true
          evictable: true
    hikari:
      connection-timeout: 30000
      maximum-pool-size: 8
      minimum-idle: 0
      idle-timeout: 30000
      pool-name: HikariCP
      max-lifetime: 1800000
      driver-class-name: com.mysql.cj.jdbc.Driver
      jmx:
        enabled: true
    spring-boot:
      main:
        allow-bean-definition-overriding: true
    jpa:
      show-sql: true
      properties:
        hibernate:
          ddl-auto: update
          naming:
            physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
          dialect: org.hibernate.dialect.MySQL5InnoDBDialect
          formatsql: true
    feign:
      client:
        config:
          default:
            decode404: false
    mybatis:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-plus:
      configuration:
        log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
      global-config:
        db-config:
          strategy:
            id-type: auto
            type-handler-package: com.example.project.typehandler
    mybatis-plus-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-plus:
      configuration:
        log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
      global-config:
        db-config:
          strategy:
            id-type: auto
            type-handler-package: com.example.project.typehandler
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
      mapper-locations: classpath:mapper/.xml
      type-aliases-package: com.example.project.model
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: false
    mybatis-spring-boot-starter:
     


标签: git 分布式

提交需求或反馈

Demand feedback