当前位置:网站首页>搭建Eureka-Server集群
搭建Eureka-Server集群
2022-06-21 19:54:00 【crysw】
1. 简介
Eureka作为微服务注册中心, Eureka-Server可以搭建多台服务注册中心实例, 并相互进行注册, 形成高可用的集群.
2. 创建Eureka注册中心微服务
创建微服务应用microservicecloud-eureka
2.1 导入依赖
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
</dependencies>
<!--springcloud官方仓库-->
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<!--锁定springcloud+springboot版本-->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Finchley.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.0.1.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
2.2 编写配置
server:
port: 7001
spring:
application:
name: eureka-server
# 集群版
eureka:
instance:
hostname: www.eureka01.com # eureka服务端的实例名称, 修改host文件映射的主机名(域名)
instance-id: eureka01
prefer-ip-address: true
server:
enable-self-preservation: true
client:
register-with-eureka: true
fetch-registry: true
service-url:
# 映射上面的主机名
defaultZone: http://www.eureka01.com:7001/eureka,http://www.eureka02.com:7002/eureka,http://www.eureka03.com:7003/eureka
2.3 host文件添加域名映射
C:\Windows\System32\drivers\etc\hosts文件添加自定义域名, 映射到本地地址127.0.0.1
127.0.0.1 www.eureka01.com
127.0.0.1 www.eureka02.com
127.0.0.1 www.eureka03.com
2.4 编写启动类并复制多个实例
首先, 编写eureka-server的启动类, 开启Eureka服务端配置(@EnableEurekaServer注解).
@SpringBootApplication
@EnableEurekaServer // 开启Eureka服务端
public class EurekaServerApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaServerApplication.class);
}
}
然后,启动eureka01实例, 并复制eureka02, eureka03实例后启动各个微服务实例, eureka-server各个实例相互注册, 形成高可用的集群.
复制eureka02实例, VM参数:-Dserver.port=7002 -Deureka.instance.hostname=www.eureka02.com -Deureka.instance.instance-id=eureka02
复制eureka03实例, VM参数:-Dserver.port=7003 -Deureka.instance.hostname=www.eureka03.com -Deureka.instance.instance-id=eureka03
最后, 访问各位服务实例, 查看eureka-server控制台的服务注册列表:http://www.eureka01.com:7001/
http://www.eureka02.com:7002/
http://www.eureka03.com:7003/
个人博客
欢迎各位访问我的个人博客: https://www.crystalblog.xyz/
边栏推荐
- Write your own compiler: intermediate code generation for loop statements such as while, for, and do
- Precautions for Jerry's external radio [chapter]
- Caricature scientifique | Vous pouvez apprendre l'EEG en regardant les images. Voulez - vous essayer?
- 杰理之开启四声道打开 EQ 后播歌卡顿问题【篇】
- F - Phone List HDU - 1671 (字典树查前缀)
- 数据可视化工具软件
- 免费又好用的参考文献管理软件zotero该怎么使用?可以同时支持中文和英文吗?...
- 拖延患者自救指南|“我有不拖延的100种借口,却不愿意跨出一步”
- Definition of unused processing methods when compiling C51 with keil 5
- F - phone list HDU - 1671 (dictionary tree prefix)
猜你喜欢

ACM. HJ35 蛇形矩阵 ●

On the charm of code language

Yx2811 landscape installation driver IC

Introduction to security encryption

Delaying patient self-help guide | "I have 100 excuses for not delaying, but I am not willing to take a step"

Merge two ordered arrays

C language array and pointer exercises (original question + analysis + original code)

Scientific research cartoon | you can learn EEG by looking at the picture. Would you like to try it?

Synchronous Boost dc/dc converter fs3400 synchronous SOT23-6 small current 500mA boost IC

英文论文如何进行润色?
随机推荐
Jerizhi, processing method for prompting chip information mismatch and error code 10 [chapter]
ACM. HJ61 放苹果 ●
Hypebeast, un média à la mode, est sur le point d'être lancé: 530 millions de dollars pour le troisième trimestre
When Jerry made Bluetooth transmission, when he modified stereo to mono differential output, there was a jam sound at the receiving end [chapter]
Definition of unused processing methods when compiling C51 with keil 5
杰理之,提示芯片信 息不匹配,错误代号 10 的处理方法【篇】
Openjudge noi 1.13 45: decimal to octal
Trend media Hypebeast plans to be listed on the curve: with a price of USD 530million, it is planned to be completed in the third quarter
Jerry's acquisition of current audio file (long) file name and current (long) folder name [chapter]
matplotlib plt. Details of subplots()
请问一下,大学生查文献在哪个网站比较好呀?
Operation of 2022 welder (Advanced) examination question bank simulation examination platform
[yolov5] opencv450 loads onnx for reasoning GPU acceleration
Tx9116 Synchronous Boost IC
JS里的数据类型(基础)
盐语Saltalk获800万美元A轮融资:继续扩大团队及市场覆盖
What websites or software are available to translate English literature into Chinese?
科研漫畫 | 看圖可以學腦電,來試試?
ARP protocol and ARP attack
Basic rules of smiles