git - Spring Cloud 配置服务器 - MultipleJGitEnvironmentRepository : Could not fetch remote for master remote

标签 git ssh bitbucket ssh-keys spring-cloud-config

我正在尝试设置一个 spring 云配置服务器,它使用 SSH key 从 git 存储库中获取配置。它与 springBootVersion 2.1.0.RELEASE 和 springCloudVersion Greenwich.M3 一起运行。
当使用带有用户名和密码的 https bitbucket URI 和以下配置时,配置服务工作正常,没有问题:

  security.user:
    name: xxxxx
    password: xxxxx
  cloud.config.server:
    git:
      uri: https://bitbucket.org/abc/configs.git
      username: uname
      password: pass
但是我们必须迁移以使用 ssh key 而不是具有以下配置的用户名和密码:
  security.user:
    name: xxxxx
    password: xxxxx
  cloud.config.server:
    git:
      uri: git@bitbucket.org:abc/configs.git
id_rsa 私钥文件与配置文件位于 .ssh 文件夹中:
Host bitbucket.org
    StrictHostKeyChecking no
    IdentityFile /home/user/.ssh/id_rsa
最初的 git clone 工作正常,当我点击 http://xxxx:xxxx@localhost:8899/app/dev 时,我们能够毫无问题地获取配置。 .
但在那之后,日志中有很多 WARN 无法从远程获取。在初始克隆之后,还可以正确获取对配置的进一步更新。但不知道为什么日志中有这么多警告,这让我很担心。

2020-07-31 11:38:51.636 WARN 1 --- [io-48899-exec-7] .c.s.e.MultipleJGitEnvironmentRepository : Could not fetch remote for master remote: git@bitbucket.org:abc/configs.git


正如我之前提到的,只有当我们使用 SSH key 进行克隆时才会发生这种情况。同一个项目与 https 克隆一起工作正常。有什么我想念的吗?

最佳答案

如果将来有人遇到此问题,我们可以通过在 config-server 中设置 refreshRate 来解决此问题。

You can control how often the config server will fetch updated configuration data from your Git backend by using spring.cloud.config.server.git.refreshRate. The value of this property is specified in seconds. By default the value is 0, meaning the config server will fetch updated configuration from the Git repo every time it is requested.


默认情况下,它设置为 0。由于它已注册到 consul,其他服务的 consul 健康检查端点以每秒过多的请求使配置服务器不堪重负,这导致配置服务器从 bitbucket 中 pull 太多次。一旦将 refreshRate 设置为 5 秒,配置服务器就开始每 5 秒 pull 一次配置,现在已经稳定了。
一周过去了,配置服务按预期工作,SSH key 没有任何问题。

关于git - Spring Cloud 配置服务器 - MultipleJGitEnvironmentRepository : Could not fetch remote for master remote,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63191584/

相关文章:

git - 撤消上次提交/merge

git - 如果您一直在使用 git merge origin/master , git reset --soft origin/master 会失败吗?

python - 如何响应 os.system 中的提示?

c# - 如何使用访问 token 进行 Bitbucket API 调用?

git - 你如何处理 git 中的文件所有权?

git-receive-pack 使用双引号,但不使用单引号,而 git 使用单引号调用它

mysql - Bash 脚本通过 SSH 连接到服务器并连接到数据库

Java - 创建 Github v3 公钥

bitbucket - Bitbucket管道在分支之间共享一些步骤

github - 在单台 PC 中为 github 和 bitbucket 添加 SSH key