Eureka Server:如何实现高可用性

编程入门 行业动态 更新时间:2024-10-10 02:15:51
本文介绍了Eureka Server:如何实现高可用性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我是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:如何实现高可用性

本文发布于:2023-11-23 23:16:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1623137.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:可用性   如何实现   Eureka   Server

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!