Spring Cloud Hoxton 版本微服务项目搭建 config 配置中心集群搭建

Spring Cloud Hoxton 版本微服务项目搭建 config 配置中心集群搭建


前言

之前的文章讲解了配置中心的搭建,今天来讲一讲config-sever集群搭建。


config-sever集群搭建

在微服务架构中,所有服务都从配置中心获取配置,配置中心一旦宕机,会发生很严重的问题,下面我们搭建一个双节点的配置中心集群来解决该问题。

启动两个config-server分别运行在4010和4011端口上;

添加config-client的配置文件bootstrap-cluster.yml,主要是添加了从注册中心获取配置中心地址的配置并去除了配置中心uri的配置:

server:
  port: 4011

spring:
  application:
    name: config-client
  cloud:
    # config客户端配置
    config:
      # 分支名称
      label: master
      # 启用配置后缀名称
      profile: dev
      # 配置文件名称
      name: config
      # config-sever集群搭建
      discovery:
        enabled: true
        service-id: config-center

eureka:
  client:
    register-with-eureka: true
    fetch-registry: true
    service-url:
      defaultZone: http://localhost:8888/eureka/

以bootstrap-cluster.yml启动config-client服务

访问 http://localhost:4011/configInfo,发现config-client可以获取到配置信息。

config info for config dir dev(master)

最后

  • 更多参考精彩博文请看这里:《陈永佳的博客》

  • 喜欢博主的小伙伴可以加个关注、点个赞哦,持续更新嘿嘿!

发布了397 篇原创文章 · 获赞 973 · 访问量 9万+

猜你喜欢

转载自blog.csdn.net/Mrs_chens/article/details/103804662