eureka build a clustered environment

The first step: we create two new registry project called eureka_register_service_master, another called eureka_register_service_backup

 

eureka_register_service_master configuration of application.properties   
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/

 

The following configuration eureka_register_service_backup application.properties
[Java]  plain text view  Copy the code
?
1
2
3
4
5
6
7
server.port=7999
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
spring.application.name=eureka-server
eureka.instance.hostname=backup
#这里配置的是master的地址
eureka.client.serviceUrl.defaultZone=http://master:7998/eureka/


 

The above configuration port are

 

master port is 7998
backupr port is 7999

 

Since I use the same machine it is necessary to bind the next host
127.0.0.1      master
127.0.0.1      backup

 

Step two: Add the startup files are ApplicationMaster.java, ApplicationBackUp.java
    Inside the code content is the same
[Java]  plain text view  Copy the code
?
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
    @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);
    }
 
}  

 

More learning materials may be concerned about: gzitcast

Published 795 original articles · won praise 3 · Views 110,000 +

Guess you like

Origin blog.csdn.net/u010395024/article/details/105043893