SpringCloud(三) eureka集群
根据 SpringCloud(一) eureka服务注册与发现 ,再增加两个eureka server
Eureka Server的高可用
Eureka Server的设计一开始就考虑到了高可用的问题,在Eureka的服务治理设计中,所有节点即是服务提供方,也是服务消费方,服务注册也不列外。之前的有配置:
eureka:
client:
register-with-eureka: false
fetch-registry: false
让服务注册中心不注册自己。Eureka Server的高可用实际上就是将自己作为服务向其他服务注册中心注册自己,这样就可以形成一组互相注册的服务注册中心,以实现服务清单的互相同步,达到高可用的效果。
因为在一台机器上部署,修改hosts
127.0.0.1 localhost1
127.0.0.1 localhost2
127.0.0.1 localhost3
eureka-server1配置文件:
server:
port: 8761
eureka:
instance:
hostname: localhost1
client:
register-with-eureka: true
fetch-registry: true
service-url:
defaultZone: http://localhost2:8762/eureka,http://localhost3:8763/eureka
spring:
application:
name: eureka-server1
eureka-server2配置文件:
server:
port: 8762
eureka:
instance:
hostname: localhost2
client:
register-with-eureka: true
fetch-registry: true
service-url:
defaultZone: http://localhost1:8761/eureka,http://localhost3:8763/eureka
spring:
application:
name: eureka-server2
eureka-server3配置文件:
server:
port: 8763
eureka:
instance:
hostname: localhost3
client:
register-with-eureka: true
fetch-registry: true
service-url:
defaultZone: http://localhost1:8761/eureka,http://localhost2:8762/eureka
spring:
application:
name: eureka-server3
eureka-client spring配置文件:
server:
port: 8080
eureka:
client:
service-url:
defaultZone: http://localhost1:8761/eureka,http://localhost2:8762/eureka,http://localhost3:8763/eureka
spring:
application:
name: eureka-client1
先启动所有eureka,在启动客户端
访问:http://localhost:8761/ 或http://localhost:8762/ 或http://localhost:8763/
实时内容请关注微信公众号,公众号与博客同时更新:程序员星星
还没有评论,来说两句吧...