当前位置:网站首页>Eureka集群搭建
Eureka集群搭建
2022-06-11 06:00:00 【暴躁的程序猿啊】
准备工作 因为我们用一台电脑模拟,所有我们修改电脑的etc文件夹下的host文件 加入:
127.0.0.1 eureka8001.cn
127.0.0.1 eureka8002.cn
我们访问这两个地址相当于访问本地的127.0.0.1路径
正式开始
配置集群就是要把多个注册中心互相注册 如: 在8001中注册8002 在8002中注册8001
创建两个eureka注册中心服务一个端口8001 一个端口为8002

8001pom依赖
<dependencies>
<!--新版本eureka-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<artifactId>cloud-api-commons</artifactId>
<groupId>com.rpf.springcloud</groupId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
8001 yml配置文件内容
server:
port: 8001
eureka:
instance:
hostname: eureka8001.cn
client:
register-with-eureka: false #false表示不向注册中心注册自己。
fetch-registry: false #false表示自己端就是注册中心,我的职责就是维护服务实例,并不需要去检索服务
service-url:
defaultZone: http:/eureka8002.cn:8002/eureka
8001启动类
@SpringBootApplication
@EnableEurekaServer
public class EurekaMain8001 {
public static void main(String[] args) {
SpringApplication.run(EurekaMain8001.class,args);
}
}
8002pom依赖
<dependencies>
<!--新版本eureka-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<artifactId>cloud-api-commons</artifactId>
<groupId>com.rpf.springcloud</groupId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
8002yml配置文件
server:
port: 8002
eureka:
instance:
hostname: eureka8002.cn
client:
register-with-eureka: false #false表示不向注册中心注册自己。
fetch-registry: false #false表示自己端就是注册中心,我的职责就是维护服务实例,并不需要去检索服务
service-url:
defaultZone: http:/eureka8001.cn:8001/eureka
8002启动类
@SpringBootApplication
@EnableEurekaServer
public class EurekaMain8002 {
public static void main(String[] args) {
SpringApplication.run(EurekaMain8002.class,args);
}
}
这时我们启动两个项目即可
访问eureka8001.cn:8001
或
eureka8002.cn:8002
可以看到互相注册了对方的服务
边栏推荐
- Sqli-libs post injection question 11-17 actual combat
- What do you need to know about Amazon evaluation?
- Database basic instruction set
- call和apply和bind的区别
- Getting started with kotlin
- What happened to the young man who loved to write code -- approaching the "Yao Guang young man" of Huawei cloud
- Do you know the functions of getbit and setbit in redis?
- Set the IP address using batch
- PgSQL reports an error: current transaction is aborted, commands ignored until end of transaction block
- Summarize the five most common BlockingQueue features
猜你喜欢

JIRA software annual summary: release of 12 important functions

Detailed steps for installing mysql-5.6.16 64 bit green version
![[元数据]LinkedIn-DataHub](/img/6a/247ee77dfc219d26651e5d93b04c98.png)
[元数据]LinkedIn-DataHub

verilog实现双目摄像头图像数据采集并modelsim仿真,最终matlab进行图像显示

How to use perforce helix core with CI build server

那个酷爱写代码的少年后来怎么样了——走近华为云“瑶光少年”

AltiumDesigner2020导入3D Body-SOLIDWORKS三维模型

Error:Execution failed for task ':app:buildNative'. & gt; A problem occurred'x/x/x/'NDK build' error resolution

Altiumdesigner2020 import 3D body SolidWorks 3D model

Servlet
随机推荐
Méthode de la partie du tableau
Dichotomy find template
What is a planning BOM?
[daily exercise] 217 Duplicate element exists
Clear function of ArrayList
使用Meshlab对CAD模型采样点云,并在PCL中显示
[must see for game development] 3-step configuration p4ignore + wonderful Q & A analysis (reprinted from user articles)
ELK日志系统实战(五):安装vector并将数据输出到es、clickhouse案例
Servlet
[usual practice] explore the insertion position
JS -- reference type
Growth Diary 01
[元数据]LinkedIn-DataHub
Implementation of data access platform scheme (Youzu network)
Cocoatouch framework and building application interface
Do we really need conference headphones?
Gilde failed to go to the listener to call back the reason record when loading the Gaussian blur image
Fix Yum dependency conflict
Sign for this "plug-in" before returning home for the new year
Jsonobject jsonarray for parsing