在windows环境下构建Eureka Server集群

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

1:配置多个profiles

---
spring:
   profiles: peer1
server:
   port: 8761
eureka:
   instance:
      hostname: peer1
   client:
      serviceUrl:
         defaultZone: http://peer2:8762/eureka/
      register-with-eureka: false
      fetch-registry: false


---

spring:
   profiles: peer2
server:
   port: 8762
eureka:
   instance:
      hostname: peer2
   client:
      serviceUrl:
         defaultZone: http://peer1:8761/eureka/
      register-with-eureka: false
      fetch-registry: false

2:修改hosts文件增加

127.0.0.1 peer1

127.0.0.1 peer2

3:通过Maven打包命令mvn clean package -Dmaven.test.skip=true

4:进入target目录 通过java -jar启动服务,启动命令

 java -jar eureka-server-0.0.1-SNAPSHOT.jar --spring.profiles.active=peer1 -verbose:class

 java -jar eureka-server-0.0.1-SNAPSHOT.jar --spring.profiles.active=peer2 -verbose:class

5:在Eureka Client配置项8761注册服务(访问peer2发现Eureka-Client也存在,说明peer1注册列表已经同步到peer2节点)

代码省略

转载于:https://my.oschina.net/u/2608890/blog/2991524

你可能感兴趣的:(在windows环境下构建Eureka Server集群)