• SpringCloud中一些基本配置


    1:eureka集群:原则,相互注册即可

    注意: 

      a:必须要有示例名,且必须相同

           b:集群模式必须开启注册registerWithEureka: true,单机情况下这个是false

           c:如果用域名,必须映射hosts

    以下用两个节点做演示server1,server2

    server-1:

    server:
      port: 8080
    eureka:
      server:
        #禁止自我保护,剔除无效服务
        enable-self-preservation: false
        #清理自我保护时间间隔 默认是60秒 单位毫秒 设定3s
        eviction-interval-timer-in-ms: 3000
      instance:
        hostname: eurekserveranode1
      client:
        #单机设置false,集群需要设置为true,负责找不到其他示例,无法相互注册
        registerWithEureka: true
        #要不要去注册中心获取其他服务的地址
        fetchRegistry: false
        serviceUrl:
          #erureka-server集群指向其他服务 
          defaultZone: http://eurekserveranode2:8081/eureka/
    #集群EurekaServer的applicationname必须有且必须相同
    spring:
      application:
        name: eureka-server

    server2:

    server:
      port: 8081
    eureka:
      server:
        #禁止自我保护,剔除无效服务
        enable-self-preservation: false
        #清理自我保护时间间隔 默认是60秒 单位毫秒 设定3s
        eviction-interval-timer-in-ms: 3000
      instance:
        hostname: eurekserveranode2
      client:
        #单机设置false,集群需要设置为true
        registerWithEureka: true
        fetchRegistry: false
        serviceUrl:
          #集群指向另外地址
          defaultZone: http://eurekserveranode1:8080/eureka/
    #集群EurekaServer的applicationname必须有且必须相同
    spring:
      application:
        name: eureka-server

    然后依次启动,在网页中访问:

    http://127.0.0.1:8081/ 可以看到:注册到了8080

     

     

     

     

    http://127.0.0.1:8080/ 可以看到:注册到了8081

    eureka-client:

    eureka:
      client:
        serviceUrl:
          defaultZone: http://eurekserveranode1:8080/eureka/,http://eurekserveranode2:8081/eureka/
    server:
      port: 8758
    spring:
      application:
        name: service-member

    zuul:

    eureka:
      client:
        serviceUrl:
          defaultZone: http://localhost:8080/eureka/
        #设置eureka-client多久拉取注册信息 默认30s
        registry-fetch-interval-seconds: 5
    server:
      port: 8766
    spring:
      application:
        name: service-zuul
    zuul:
      routes:
        api-a:
          path: /api-member/**
          service-id: service-member
        api-b:
          path: /api-order/**
          service-id: service-order

     

     

     

  • 相关阅读:
    在xcode5中修改整个项目名
    如何调试堆损坏
    My Life with Isaac Stern by Aaron Rosand
    Seagate 硬盘产地查询
    服务器返回 HTTP 500
    Exception code: 0xE0434352
    When curl sends 100-continue
    Milestone 不能卸载,修复 Counter 即可
    GE 遇到的 UAC 导致不能自动启动的问题
    关于 UAC,Mark Russinovich on the Future of Security
  • 原文地址:https://www.cnblogs.com/coderdxj/p/14726359.html
Copyright © 2020-2023  润新知