漂亮的网站设计,福建省网站建设有限公司,wordpress 作者列表,万网主机网站建设数据库怎么弄前言 1#xff1a;对于能提供完整领域服务接口功能的RPC而言#xff0c;例如#xff1b;gRPC、Thrift、Dubbo等#xff0c;服务的注册与发现都是核心功能中非常重要的一环#xff0c;使得微服务得到统一管理。
2#xff1a;在分布式领域中有个著名的CAP理论#xff1b;…前言 1对于能提供完整领域服务接口功能的RPC而言例如gRPC、Thrift、Dubbo等服务的注册与发现都是核心功能中非常重要的一环使得微服务得到统一管理。
2在分布式领域中有个著名的CAP理论一致性Consistency、可用性Availability、分区容错性Partition tolerance这三个要素在分布式系统中最多满足两个不可能三者兼顾。
3通常我们在使用dubbo时zookeeper作为注册中心以选主配置为核心保证CP特性即任何时刻对 Zookeeper 的访问请求能得到一致的数据结果同时系统对网络分割具备容错性但是它不能保证每次服务请求的可用性。
4而 Spring Cloud Netflix 在设计 Eureka 时遵守的就是 AP 原则因为对于服务发现而言可用性比数据一致性显得尤为重要。 案例说明 案列使用版本如下 1jdk 1.8 2Spring Boot 2.0.6.RELEASE 3Spring Cloud Finchley.SR2 新建应用启动类 EurekaServerApplication.java | 三组node代码一致只需要一个普通的springboot添加EnableEurekaServer即可启动
SpringBootApplication
EnableEurekaServer
public class EurekaServerApplication {public static void main(String[] args) {SpringApplication.run( EurekaServerApplication.class, args );}}application.yml | node1 指向另外两台服务registerWithEureka、fetchRegistry和单实例不同需要配置为true
spring:application:name: demo-eureka-serverserver:port: 8081eureka:instance:hostname: node01client:registerWithEureka: truefetchRegistry: trueserviceUrl:defaultZone: http://node02:8082/eureka/,http://node03:8083/eureka/
application.yml | node2 指向另外两台服务
spring:application:name: demo-eureka-serverserver:port: 8082eureka:instance:hostname: node02client:registerWithEureka: truefetchRegistry: trueserviceUrl:defaultZone: http://node03:8083/eureka/,http://node01:8081/eureka/
application.yml | node3 指向另外两台服务
spring:application:name: demo-eureka-serverserver:port: 8083eureka:instance:hostname: node03client:registerWithEureka: truefetchRegistry: trueserviceUrl:defaultZone: http://node01:8081/eureka/,http://node02:8082/eureka/
测试验证 1配置host127.0.0.1 node01 node02 node03 2分别启动node1、node2、node3 3访问http://localhost:8081/ 好了到这里就结束了一偏概述告诉你SpringCloud是什么的学习大家一定要跟着动手操作起来。需要源码的 可si我获取