当前位置:网站首页>Eureka-Server------单节和集群的搭建
Eureka-Server------单节和集群的搭建
2022-08-09 04:53:00 【魔人Majin Buu】
单节点搭建
1,pom依赖
org.springframework.cloud spring-cloud-starter-netflix-eureka-server 2,SpringBoot启动类package com.wwl.eureka_server;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@SpringBootApplication
@EnableEurekaServer
public class EurekaServerApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaServerApplication.class, args);
}
}
3,yaml配置文件,application.yaml
spring:
application:
name: eureka-server
server:
port: 7901
# eureka配置
eureka:
client:
fetch-registry: false
register-with-eureka: false
service-url:
defaultZone: http://eureka1:7901/eureka
instance:
hostname: eureka1
集群搭建
1,依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
2,启动类开启Eureka
package com.wwl.eureka_server;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@SpringBootApplication
@EnableEurekaServer // 开启Eureka
public class EurekaServerApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaServerApplication.class, args);
}
}
3,Eureka注册中心配置(Eureka集群模式)
spring:
application:
name: eureka-server
---
spring:
profiles: eureka1
server:
port: 7901
eureka:
client:
service-url:
defaultZone: http://eureka1:7901/eureka,http://eureka2:7902/eureka,http://eureka3:7903/eureka
instance:
hostname: eureka1
---
spring:
profiles: eureka2
server:
port: 7902
eureka:
client:
service-url:
defaultZone: http://eureka2:7902/eureka,http://eureka1:7901/eureka,http://eureka3:7903/eureka
instance:
hostname: eureka2
---
spring:
profiles: eureka3
server:
port: 7903
eureka:
client:
service-url:
defaultZone: http://eureka3:7903/eureka,http://eureka1:7901/eureka,http://eureka2:7902/eureka
instance:
hostname: eureka3
注意问题:
Eureka集群模式在本地玩的时候,每个节点要配置hostname,并配置本地host文件
边栏推荐
- LeetCode-636. 函数的独占时间
- AttributeError: partially initialized module 'cv2' has no attribute 'gapi_wip_gst_GStreamerPipeline'
- 杰理之播歌曲前后音量大小不一样【篇】
- The influence law of genes for disease - read the paper
- Pycharm Debug调试使用+代码调试理解
- 【Harmony OS】【FAQ】Hongmeng Questions Collection 1
- 【Harmony OS】【ARK UI】公共事件模块
- Harmony OS ets ArkUI 】 【 】 development create a view and building layout
- 抖音直播带货的4个技巧,提升直播间转化率!
- Faced with risk control, what should Amazon do when evaluating self-supporting accounts?
猜你喜欢

How to trim svg and compress
Improve the user experience and add a small detail to your modal popup

GraalVM安装
![[Harmony OS] [ARK UI] ETS context basic operations](/img/40/d5924477c42e2b3246eb212f4be534.png)
[Harmony OS] [ARK UI] ETS context basic operations

【Harmony OS】【ARK UI】Date Basic Operation

软件测试的发展趋势

MySQL: Intent Shared Locks and Intentional Exclusive Locks | Deadlocks | Lock Optimization

【Harmony OS】【ArkUI】ets开发 基础页面布局与数据连接

【Harmony OS】【FAQ】鸿蒙问题合集1

Alibaba Cloud Tianchi Contest Question (Machine Learning) - Repeat Purchase Prediction of Tmall Users (Complete Code)
随机推荐
Ali YunTianChi competition problem (deep learning) - video enhancement (complete code)
【暑期每日一题】洛谷 P1176 路径计数2
pytorch implementation of Poly1CrossEntropyLoss
【Harmony OS】【ARK UI】公共事件模块
时序约束基础
php write online remote file to temp file
Dingding conflicts with RStudio shortcuts--Dingding shortcut settings
【开发者必看】【push kit】推送服务服务典型问题合集2
leetcode:315. 计算右侧小于当前元素的个数
Timing Constraint Basics
Golang 常见知识点整理
后台登录模块以及验证码登录
【Harmony OS】【ARK UI】Date 基本操作
说明高级语言、汇编语言、机器语言三者的区别,谈谈你对汇编语言的认识。
C进阶 - 程序的编译(预处理操作) + 链接
OKR management process, how to implement effective dialogue, using the CFR feedback and recognition?
【Harmony OS】【FAQ】鸿蒙问题合集1
2022 Security Officer-B Certificate Exam Practice Questions and Online Mock Exam
Nacos源码安装
Disappearance of heritability - wiki