zoukankan      html  css  js  c++  java
  • 搭建eureka高可用

    Eureka高可用

     

    1.设置服务器之间的host,测试环境是在window10上搭建的,所以去修改C:WindowsSystem32driversetc文件,如下:

     

    image-20200427215406445

    2.创建项目:

    image-20200427215537059

    image-20200427215912576

    image-20200427220148974

    image-20200427220546945

    image-20200427220658909

    3.编辑配置文件:

     

    application.yml:
    
      #一组服务需要使用相同的服务名称,才能被识别为一组!
      application:
        name: eureka-server
    application-euk1.yml:
    
    eureka:
      client:
        #集群模式需要设置为true
        register-with-eureka: true
        #集群模式需要设置为true
        fetch-registry: true
        #设置服务注册中心的URL,用于client和server端交流
        #注意事项:
        #eureka.client.serviceUrl.defaultZone配置项的地址,不能使用localhost,要使用service-center-1之类的域名,通过host映射到127.0.0.1;
        service-url:
          defaultZone: http://euk2.com:8702/eureka/
      instance:
        #hostname为必填
        hostname: euk1.com
    server:
      port: 8701

    application.euk2.yml:
    
    eureka:
      client:
        register-with-eureka: true
        fetch-registry: true
        service-url:
          defaultZone: http://euk1.com:8701/eureka/
      instance:
        hostname: euk2.com
    server:
      port: 8702

    4.设置Configuration,以不同的配置文件启动两个eureka实例:

    image-20200427221214870

    image-20200427221333002

    image-20200427221743914

    5.看一下启动正常后的运行界面:(8702端口界面也是一样的,就不贴了)

    image-20200427222004793

    6.总结:在部署eureka单节点和高可用时候遇到的坑:

    a.第一次部署eureka的时候,只是在配置文件中配置了eureka的相关配置,没有在启动类上加注解 @EnableEurekaServer,所以访问控制台报错404

    b.同样服务的client要起同样的名称(spring.application.name),不然eureka不会放在同一组里面

  • 相关阅读:
    【codevs1079】回家
    【codevs1245】最小的N个和
    【codevs1231】最优布线问题
    【codevs1078】最小生成树
    【NOIP1999】【codevs1083】Cantor表
    【NOIP2006】【codevs1075】明明的随机数
    【NOIP2001】【codevs1011】数的计算
    【POJ2259】Team Queue(队列,模拟)
    【LOJ119】单源最短路 模板
    Jzoj4900 平方数
  • 原文地址:https://www.cnblogs.com/know-more/p/12790725.html
Copyright © 2011-2022 走看看