In the microservices architecture, the registry is an essential component
The registration center we built earlier is only suitable for local development. In the production environment, a cluster must be set up to ensure high availability.
Eureka's cluster setup is simple, and each Eureka needs to specify another N Eureka address in the configuration.
Below we explain with 2 nodes
We have master and slaveone 2 machines, what we need to do is:
If it is 3 machines, then so on:
First we need to add 2 property files to start different instances through different environments.
Add application-master.properties
server.port=8761
# pointing to your slave node Eureka
eureka.client.serviceUrl.defaultZone=http://username:password@slaveone:8762/eureka/
Add application-slaveone.properties
server.port=8762
#Eureka pointing to your primary node
eureka.client.serviceUrl.defaultZone=http://username:password@master:8761/eureka/
Master and slaveone are hostname, can be added in the hosts file, directly write IP
Add the following content to application.properties
spring.application.name=fangjia-eureka
eureka.instance.hostname=localhost
# Since the app is a registration center, it is set to false, which means that you do not register yourself with the registration center.
eureka.client.register-with-eureka=false
# Since the role of the registry is to maintain a service instance, he does not need to retrieve the service, so it is also set to false.
eureka.client.fetch-registry=false
# Close self protection
eureka.server.enableSelfPreservation=false
security.basic.enabled=true
Security.user.name=username
Security.user.password=Password
# Specify a different environment
spring.profiles.active=master
Start on the A machine by default to start with the master, then add --spring.profiles.active=slaveone on the B machine to start
In this way, the master is registered in the slaveone, the slaveone is registered in the master, and the configuration information on the two sides is synchronized. No matter who hangs, the application can continue to use the surviving registry.
Specific code can refer to my github:
SpringCloud uses Eureka Server as the registry. In order to achieve high availability, it must be clustered Reference to this posthttp://blog.didispace.com/springcloud6/ Thank God Zhai Yongchao for th...
In the previous article, we introduced the registration and discovery of services. An Eureka Server service is an instance. When thousands of clients register with it, its pressure is very high. If it...
Article Directory Spring Cloud Learning |-02-Eureka cluster achieves high availability 1. Start Eureka 1.1 Start Eureka registration service 1 1.2 Start Eureka registration service 2 and 3 2. Registry...
Seven, Eureka Server High Availability Cluster 7.1 Eureka Server High Availability Cluster In front of us to achieve a single-node service registered with the service Eureka Server discovery function....
Spring Cloud Eureka High Availability High availability client (HA client) Mostly used in production environments, client applications associate or configure a registry server cluster to avoid single ...
1.Server end high availability 1.1 Start (eurkerServerTestApplication1 eurkerServerTestApplication2 registered with each other) 1.2 start The registration 2.1client...
Eureka High Availability in Spring Cloud I use three Eureka Servers and one Eureka Client to demonstrate Eureka's high availability. The architecture diagram is as follows: These three Eureka Servers ...
Importance: a problem The importance spring cloud Eureka registry What is High Availability Cluster Why build a high-availability cluster registry Why kick a node goes down We think about the above pr...
As a registration center, Eureka must guarantee high availability, otherwise it will directly affect the entire service system. The following is a multi-service center cluster configuration for...
February 28, 2017 17:18:48Don't be too light Personal classification:Microservice Copyright statement: This article is an original article of the blogger and may not be reproduced without the pe...