简体   繁体   English

Spring 云配置服务器后备多个存储库

[英]Spring Cloud Config Server fallback for multiple repositories

We are using spring cloud config server backed by bitbucket for config files.我们正在使用由 bitbucket 支持的 spring 云配置服务器作为配置文件。 We have configured multiple repositories in application.yml of config server.我们在配置服务器的 application.yml 中配置了多个存储库。 We want to make it available even if bitbucket is down.即使 bitbucket 关闭,我们也希望它可用。 We are looking for a solution that can cache config repositories and in case bitbucket is down it can still be able to serve properties of different repositories.我们正在寻找一种可以缓存配置存储库的解决方案,如果 bitbucket 出现故障,它仍然可以提供不同存储库的属性。 Below is my application.yml下面是我的 application.yml

spring:
  cloud:
    config:
      server:
        git:
          uri: git@bitbucket.org:config1.git
          ignoreLocalSshSettings: true
          privateKey: ${PEM}
          repos:
            service1:
              uri: git@bitbucket.org:config2.git
              ignoreLocalSshSettings: true
              privateKey: ${PEM}
            service2:
              uri: git@bitbucket.org:config3.git
              ignoreLocalSshSettings: true
              privateKey: ${PEM}

I have tried setting up spring.cloud.config.server.git.basedir but it clones only the base config repo.我尝试设置spring.cloud.config.server.git.basedir但它只克隆基本配置仓库。 How can we make config server to serve from local if bitbucket is down.如果 bitbucket 关闭,我们如何使配置服务器从本地服务。

Using basedir property is the only way out.使用basedir属性是唯一的出路。 This is how we use that:这就是我们如何使用它:

spring:
  cloud:
    config:
      server:
        git:
          uri: git@bitbucket.org:config1.git
          ignoreLocalSshSettings: true
          privateKey: ${PEM}
          basedir: /home/user/config1-repo
          repos:
            service1:
              uri: git@bitbucket.org:config2.git
              ignoreLocalSshSettings: true
              privateKey: ${PEM}
              basedir: /home/user/config2-repo
            service2:
              uri: git@bitbucket.org:config3.git
              ignoreLocalSshSettings: true
              privateKey: ${PEM}
              basedir: /home/user/config3-repo

How did you try to reproduce the scenario where git is not available and forcing the config server to fetch the properties from local server path.您如何尝试重现 git 不可用并强制配置服务器从本地服务器路径获取属性的场景。 I suggest you create the local path.我建议你创建本地路径。 And using git-bash clone the config repo inside your local repo directory.并使用 git-bash 克隆本地 repo 目录中的配置 repo。 For example in this case go inside /home/user/localRepo and clone your config git repo there.例如,在这种情况下 go 在/home/user/localRepo并在那里克隆您的配置 git 存储库。 Ensure to have all the files and folder be cloned properly.确保正确克隆所有文件和文件夹。

Then try to reproduce the git not available scenario and check if your config server MS is able to fetch properties from local dir.然后尝试重现 git 不可用场景并检查您的配置服务器 MS 是否能够从本地目录获取属性。 This is the only way out for fallback.这是回退的唯一出路。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM