• springcloud费话之Eureka集群


    目录:

    springcloud费话之Eureka基础

    springcloud费话之Eureka集群

    springcloud费话之Eureka服务访问(restTemplate)

    springcloud费话之Eureka接口调用(feign)

    springcloud费话之断路器(hystrix in feign)

    springcloud费话之配置中心基础(SVN)

    springcloud费话之配置中心客户端(SVN)

    一、容灾server集群

    复制上例中的server项目两个,分别命名为x-server2和x-server3,修改yml配置

    ①端口:三个服务器的端口分别为9010,9011,9012

    ②defaultZone:三个服务器的defaultZone分别为对方,即排除自己之外的两个,即A填写BC的地址,B填写AC的地址,C填写AB的地址。

    ③name:修改三个server的name,做区分。

    三个server的具体yml配置如下

    server:
      port: 9010
      
    eureka:
      instance:
        hostname: localhost
      client:
        registerWithEureka: false
        fetchRegistry: false
        serviceUrl:
          defaultZone: http://localhost:9011/eureka/,http://localhost:9012/eureka/
      server:
        enable-self-preservation: false
    
    spring:
      application: 
        name: eureka-server-9010
    server:
      port: 9011
      
    eureka:
      instance:
        hostname: localhost
      client:
        registerWithEureka: false
        fetchRegistry: false
        serviceUrl:
          defaultZone: http://localhost:9010/eureka/,http://localhost:9012/eureka/
      server:
        enable-self-preservation: false
    
    spring:
      application: 
        name: eureka-server-9011
    server:
      port: 9012
      
    eureka:
      instance:
        hostname: localhost
      client:
        registerWithEureka: false
        fetchRegistry: false
        serviceUrl:
          defaultZone: http://localhost:9010/eureka/,http://localhost:9011/eureka/
      server:
        enable-self-preservation: false
    
    spring:
      application: 
        name: eureka-server-9012

    为了演示配置用3台,两台即可,最好物理上做区分为2台。

    二、eureka client集群

    复制上例中的client项目两个,分别命名为x-client2和x-client3,修改yml配置

    ①端口:三个客户端的端口分别为9020,9021,9022

    ②defaultZone:三个客户端的defaultZone分别为三个server

    ③name:三个客户端分别修改name,做区分

    三个客户端的yml配置如下:

    server:
      port: 9020
    
    eureka:
      client:
        serviceUrl:
          defaultZone: http://localhost:9010/eureka/,http://localhost:9011/eureka/,http://localhost:9012/eureka/
      
    spring:
      application:
        name: eureka-client-9020
    server:
      port: 9021
    
    eureka:
      client:
        serviceUrl:
          defaultZone: http://localhost:9010/eureka/,http://localhost:9011/eureka/,http://localhost:9012/eureka/
      
    spring:
      application:
        name: eureka-client-9021
    server:
      port: 9022
    
    eureka:
      client:
        serviceUrl:
          defaultZone: http://localhost:9010/eureka/,http://localhost:9011/eureka/,http://localhost:9012/eureka/
      
    spring:
      application:
        name: eureka-client-9022

    结果如下:

     可尝试关闭掉当前注册进的server,然后观察其他两个server的变化情况

    以上!

  • 相关阅读:
    windows cmd 编码
    ARM伪指令
    System.load 和 System.loadLibrary
    用GDB调试程序
    ARM指令集
    ARM寻址方式
    abortion
    Oxford City Jealous Lover
    everyday words
    【转】高效率的C++函数返回值
  • 原文地址:https://www.cnblogs.com/liuyuhangCastle/p/11397245.html
Copyright © 2020-2023  润新知