新教E区

 楼主| 发表于 2019-1-30 10:26:47 | 显示全部楼层 |阅读模式
一、准备工作
Eureka can be made even more resilient and available by running multiple instances and asking them to register with each other. In fact, this is the default behaviour, so all you need to do to make it work is add a valid serviceUrl to a peer, e.g.
摘自官网
需要JAVA Spring Cloud大型企业分布式微服务云构建的B2B2C电子商务平台源码 一零三八七七四六二六
Eureka通过运行多个实例,使其更具有高可用性。事实上,这是它默认的熟性,你需要做的就是给对等的实例一个合法的关联serviceurl。
二、改造工作
在eureka-server工程中resources文件夹下,创建配置文件application-peer1.yml:

server:
  port: 8761 spring:
  profiles: peer1
eureka:
  instance:
    hostname: peer1
  client:
    serviceUrl:
      defaultZone: http://peer2:8769/eureka/

并且创建另外一个配置文件application-peer2.yml:

server:
  port: 8769 spring:
  profiles: peer2
eureka:
  instance:
    hostname: peer2
  client:
    serviceUrl:
      defaultZone: http://peer1:8761/eureka/

  这时eureka-server就已经改造完毕。
ou could use this configuration to test the peer awareness on a single host (there’s not much value in doing that in production) by manipulating /etc/hosts to resolve the host names.
按照官方文档的指示,需要改变etc/hosts,linux系统通过vim /etc/hosts ,加上:
127.0.0.1 peer1 127.0.0.1 peer2
windows电脑,在c:/windows/systems/drivers/etc/hosts 修改。
这时需要改造下service-hi:
      eureka:
    client:
    serviceUrl:
      defaultZone: http://peer1:8761/eureka/ server:
    port: 8762 spring:
    application:
    name: service-hi

  java B2B2C源码电子商务平台
   

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|小黑屋|手机版|Archiver|新教e区 ( 鲁ICP备16007390号-1 )

GMT+8, 2019-2-19 09:16 , Processed in 0.062500 second(s), 15 queries , Gzip On.

新教E区

© 2006-2014 新教E区

快速回复 返回顶部 返回列表