我是Spring Cloud的新手.我已经阅读了此文档,它说客户端应用程序必须指定服务网址:
I'm new to spring cloud. I've read this doc and it says the client application must specify a service url:
eureka: client: serviceUrl: defaultZone: localhost:8761/eureka/但是如果localhost:8761下降怎么办?
推荐答案Eureka Discovery Server应该在生产设置中的对等感知配置模式下使用. 查看: cloud.spring.io/spring-cloud-static/spring-cloud. html#_peer_awareness
Eureka Discovery Server should be used in the Peer-Aware config mode in production setups. Check: cloud.spring.io/spring-cloud-static/spring-cloud.html#_peer_awareness
例如,您的第一个eureka服务器实例将具有以下配置:
For instance your first eureka server instance will have config like this:
server: port: 1111 eureka: instance: hostname: peer1 client: serviceUrl: defaultZone: peer2:1112/eureka/..和第二个服务器实例,如下所示:
..and second server instance like this:
server: port: 1112 eureka: instance: hostname: peer2 client: serviceUrl: defaultZone: peer1:1111/eureka/当Eureka服务器实例启动时,它们将互相寻找.所有微服务都会自动向其注册,因此,如果一个服务出现故障,另一个服务器实例将始终存在.在两个Eureka实例上,您将能够看到所有已注册的微服务.这样,您可以扩大规模,并在生产环境中拥有多个服务器实例.
When Eureka server instances will boot up they will look for each other. All microservices will register with them automatically, so if one goes down the other server instance will be always there. On both Eureka instances you will be able to see all the registered microservices. Like this you can scale-up and have multiple server instances in a production environment.
注意:如果要在单个系统上尝试此操作,请不要忘记编辑/etc/hosts文件: 127.0.0.1 peer1 127.0.0.1 peer2
Note: If you are trying this on a single system, dont forget to edit the /etc/hosts file: 127.0.0.1 peer1 127.0.0.1 peer2
更多推荐
Eureka Server:如何实现高可用性
发布评论