Eureka Server:如何实现高可用性 [英] Eureka Server: How to achieve high availability

查看:841
本文介绍了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: http://localhost:8761/eureka/

但是如果localhost:8761下降怎么办?

推荐答案

Eureka Discovery Server应该在生产设置中的对等感知配置模式下使用. 查看: http://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: http://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: http://peer2:1112/eureka/

..和第二个服务器实例,如下所示:

..and second server instance like this:

server:
   port: 1112
eureka:
   instance:
      hostname: peer2
   client:
      serviceUrl:
           defaultZone: http://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:如何实现高可用性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆