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不会放在同一组里面

  • 相关阅读:
    5.4.3 果园里的树
    5.3.2 字母重排
    5.3.1 6174问题
    Codeforces Round #253 (Div. 2), problem: (B)【字符串匹配】
    POJ1054 枚举【STL__binary_search()_的应用】
    432B
    0x3f3f3f3f...编程中无穷大常量的设置技巧
    2014年百度之星程序设计大赛 资格赛第一题 (longlong)
    Tarjan
    Dijkstra、Dij + heap、Floyd、SPFA、 SPFA + SLF Template
  • 原文地址:https://www.cnblogs.com/know-more/p/12790725.html
Copyright © 2011-2022 走看看