Springcloud high availability and springcloud availability

Source: Internet
Author: User

Springcloud high availability and springcloud availability
Purpose

In the actual production environment, a single point of registration center is defective. When the node goes down, the microservices dependent on its services will fail, therefore, a high-availability registration center is needed to make up for this defect. Eureka achieves high availability through the "partner" mechanism. Each Eureka instance must specify another Eureka address as its partner in the configuration. When Eureka starts, it obtains the existing registration list from its partner node, in this way, you do not need to worry about incomplete registration lists when adding machines to the Eureka cluster.

Project Architecture

Configuration file configuration application. properties
Spring. profiles. active = slave # use an IP address to define the Registration Center address eureka. instance. prefer-ip-address = true # disable self-protection mode eureka. server. enable-self-preservation = false ### enable security verification on eureka server. user. name = adminsecurity. user. password = 123456security. basic. enabled = true # do not register yourself with the Registration Center # eureka. client. register-with-eureka = false # The Registry is responsible for maintaining the service instance and does not need to retrieve the service # eureka. client. fetch-registry = false # The call interval of the Service Renewal task is 30 s by default # eureka. instance. lease-renewal-interval-in-seconds = 3 ### defines the default service expiration time as 90 s # eureka. instance. lease-expiration-duration-in-seconds = 540
Configuration application-slave.properties for Registration Center 1
spring.application.name=springcloud-eureka-serverserver.port=8766eureka.instance.instance-id=${spring.cloud.client.ipAddress}:${server.port}eureka.instance.hostname=${spring.cloud.client.ipAddress}eureka.client.serviceUrl.defaultZone=http://${security.user.name}:${security.user.password}@localhost:8765/eureka/eureka.instance.status-page-url-path=/
Configuration application-master.properties for registry 2
spring.application.name=springcloud-eureka-serverserver.port=8765eureka.instance.instance-id=${spring.cloud.client.ipAddress}:${server.port}eureka.instance.hostname=${spring.cloud.client.ipAddress}eureka.client.serviceUrl.defaultZone=http://${security.user.name}:${security.user.password}@localhost:8766/eureka/eureka.instance.status-page-url-path=/
Start

First, start the first service. At this time, set active in the overall configuration application. properties to slave. Then start the startup class. An error is reported at this time, but it does not matter. Start the second one.

spring.profiles.active=slave#spring.profiles.active=master

When the second service is started, set active in application. properties as master. Then start the startup class.

#spring.profiles.active=slavespring.profiles.active=master

In this case, a high-availability registration center is implemented.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.