目标
1、Eureka集群搭建
2、Eureka自我保护机制
Eureka集群搭建
高可用集群配置
当注册中心扛不住高并发的时候,这时候 要用集群来扛;
普通操作
我们再新建两个module microservice-eureka-server-2002 microservice-eureka-server-2003
1、pom.xml 把依赖加下;
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- 修改后立即生效,热部署 -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
</dependencies>
2、2002 2003的主启动类EurekaServerApplication_2002,EurekaServerApplication_2003复制修改下
package com.xieminglu.microserviceeurekaserver2003;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@EnableEurekaServer
@SpringBootApplication
public class MicroserviceEurekaServer2003Application {
public static void main(String[] args) {
SpringApplication.run(MicroserviceEurekaServer2003Application.class, args);
}
}
3、前面单机的时候 eureka注册中心实例名称 是localhost,现在是集群,不能三个实例都是localhost,这里复杂的办法是搞三个虚拟机,麻烦,这里有简单办法,直接配置本机