Eureka clusters ---- SpringCloud microService

Eureka high availability.

Single point of failure can cause the system to all die. So it is necessary to operate a similar kind of cluster, one of them die, there are other, the system will not take.

Eureka clusters, that is, mutual registration between Eureka.

Eureka cluster environment to build

Eureka01 Configuration
###Service port number
server:
  port: 8100
### eureka basic system configuration information
spring: 
 application: 
  name: eureka-server
eureka:
  instance:
    ### addresses registered to eurekaip
    hostname: 127.0.0.1
  client:
    ServiceUrl:
      defaultZone: http://127.0.0.1:8200/eureka/
### because he is a registered center, do not need to register yourself
    register-with-eureka: true
### because he is a registered center, no retrieval services
    fetch-registry: true

Eureka02 Configuration

###Service port number
server:
  port: 8200
### eureka basic system configuration information
spring: 
 application: 
  name: eureka-server
eureka:
  instance:
    ### addresses registered to eurekaip
    hostname: 127.0.0.1
  client:
    ServiceUrl:
      defaultZone: http://127.0.0.1:8100/eureka/
### because he is a registered center, do not need to register yourself
    register-with-eureka: true
### because he is a registered center, no retrieval services
    fetch-registry: true

  Client calls.

Client integration Eureka clusters

server:
  port: 8000
spring:
  application:
    name: app-itmayiedu-member
#eureka:
#  client:
#    service-url:
#      defaultZone: http://localhost:8100/eureka
### cluster address
eureka:
  client:
    service-url:
           defaultZone: http://localhost:8100/eureka,http://localhost:8200/eureka    
    register-with-eureka: true
    fetch-registry: true

pom.xml configuration

    <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 > the Spring-Cloud-Starter-Netflix-Eureka-Server </ artifactId > 
        </ dependency > 
    </ the Dependencies > 
    <-! Note: this must be added, whether those various dependence in question -> 
    < Repositories > 
        < Repository > 
            < ID > Spring-Milestones </ ID > 
            < name > the Spring Milestones </ name > 
            < URL > HTTPS: //repo.spring.I / libs-milestone</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>

 

Guess you like

Origin www.cnblogs.com/a393060727/p/12209723.html