Spring Cloud 分布式集群搭建
网关/负载均衡:Gateway
以上图结构为例,建立两个Eureka Server, 两个服务提供端,两个服务消费端,一个网关Gateway
1. 建立注册中心集群(多个Eureka Server)
1.1 Eureka Server 集群中有多少个server就需要在Eureka工程中建多少个application-**.yml 文件,其中一个application-master.yml 文件(设置port:8001),其它都是application-slave1.yml 文件(设置port:8005),application-slave2.yml 文件(设置port:8006)每个文件中设置不同的port,其它都一样。
1.2 application-master.yml 文件和application-slave.yml文件中要相互注册URL. 如下:
application-master.yml
Eureka:
client:
server-url:
defaultzone:http://ip:8005/eureka,http://localhost:8006/eureka
application-slave.yml
Eureka:
client:
server-url:
defaultzone:http://ip:8001/eureka