网站首页 > 博客文章 正文
Eureka Server没有后端存储,所有的注册信息全部放在内存中。
默认情况下,一个Eureka Server也是一个Eureka Client。也需要配置一个注册中心url,去找到对端的注册中心。以实现高可用。
单注册中心模式:
就像上一篇的示例。
server: port: 8761 eureka: instance: hostname: localhost client: registerWithEureka: false fetchRegistry: false serviceUrl: defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
注意,这种模式下,我们会把client配置中的registerWithEureka和fetchRegistry置为false
因为不存在另一个注册中心。serviceUrl设置的是自己。不能自己向自己注册。
集群模式
模拟3节点组建的集群
如图,新建3个配置文件,分别配置3个节点的属性。
一定是application-xxx.yml。这是springboot中约定的。
内容类似,对应修改即可
server: port: 8761 spring: profiles: peer1 eureka: instance: hostname: peer1 client: serviceUrl: defaultZone: http://peer2:8762/eureka/,http://peer3:8763/eureka/
因为我是在一台机器上操作,所以需要改下机器的域名。
我是win7,修改c:\windows\system32\drivers\etc\hosts文件
加上
127.0.0.1 peer1 127.0.0.1 peer2 127.0.0.1 peer3
启动,不需要打三个包去启动。
可以通过在idea中修改启动参数,启动多个
启动参数添加 --spring.profiles.active=peer1
注意右上角的单例选项要勾掉
启动好之后,
在peer1的控制台,可以看到他的备节点是peer2和peer3。同理可以看看peer2和3的
再启动2个服务
同样的操作,改造下配置文件
配置代码:
spring: application: name: service-hello eureka: client: serviceUrl: defaultZone: http://peer1:8761/eureka/,http://peer2:8762/eureka/,http://peer3:8763/eureka/ server: port: 8771
同样启动两个服务
现在的架构:
猜你喜欢
- 2024-10-08 一文掌握Spring Cloud Eureka(一文掌握图像超分辨率重建)
- 2024-10-08 「开源」SpringCloud+vue搭建的商城项目
- 2024-10-08 容器微服务和持续集成,(一)Spring cloud搭建部署
- 2024-10-08 使用 Docker 部署 Spring Cloud 项目详细步骤
- 2024-10-08 使用Intellij中的Spring Initializr来构建Spring Boot/Cloud工程
- 2024-10-08 Spring Boot+Spring Cloud实现itoken项目
- 2024-10-08 史上最简单的SpringCloud教程|docker部署spring cloud项目
- 2024-10-08 使用Intellij中的Spring Initializr来快速构建Spring Boot/Cloud
- 2024-10-08 10年IT老兵亲述SpringCloud开发从入门到实战文档
- 2024-10-08 Spring Cloud Eureka:服务注册与发现
你 发表评论:
欢迎- 07-08Google Cloud Platform 加入支持 Docker 的容器引擎
- 07-08日本KDDI与Google Cloud 签署合作备忘录,共探AI未来
- 07-08美国Infoblox与Google Cloud合作推出云原生网络和安全解决方案
- 07-08GoogleCloud为Spanner数据库引入HDD层,将冷存储成本降低80%
- 07-08谷歌推出Cloud Dataproc,缩短集群启动时间
- 07-08Infovista与Google Cloud携手推进射频网络规划革新
- 07-08比利时Odoo与Google Cloud建立增强合作,扩大全球影响力
- 07-08BT 和 Google Cloud 通过 Global Fabric 加速 AI 网络
- 最近发表
-
- Google Cloud Platform 加入支持 Docker 的容器引擎
- 日本KDDI与Google Cloud 签署合作备忘录,共探AI未来
- 美国Infoblox与Google Cloud合作推出云原生网络和安全解决方案
- GoogleCloud为Spanner数据库引入HDD层,将冷存储成本降低80%
- 谷歌推出Cloud Dataproc,缩短集群启动时间
- Infovista与Google Cloud携手推进射频网络规划革新
- 比利时Odoo与Google Cloud建立增强合作,扩大全球影响力
- BT 和 Google Cloud 通过 Global Fabric 加速 AI 网络
- NCSA和Google Cloud合作开发AI驱动的网络防御系统,加强泰国网络空间的安全性
- SAP将在沙特阿拉伯 Google Cloud 上推出BTP服务
- 标签列表
-
- ifneq (61)
- 字符串长度在线 (61)
- googlecloud (64)
- messagesource (56)
- promise.race (63)
- 2019cad序列号和密钥激活码 (62)
- window.performance (66)
- qt删除文件夹 (72)
- mysqlcaching_sha2_password (64)
- ubuntu升级gcc (58)
- nacos启动失败 (64)
- ssh-add (70)
- jwt漏洞 (58)
- macos14下载 (58)
- yarnnode (62)
- abstractqueuedsynchronizer (64)
- source~/.bashrc没有那个文件或目录 (65)
- springboot整合activiti工作流 (70)
- jmeter插件下载 (61)
- 抓包分析 (60)
- idea创建mavenweb项目 (65)
- vue回到顶部 (57)
- qcombobox样式表 (68)
- tomcatundertow (58)
- pastemac (61)
本文暂时没有评论,来添加一个吧(●'◡'●)