zoukankan      html  css  js  c++  java
  • Eureka集群----SpringCloud 微服务

    Eureka高可用。

    单点故障会导致系统全部死掉。所以需要来个类似集群的那种操作,死了一个,还有其他的,不至于系统用不了。

    Eureka的集群,也就是Eureka之间相互注册。

    Eureka集群环境搭建
    
    Eureka01配置
    ###服务端口号
    server:
      port: 8100
    ###eureka 基本信息配置
    spring: 
     application: 
      name: eureka-server
    eureka:
      instance:
        ###注册到eurekaip地址
        hostname: 127.0.0.1
      client:
        serviceUrl:
          defaultZone: http://127.0.0.1:8200/eureka/
    ###因为自己是为注册中心,不需要自己注册自己
        register-with-eureka: true
    ###因为自己是为注册中心,不需要检索服务
        fetch-registry: true
    
    Eureka02配置
    
    ###服务端口号
    server:
      port: 8200
    ###eureka 基本信息配置
    spring: 
     application: 
      name: eureka-server
    eureka:
      instance:
        ###注册到eurekaip地址
        hostname: 127.0.0.1
      client:
        serviceUrl:
          defaultZone: http://127.0.0.1:8100/eureka/
    ###因为自己是为注册中心,不需要自己注册自己
        register-with-eureka: true
    ###因为自己是为注册中心,不需要检索服务
        fetch-registry: true
    

      客户端调用。

    客户端集成Eureka集群
    
    server:
      port: 8000
    spring:
      application:
        name: app-itmayiedu-member
    #eureka:
    #  client:
    #    service-url:
    #      defaultZone: http://localhost:8100/eureka
    ###集群地址
    eureka:
      client:
        service-url:
               defaultZone: http://localhost:8100/eureka,http://localhost:8200/eureka    
        register-with-eureka: true
        fetch-registry: true

    pom.xml配置

        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.0.1.RELEASE</version>
        </parent>
        <!-- 管理依赖 -->
        <dependencyManagement>
            <dependencies>
                <dependency>
                    <groupId>org.springframework.cloud</groupId>
                    <artifactId>spring-cloud-dependencies</artifactId>
                    <version>Finchley.M7</version>
                    <type>pom</type>
                    <scope>import</scope>
                </dependency>
            </dependencies>
        </dependencyManagement>
        <dependencies>
            <!--SpringCloud eureka-server -->
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
            </dependency>
        </dependencies>
        <!-- 注意: 这里必须要添加, 否者各种依赖有问题 -->
        <repositories>
            <repository>
                <id>spring-milestones</id>
                <name>Spring Milestones</name>
                <url>https://repo.spring.io/libs-milestone</url>
                <snapshots>
                    <enabled>false</enabled>
                </snapshots>
            </repository>
        </repositories>
  • 相关阅读:
    An AODV Tutorial
    MFC去掉单文档的"无标题-"的方法
    win32 openss 编译
    ASP.NET实现RENREN SIG计算
    std::string str.c_str() const
    fopen
    curl with ssl support for win32
    VC++ utf8 Unicode GB2312 编码转换
    编码转换
    VirtualBox uuid冲突问题
  • 原文地址:https://www.cnblogs.com/a393060727/p/12209723.html
Copyright © 2011-2022 走看看