当前位置:网站首页>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文件
边栏推荐
- 必须指定GDAL API版本。提供一个路径使用GDAL_CONFIG gdal-config环境
- 学习笔记_numpy图片基本操作_自用
- 浙江DAMA-CDGA/CDGP数据治理认证招生简章
- XJTUSE Professional Course and Experiment Guide
- Ali YunTianChi competition problem (machine learning) - ali cloud security malware detection (complete code)
- 整数倍数数列
- 算法---优美的排列(Kotlin)
- 【暑期每日一题】洛谷 P8086 『JROI-5』Music
- 360 评估反馈问题的示范案例
- 时序约束基础
猜你喜欢
[MLT] Analysis of MLT Multimedia Framework Production and Consumption Architecture (2)
How to trim svg and compress
y91.第六章 微服务、服务网格及Envoy实战 -- 服务网格基础(二)
【MLT】MLT多媒体框架生产消费架构解析(二)
LeetCode - remove consecutive nodes with a sum of zero from a linked list
The influence law of genes for disease - read the paper
JS-DOM-对象的事件onload、匿名函数、this
equals和==
必须指定GDAL API版本。提供一个路径使用GDAL_CONFIG gdal-config环境
【Harmony OS】【ARK UI】Custom popup
随机推荐
单元测试覆盖率怎么算?
ABP中的数据过滤器
XJTUSE Professional Course and Experiment Guide
区别如下概念:助记符、汇编语言、汇编语言程序和汇编程序。
Quantitative Genetics Heritability Calculation 1: Parent-Child Regression Method
pr22.5最新版下载地址
Ali YunTianChi competition problem (deep learning) - video enhancement (complete code)
存储系统架构演变
php uses phpoffice/phpspreadsheet to import and export excel tables
Dingding conflicts with RStudio shortcuts--Dingding shortcut settings
安装pytorch和cuda
【UNR #6 A】面基之路(最短路)
抖音直播间带货最新玩法和运营技巧
Example of 360 assessment feedback questions
MySQL: redo log log - notes for personal use
"IP" command to configure network interface
Ali YunTianChi competition problem (machine learning) - ali cloud security malware detection (complete code)
【开发者必看】【push kit】推送服务服务典型问题合集2
【HMS Core】【FAQ】【AR Engine】AR Engine FAQ
杰理之智能充电仓低电发码关机 触摸不开机【篇】