Eureka-server集群2个节点的搭建
1.导包:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
2.配置yaml:
eureka:
instance:
hostname: peer1 #在hosts文件配置
client:
service-url:
defaultZone: http://peer2:7902/eureka/
server:
port: 7901
spring:
application:
name: cloud-eureka-servers
profiles: peer1
--- #以下相当于另一个配置文件 .yaml
eureka:
instance:
hostname: peer2
client:
service-url:
defaultZone: http://peer1:7901/eureka/
server:
port: 7902
spring:
application:
name: cloud-eureka-servers
profiles: peer2
3.在主类上添加注解:@EnableEurekaServer
分别启动:CloudEurekaServersApplication CloudEurekaServersApplication(1)