eureka cluster

1. The purpose of the eureka cluster

    As a registry, eureka has a single point of risk. If it hangs, the service will not be found.

2、euerka server

    Let's take three nodes as an example, the application.yml configuration is as follows

---
spring:
  profiles: peer1
eureka:
  instance:
    hostname: peer1
  client:
    serviceUrl:
      defaultZone: http://peer1/eureka/,http://peer2/eureka/

---
spring:
  profiles: peer2
eureka:
  instance:
    hostname: peer2
  client:
    serviceUrl:
      defaultZone: http://peer1/eureka/,http://peer3/eureka/

---
spring:
  profiles: peer3
eureka:
  instance:
    hostname: peer3
  client:
    serviceUrl:
      defaultZone: http://peer1/eureka/,http://peer2/eureka/

    At this point, visit the registration center of peer1: http://peer1/. There are already eureka-servers of peer2 and peer3 nodes in registered-replicas.

    Similarly, visit the registry of peer2: http://peer2/, there are already peer1 and peer3 nodes in registered-replicas, and these nodes are in the available-replicase.

    We can also try to shut down peer1 and refresh http://peer2/, the node of peer1 becomes unavailable-replicas.

    Notice:

    The two-by-two registration method can achieve the effect of complete equivalence of nodes in the cluster and achieve the highest availability cluster. The failure of any registration center will not affect the registration and discovery of services.

3、eureka client

server:
  port: 8080
spring:
  application:
    name: eureka-ha-demo
eureka:
  client:
    service-url:
      defaultZone: http://peer1/eureka,http://peer2/eureka,http://peer3/eureka

or

server:
  port: 8080
spring:
  application:
    name: eureka-ha-demo
eureka:
  client:
    service-url:
      defaultZone: http://peer1/eureka

    The client side only connects to one peer1, and also synchronizes the registration information to peer2 and peer3.

     Because the synchronization of Eureka Server follows a very simple principle: as long as there is an edge connecting the nodes, information dissemination and synchronization can be performed.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325174818&siteId=291194637