gpt4 book ai didi

java - spring cloud config 成为我的单点故障

转载 作者:行者123 更新时间:2023-11-30 10:42:26 26 4
gpt4 key购买 nike

简而言之,我可以运行一个 Spring Cloud Config 服务器集群来确保高可用性吗?如果是,如何?

我正在尝试使用 Spring Cloud Config 作为我的中央配置服务。我的问题是每个客户端只能指定一个服务器来获取配置。如果这台服务器挂了,一切都得等它恢复。

一些其他框架允许您运行多个服务器并在客户端枚举它们。 Spring Cloud Config有这样的功能吗?

如果那不可能,我正在考虑运行多个实例并将它们放在 nginx 后面。这会导致一些副作用吗?

如有任何建议,我们将不胜感激。

最佳答案

Some other framework allows you to run several servers and enumerate them on the client side. Does Spring Cloud Config has such feature?

你应该使用 Spring Cloud Netflix Eureka将 Eureka Server 包含为服务发现并包含 Eureka Client在服务(微服务)中。您可以让配置服务器向发现服务注册。

Spring Cloud Config Discovery service

来自文档:

If you use a DiscoveryClient implementation, such as Spring Cloud Netflix and Eureka Service Discovery or Spring Cloud Consul, you can have the Config Server register with the Discovery Service. However, in the default “Config First” mode, clients cannot take advantage of the registration.

If you prefer to use DiscoveryClient to locate the Config Server, you can do so by setting spring.cloud.config.discovery.enabled=true (the default is false). The net result of doing so is that client applications all need a bootstrap.yml (or an environment variable) with the appropriate discovery configuration. For example, with Spring Cloud Netflix, you need to define the Eureka server address (for example, in eureka.client.serviceUrl.defaultZone). The price for using this option is an extra network round trip on startup, to locate the service registration. The benefit is that, as long as the Discovery Service is a fixed point, the Config Server can change its coordinates. The default service ID is configserver, but you can change that on the client by setting spring.cloud.config.discovery.serviceId (and on the server, in the usual way for a service, such as by setting spring.application.name).

例如服务(客户端)中的bootstrap.yml:

spring:
application:
name: example-service
cloud:
config:
fail-fast: true
discovery:
enabled: true
service-id: configuration-server
# Eureka client
eureka:
client:
prefer-same-zone-eureka: true
region: region1
service-url:
zone1: http://discovery-server-01:8761/eureka/,http://discovery-server-02:8761/eureka/
availability-zones:
region1: zone1

关于java - spring cloud config 成为我的单点故障,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38136911/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com