A: Cluster environment construction
First step: We create a new two registry project called Eureka_register_service_master, another called Eureka_register_service_backup
The application.properties configuration for Eureka_register_service_master is as follows
server.port=7998 eureka.client.register-with-eureka=false eureka.client.fetch-registry=false spring.application.name=eureka-server eureka.instance.hostname=master eureka.client.serviceUrl.defaultZone=http://backup:7999/eureka/ #这里配置的是backup的地址 eureka_register_service_backup的application.properties配置如下
The application.properties configuration for Eureka_register_service_backup is as follows
` server.port=7999eureka.client.register-with-eureka=falseeureka.client.fetch-registry=falsespring.application.name=eureka-servereureka.instance.hostname=backup#这里配置的是master的地址eureka.client.serviceUrl.defaultZone=http://master:7998/eureka/` 上面的配置端口分别是 master端口是7998
BACKUPR Port is 7999
Because I'm using the same machine, I need to bind the host.
127.0.0.1 Master
127.0.0.1 Backup
The second step: Add boot files are Applicationmaster.java,applicationbackup.java
The contents of the code are the same
@EnableEurekaServer @SpringBootApplication public class ApplicationMaster { public static void main(String[] args) { SpringApplication.run(ApplicationMaster.class, args); } } @EnableEurekaServer @SpringBootApplication public class ApplicationBackUp { public static void main(String[] args) { SpringApplication.run(ApplicationBackUp.class, args); } }
Step Three: Start
If the jar is started, the parameter--spring.profiles.active=matser or--spring.profiles.active=backup is required.
The first method is to start with the jar command
' Java-jar Eureka_register_service_matser-1.0.0.jar--spring.profiles.active=matser
java -jar eureka_register_service_backup-1.0.0.jar --spring.profiles.active=backup` 架构代码如下: ![](http://i2.51cto.com/images/blog/201802/08/e143be457842bf385ec7e011c6f70093.jpg?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
MicroServices Architecture Springcloud (iii) EUREKA (Registration center cluster chapter)