当前位置:网站首页>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文件
边栏推荐
- MySQL: Implementation Principles of Submitted Read and Repeatable Read | MVCC (Multi-Version Concurrency Control) - Notes for Your Own Use
- Hhhhgffsb
- XJTUSE Professional Course and Experiment Guide
- 【HMS Core】【FAQ】【AR Engine】AR Engine FAQ
- 【Harmony OS】【ArkUI】ets开发 图形与动画绘制
- ABP 6.0.0-rc.1的新特性
- 换座位[异或巧妙的让奇偶互换]
- Cluster deployment using ceph-deploycep with 3 disks as dedicated osd
- [MLT] Analysis of MLT Multimedia Framework Production and Consumption Architecture (2)
- Pycharm社区版专业版下载安装环境配置【精细到每一个步骤】
猜你喜欢
随机推荐
区别如下概念:助记符、汇编语言、汇编语言程序和汇编程序。
npm package.json
时序约束基础
Example of 360 assessment feedback questions
pr22.5最新版下载地址
【Harmony OS】【ARK UI】ETS 上下文基本操作
EDI对接 New York & Company案例
ABP中的数据过滤器
XJTUSE Professional Course and Experiment Guide
杰理之SD卡切回蓝牙没有作用【篇】
Ali YunTianChi competition problem (machine learning) - O2O coupons prediction (complete code)
HP路由器和交换机日志分析
Ridge regression and LASSO regression
抖音直播带货的4个技巧,提升直播间转化率!
全栈代码测试覆盖率及用例发现系统的建设和实践
Pycharm社区版专业版下载安装环境配置【精细到每一个步骤】
2022-08-07 反思
【暑期每日一题】洛谷 P1216 [USACO1.5][IOI1994]数字三角形 Number Triangles
GraalVM安装
【暑期每日一题】洛谷 P4325 [COCI2006-2007#1] Modulo