SpringCloud(四)服务中心配置集群

服务机配置集群:添加一个服务机的名字
spring:
application:
name: wx-eureka
把register-with-eureka设置为true,两台机器的name和password要一致

server:
  port: 5000

spring:
  application:
    name: wx-eureka
eureka:
  client:
    fetch-registry: false
    register-with-eureka: true
    service-url:
     #defaultZone: http://root:111111@你要连接的另一台电脑ip地址:端口号/eureka/
     defaultZone: http://root:[email protected]:7000/eureka/
security:
  user:
    name: root
    password: 111111

  basic:
    enabled: true

在这里插入图片描述
其他提供者可以往这两台机器注册服务
比如说提供者的yml配置文件:在两台机器上注册服务只需要在中间用逗号隔开,这样的话就可以同时在这两台机器注册服务,

server:
  port: 5100
spring:
  application:
     name: QQ-user-provider
eureka:
  client:
    service-url:
      #defaultZone: http://登录名:密码@第一台机器的IP地址:端口号/eureka/,http://登录名:密码@第二台机器的IP:端口号/eureka/
      defaultZone:  http://root:111111@localhost:5000/eureka/,http://root:[email protected]:7000/eureka/

上一篇:Spring Cloud入门教程(三):如何在服务机注册一个消费者和设置熔断机制
下一篇:SpringCloud(五)负载均衡之随机策略

猜你喜欢

转载自blog.csdn.net/weixin_43844158/article/details/86520442
今日推荐