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

  • 相关阅读:
    oracle 10g 免安装客户端在windows下配置
    sql2005 sa密码
    使用windows live writer 有感
    windows xp SNMP安装包提取
    汉化groove2007
    迁移SQL server 2005 Reporting Services到SQL server 2008 Reporting Services全程截图操作指南
    foxmail 6在使用中的问题
    AGPM客户端连接不上服务器解决一例
    SpringSource Tool Suite add CloudFoundry service
    Java 之 SWing
  • 原文地址:https://www.cnblogs.com/know-more/p/12790725.html
Copyright © 2011-2022 走看看