Eureka分区集群部署,零基础也能看得懂
最后这里放上我这段时间复习的资料,这个资料也是偶然一位朋友分享给我的,里面包含了腾讯、字节跳动、阿里、百度2020-2021面试真题解析,并且把每个技术点整理成了视频和PDF(知识脉络 + 诸多细节)。还有高级架构技术进阶脑图、高级进阶架构资料帮助大家学习提升进阶,这里我也免费分享给大家也节省大家在网上搜索资料的时间来学习,也可以分享给身边好友一起学习。一起互勉~《互联网大厂面试真题解析、进阶开发
prefer-same-zone-eureka: true
register-with-eureka: true
region: shenzhen
availability-zones:
shenzhen: zone-yantian,zone-luohu,zone-nanshan,zone-baoan
fetch-registry: true
service-url:
zone-yantian: http://eureka18881.com:18881/eureka/
zone-luohu: http://eureka18882.com:18882/eureka/
zone-nanshan: http://eureka18883.com:18883/eureka/
zone-baoan: http://eureka18884.com:18884/eureka/
Eureka-Luohu的Eureka Server配置文件
server:
port: 18882
spring:
application:
name: Eureka-Luohu
eureka:
instance:
hostname: eureka18882.com
client:
prefer-same-zone-eureka: true
register-with-eureka: true
region: shenzhen
availability-zones:
shenzhen: zone-luohu,zone-yantian,zone-nanshan,zone-baoan
fetch-registry: true
service-url:
zone-yantian: http://eureka18881.com:18881/eureka/
zone-luohu: http://eureka18882.com:18882/eureka/
zone-nanshan: http://eureka18883.com:18883/eureka/
zone-baoan: http://eureka18884.com:18884/eureka/
Eureka-Nanshan的Eureka Server配置文件
server:
port: 18883
spring:
application:
name: Eureka-Nanshan
eureka:
instance:
hostname: eureka18883.com
client:
prefer-same-zone-eureka: true
register-with-eureka: true
region: shenzhen
availability-zones:
shenzhen: zone-nanshan,zone-luohu,zone-yantian,zone-baoan
fetch-registry: true
service-url:
zone-yantian: http://eureka18881.com:18881/eureka/
zone-luohu: http://eureka18882.com:18882/eureka/
zone-nanshan: http://eureka18883.com:18883/eureka/
zone-baoan: http://eureka18884.com:18884/eureka/
Eureka-Baoan的Eureka Server配置文件
server:
port: 18884
spring:
application:
name: Eureka-Baoan
eureka:
instance:
hostname: eureka18884.com
client:
prefer-same-zone-eureka: true
register-with-eureka: true
region: shenzhen
availability-zones:
shenzhen: zone-baoan,zone-nanshan,zone-luohu,zone-yantian
fetch-registry: true
service-url:
zone-yantian: http://eureka18881.com:18881/eureka/
zone-luohu: http://eureka18882.com:18882/eureka/
zone-nanshan: http://eureka18883.com:18883/eureka/
zone-baoan: http://eureka18884.com:18884/eureka/
2.3 启动集群
依次启动集群中四个Eureka Server服务,等待集群之间稳定后,访问Eureka Server的Dashboard,此时在四台Eureka Server中的任意一台都可以看到相同的服务注册信息Instance currently registered with Eureka,以及DS Replicaes信息(这个不相同哦,不需要复制自己……),此时说明Eureka Server Cluster已经正常启动了。
2.4 服务注册
Eureka Server分区本质上除了达到高可用之外,最主要是为了给客户端提供最优的服务,以此来达到服务的最快响应。在Eureka Server中注册两个服务Server-01和Server-02,Server-01中metadata-map zone选择zone-yantian,Server-02中metadata-map zone选择zone-louhu。(注意两个服务的服务名均为Server)
Server-01配置文件
server:
port: 19991
spring:
application:
name: Server
eureka:
instance:
prefer-ip-address: true
metadata-map:
zone: zone-yantian
client:
region: shenzhen
availability-zones:
shenzhen: zone-yantian,zone-luohu,zone-nanshan,zone-baoan
service-url:
zone-yantian: http://eureka18881.com:18881/eureka/
zone-luohu: http://eureka18882.com:18882/eureka/
zone-nanshan: http://eureka18883.com:18883/eureka/
zone-baoan: http://eureka18884.com:18884/eureka/
fetch-registry: true
register-with-eureka: true
prefer-same-zone-eureka: true
Server-01中提供一个Rest Api端点
@RestController
@RequestMapping(“/zone”)
public class ZoneController {
@GetMapping
public String zone() {
return “Server zone-yantian”;
}
}
Server-02配置文件
server:
port: 19992
spring:
application:
name: Server
eureka:
instance:
prefer-ip-address: true
metadata-map:
zone: zone-luohu
client:
region: shenzhen
availability-zones:
shenzhen: zone-luohu,zone-yantian,zone-nanshan,zone-baoan
service-url:
zone-yantian: http://eureka18881.com:18881/eureka/
zone-luohu: http://eureka18882.com:18882/eureka/
zone-nanshan: http://eureka18883.com:18883/eureka/
zone-baoan: http://eureka18884.com:18884/eureka/
fetch-registry: true
register-with-eureka: true
prefer-same-zone-eureka: true
Server-02中提供一个Rest Api端点
@RestController
@RequestMapping(“/zone”)
public class ZoneController {
@GetMapping
public String zone() {
return “Server zone-luohu”;
}
}
此时访问Eureka dashboard可以看到Server 有两个实例注册到了Eureka Server Cluster中。
2.4 服务消费
创建一个服务消费者Consumer-01,用于测试服务调用分发的具体情况。
Consumer-01配置文件,其中指定metadata-map.zone为zone-luohu
server:
port: 17771
spring:
application:
name: Consumer-01
eureka:
instance:
prefer-ip-address: true
metadata-map:
zone: zone-luohu
client:
region: shenzhen
availability-zones:
shenzhen: zone-luohu,zone-yantian,zone-nanshan,zone-baoan
service-url:
zone-yantian: http://eureka18881.com:18881/eureka/
zone-luohu: http://eureka18882.com:18882/eureka/
zone-nanshan: http://eureka18883.com:18883/eureka/
zone-baoan: http://eureka18884.com:18884/eureka/
fetch-registry: true
register-with-eureka: true
prefer-same-zone-eureka: true
提供一个Rest Api访问端点:
@RestController
@RequestMapping(“/consumer”)
public class ZoneController {
@Autowired
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数初中级Android工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则近万的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Android移动开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Android开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!
如果你觉得这些内容对你有帮助,可以扫码获取!!(备注:Android)
最后
最后这里放上我这段时间复习的资料,这个资料也是偶然一位朋友分享给我的,里面包含了腾讯、字节跳动、阿里、百度2020-2021面试真题解析,并且把每个技术点整理成了视频和PDF(知识脉络 + 诸多细节)。
还有 高级架构技术进阶脑图、高级进阶架构资料 帮助大家学习提升进阶,这里我也免费分享给大家也节省大家在网上搜索资料的时间来学习,也可以分享给身边好友一起学习。
一起互勉~
《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!
你觉得这些内容对你有帮助,可以扫码获取!!(备注:Android)**
最后
最后这里放上我这段时间复习的资料,这个资料也是偶然一位朋友分享给我的,里面包含了腾讯、字节跳动、阿里、百度2020-2021面试真题解析,并且把每个技术点整理成了视频和PDF(知识脉络 + 诸多细节)。
还有 高级架构技术进阶脑图、高级进阶架构资料 帮助大家学习提升进阶,这里我也免费分享给大家也节省大家在网上搜索资料的时间来学习,也可以分享给身边好友一起学习。
[外链图片转存中…(img-3Hq7aUA0-1712486886698)]
[外链图片转存中…(img-PpcxLXJO-1712486886698)]
一起互勉~
《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!
更多推荐
所有评论(0)