美文网首页
Spring Cloud Eureka Server

Spring Cloud Eureka Server

作者: 赛亚人之神 | 来源:发表于2019-05-08 14:47 被阅读0次

    spring cloud eureka server 单节点配置

    1. 使用 idea 创建 eureka-server


    2. 重命名 application.yml 并加入如下配置信息


    spring:
      application:
        name: eureka-server
    server:
      port: 1111
    eureka:
      instance:
        hostname: peer1
      client:
        register-with-eureka: false
        fetch-registry: false
        service-url:
          defaultZone: http://peer1:1111/eureka
      server:
        enable-self-preservation: false
    
    1. 启用 EnableEurekaServer


    2. C:\Windows\System32\drivers\etc\hosts 文件中加入域名映射

    127.0.0.1 peer1 peer2 peer3
    

    spring cloud eureka server 双节点设置

    resources 文件夹下创建两个节点的配置文件

    1. 节点一:application-peer1.yml
    spring:
      application:
        name: eureka-server
    server:
      port: 1111
    eureka:
      instance:
        hostname: peer1
      client:
        register-with-eureka: true
        fetch-registry: true
        service-url:
          defaultZone: http://peer2:2222/eureka
      server:
        enable-self-preservation: false
    
    1. 节点二:application-peer2.yml
    spring:
      application:
        name: eureka-server
    server:
      port: 2222
    eureka:
      instance:
        hostname: peer2
      client:
        register-with-eureka: true
        fetch-registry: true
        service-url:
          defaultZone: http://peer1:1111/eureka
      server:
        enable-self-preservation: false
    

    使用 eureka’s rest api 查看 content of registry: 查看一个服务的所有实例信息
    http://<eureka service>:<port>/eureka/apps/<APPID>
    例子:查看 eureka-server 注册信息

    相关文章

      网友评论

          本文标题:Spring Cloud Eureka Server

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