EurekaServer的高可用

1、pom.xml

pom文件和之前的EurekaServer的一致

2、application.yml

spring.profiles:可以理解为给这一段配置起了个名字,在我们运行代码的时候,可以选择一段配置去启动

---
spring:
  profiles: peer1
  application:
    name: peer1
eureka:
  instance:
    hostname: peer1
  client:
    serviceUrl:
      defaultZone: http://peer2:8762/eureka/
server:
  port: 8761
---
spring:
  profiles: peer2
  application:
    name: peer2
eureka:
  instance:
    hostname: peer2
  client:
    serviceUrl:
      defaultZone: http://peer1:8761/eureka/
server:
  port: 8762

3、启动类添加注解并启动

@SpringBootApplication
@EnableEurekaServer
public class EurekaServerTogetherApplication {

    public static void main(String[] args) {
        SpringApplication.run(EurekaServerTogetherApplication.class, args);
    }
}

4、启动时,配置

在此处配置你要用的配置

5、先启动的EurekaServer都会报错,属于正常现象,我们访问EurekaServer页面正常即为正常

     第二次启动的EurekaServer不会报错

6、结果

DS Replicas代表本服务器从哪里同步数据

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值