zoukankan      html  css  js  c++  java
  • springbcloud5----高可用

    package com.itmuch.cloud;
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
    
    @SpringBootApplication
    @EnableEurekaServer
    public class EurekaHaApplication {
      public static void main(String[] args) {
        SpringApplication.run(EurekaHaApplication.class, args);
      }
    }
    spring:
      application:
        name: EUREKA-HA
    ---
    server:
      port: 8764
    spring:
      profiles: peer1
    eureka:
      instance:
        hostname: peer1 #主机名是peer1
      client:
        serviceUrl:
          defaultZone: http://peer2:8762/eureka/,http://peer3:8763/eureka/  #把自己注册到2和3,相互注册
    ---
    server:
      port: 8762
    spring:
      profiles: peer2
    eureka:
      instance:
        hostname: peer2  #主机名是peer2
      client:
        serviceUrl:
          defaultZone: http://peer1:8761/eureka/,http://peer3:8763/eureka/  #把自己注册到1和3,相互注册
    ---
    server:
      port: 8763
    spring:
      profiles: peer3
    eureka:
      instance:
        hostname: peer3  #主机名是peer3
      client:
        serviceUrl:
          defaultZone: http://peer1:8761/eureka/,http://peer2:8762/eureka/  #把自己注册到1和2,相互注册
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
    
        <parent>
            <groupId>com.itmuch.cloud</groupId>
            <artifactId>microservice-spring-cloud</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </parent>
    
        <artifactId>microservice-discovery-eureka-ha</artifactId>
        <packaging>jar</packaging>
    
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        </properties>
    
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-eureka-server</artifactId>
            </dependency>
            <!-- <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-security</artifactId>
            </dependency> -->
        </dependencies>
    
    </project>

    分别启动不同的peer

    用户微服务注册的时候,注册多个eureka server地址。

  • 相关阅读:
    C# 枚举、字符串、值的相互转换
    What's New in v2010 vol 2.5
    Using Oracle's Parallel Execution Features
    [zhuan]asp.net程序性能优化的七个方面 (c#(或vb.net)程序改进)
    ORACLE常用网址
    html中的块元素(block element)和内联元素(inline element)
    软件构架师的特点
    窗体信息处理函数讲解
    [xue]软件项目经理所必需具备的素质
    Gulp系列文章入门Gulp
  • 原文地址:https://www.cnblogs.com/yaowen/p/9129910.html
Copyright © 2011-2022 走看看