美文网首页
Spring Cloud 16 -- Zuul 集群

Spring Cloud 16 -- Zuul 集群

作者: 半碗鱼汤 | 来源:发表于2019-08-15 10:26 被阅读0次

    一、说明

    上一篇文章对 eureka server 进行了集群化,现在我们对 zuul 也来集群化

    二、修改 zuul 的配置文件

    application.yml

    spring:
      application:
        name: zuul
      profiles:
        active: zuul1
    

    新增 application-zuul1.yml

    server:
      port: 8769
    
    spring:
      rabbitmq:
        host: localhost
        port: 5672
        username: guest
        password: guest
      cloud:
        bus:
          enabled: true
          trace:
            enabled: true
    
    eureka:
      client:
        registryFetchIntervalSeconds: 5
        serviceUrl:
          defaultZone: http://localhost:8761/eureka/,http://localhost:8760/eureka/
      instance:
        leaseRenewalIntervalInSeconds: 10
        health-check-url-path: /actuator/health
        instance-id: ${spring.cloud.client.ip-address}:${server.port}
        prefer-ip-address: true
    
    management:
      endpoints:
        web:
          exposure:
            include: "*"
      endpoint:
        health:
          show-details: ALWAYS
    
    zuul:
      routes:
        toclient1:
          path: /toclient1/**
          serviceId: client1
        toclient2:
          path: /toclient2/**
          serviceId: client2
    

    新增 application-zuul2.yml

    server:
      port: 8770
    
    spring:
      rabbitmq:
        host: localhost
        port: 5672
        username: guest
        password: guest
      cloud:
        bus:
          enabled: true
          trace:
            enabled: true
    
    eureka:
      client:
        registryFetchIntervalSeconds: 5
        serviceUrl:
          defaultZone: http://localhost:8761/eureka/,http://localhost:8760/eureka/
      instance:
        leaseRenewalIntervalInSeconds: 10
        health-check-url-path: /actuator/health
        instance-id: ${spring.cloud.client.ip-address}:${server.port}
        prefer-ip-address: true
    
    management:
      endpoints:
        web:
          exposure:
            include: "*"
      endpoint:
        health:
          show-details: ALWAYS
    
    zuul:
      routes:
        toclient1:
          path: /toclient1/**
          serviceId: client1
        toclient2:
          path: /toclient2/**
          serviceId: client2
    

    指向 zuul1 启动一个 zuul,再指向 zuul2 启动一个

    三、完成集群化

    相关文章

      网友评论

          本文标题:Spring Cloud 16 -- Zuul 集群

          本文链接:https://www.haomeiwen.com/subject/nfuajctx.html