consul

Spring Cloud(中文版)

匿名 (未验证) 提交于 2019-12-02 22:56:40
I.云原生应用 Spring Cloud上下文:应用上下文服务 2.1。Bootstrap应用程序上下文 2.2。应用程序上下文层次结构 2.3。更改Bootstrap属性的位置 2.4。覆盖远程属性的值 2.5。自定义Bootstrap配置 2.6。自定义Bootstrap属性源 2.7。记录配置 2.8。环境变化 2.9。刷新范围 2.10。加密和解密 2.11。端点 Spring Cloud Commons:Common Abstractions 3.1。@EnableDiscoveryClient 3.1.1。健康指标 3.2。ServiceRegistry 3.2.1。ServiceRegistry自动注册 3.2.2。Service Registry Actuator Endpoint 3.3。Spring RestTemplate作为负载均衡器客户端 3.4。Spring WebClient作为负载均衡器客户端 3.4.1。重试失败的请求 3.5。多个RestTemplate对象 3.6。Spring WebFlux WebClient作为负载均衡器客户端 3.7。忽略网络接口 3.8。HTTP客户端工厂 3.9。启用功能 3.9.1。功能类型 3.9.2。声明功能 II。Spring Cloud Config 4.快速入门 4.1。客户端使用 Spring

Linux中Consul集群部署

匿名 (未验证) 提交于 2019-12-02 22:10:10
分配三台虚拟机: 192.168.5.125 192.168.5.128 192.168.5.129 常用命令 command : agent作用:运行一个consul agent members作用:列出consul cluster集群中的members 常用选项 option : -data-dir 作用:指定agent储存状态的数据目录,这是所有agent都必须的,对于server尤其重要,因为他们必须持久化集群的状态 -config-dir作用:指定service的配置文件和检查定义所在的位置,通常会指定为"某一个路径/consul.d"(通常情况下,.d表示一系列配置文件存放的目录) -config-file作用:指定一个要装载的配置文件,该选项可以配置多次,进而配置多个配置文件(后边的会合并前边的,相同的值覆盖) -dev作用:创建一个开发环境下的server节点,该参数配置下,不会有任何持久化操作,即不会有任何数据写入到磁盘,这种模式不能用于生产环境(因为第二条) -bootstrap-expect作用:该命令通知consul server我们现在准备加入的server节点个数,该参数是为了延迟日志复制的启动直到我们指定数量的server节点成功的加入后启动。 -node作用:指定节点在集群中的名称,该名称在集群中必须是唯一的(默认采用机器的host)推荐

.net core Ocelot Consul 实现API网关 服务注册 服务发现 负载均衡

匿名 (未验证) 提交于 2019-12-02 22:10:10
大神张善友 分享过 һƪ 《.NET Core 在腾讯财付通的企业级应用开发实践》 里面就是用.net core 和 Ocelot搭建的可扩展的高性能Api网关。 Ocelot( http://ocelot.readthedocs.io )是一个用.NET Core实现并且开源的API网关,它功能强大,包括了:路由、 负载均衡 、请求聚合、认证、鉴权、限流熔断等,这些功能只都只需要简单的配置即可完成。 Consul(https://www.consul.io)是一个分布式,高可用、支持多数据中心的服务注册、发现、健康检查和配置共享的服务软件,由 HashiCorp 公司用 Go 语言开发。 Ocelot 天生集成 对Consul支持,在OcelotGateway项目中Ocelot.json配置就可以开启 ocelot + consul 的组合使用,实现服务注册、服务发现、 健康检查 、负载均衡。 软件版本 Asp.net Core :2.0 Ocelot :7.1.0-unstable0011 (开发时最新) Consul :1.1.0(开发时最新) Ocelot搭建Api网关;2、Ocelot+ Consul 实现下游服务的 服务注册、服务发现、 健康检查、负载均衡。 项目结构 Snai.Ocelot 网关: Snai.ApiGateway Asp.net Core 2.0

Ocelot(九)- 教你如何配置Ocelot?

匿名 (未验证) 提交于 2019-12-02 22:06:11
配置 可以在 此处 找到示例配置 。 配置有两个部分。 一组ReRoutes和一个GlobalConfiguration。 ReRoutes是告诉Ocelot如何处理上游请求的对象。 全局配置有点hacky并允许覆盖ReRoute特定设置。 如果您不想管理大量ReRoute特定设置,这将非常有用。 { "ReRoutes": [], "GlobalConfiguration": {} } { "DownstreamPathTemplate": "/", "UpstreamPathTemplate": "/", "UpstreamHttpMethod": [ "Get" ], "AddHeadersToRequest": {}, "AddClaimsToRequest": {}, "RouteClaimsRequirement": {}, "AddQueriesToRequest": {}, "RequestIdKey": "", "FileCacheOptions": { "TtlSeconds": 0, "Region": "" }, "ReRouteIsCaseSensitive": false, "ServiceName": "", "DownstreamScheme": "http", "DownstreamHostAndPorts": [ { "Host":

.net core grpc 实现通信(一)

匿名 (未验证) 提交于 2019-12-02 22:06:11
在上一篇 .net core grpc 实现通信(一) 中,我们实现的grpc通信在.net core中的可行性,但要在微服务中真正使用,还缺少 服务注册,服务发现及负载均衡等,本篇我们将在 .net core grpc 通信 的基础上加上 服务注册,服务发现,负载均衡。 如对.net core grpc 通信不太熟悉的,可以看上一篇 .net core grpc 实现通信(一) ,然后再看本篇。 grpc(https://grpc.io/)是google发布的一个开源、高性能、通用RPC(Remote Procedure Call)框架,使用HTTP/2协议,支持多路复用,并用ProtoBuf作为序列化工具,提供跨语言、跨平台支持。 Consul(https://www.consul.io)是一个分布式,高可用、支持多数据中心的服务注册、发现、健康检查和配置共享的服务软件,由 HashiCorp 公司用 Go 语言开发。 本次服务注册、发现 通过 Consul Api 来实现,开发过程中结合.net core 依赖注入,切面管道思想等。 软件版本 .net Core:2.0 grpc:1.11.0 Consul:1.1.0 Consul Nuget注册组件:0.7.2.5 项目结构 .net core 代码部分: Snai.GrpcClient 客户端 .net core 2

How to self register a service with Consul

妖精的绣舞 提交于 2019-12-02 21:26:07
I'm trying to self register my ASP.NET Core application to Consul registry on startup and deregister it on shutdown. From here I can gather that calling the http api [ put /v1/agent/service/register ] might be the way to go (or maybe not!). From my app, I thought I'll target the Startup class, starting with adding the my .json file public Startup(IHostingEnvironment env) { var builder = new Configuration().AddJsonFile("consulconfig.json"); Configuration = builder.Build(); } But now, I'm stuck as ConfigureServices method tells me thats where I add services to the container, and Configure method

What is the conceptual difference between Service Discovery tools and Load Balancers that check node health?

牧云@^-^@ 提交于 2019-12-02 21:04:43
Recently several service discovery tools have become popular/"mainstream", and I’m wondering under what primary use cases one should employ them instead of traditional load balancers. With LBs, you cluster a bunch of nodes behind the balancer, and then clients make requests to the balancer, who then (typically) round robins those requests to all the nodes in the cluster. With service discovery ( Consul , ZK , etc.), you let a centralized “consensus” service determine what nodes for particular service are healthy, and your app connects to the nodes that the service deems as being healthy. So

【Spring Cloud】服务注册与发现组件——Eureka(二)

ぐ巨炮叔叔 提交于 2019-12-02 06:27:27
一、Eureka原理 1、架构图 首先来看eureka的官方结构图   所有应用作为Eureka Client和Eureka Server交互,服务提供者启动时向Eureka Server注册自己的IP、端口、提供服务等信息,并定时续约更新自己的状态。   服务消费者通过Eureka Server发现得到所需服务的提供者地址信息,然后向服务提供者发起远程调用。   为了保证Eureka注册中心的高可用,可以集群部署,其中一个节点信息又更新时通知其他Server节点,不同节点的Eureka通过Replicate进行数据同步。 2、基本原理 在Eureka响应的过程中,有三个角色,分别是Eureka、服务提供者、服务消费者; 在服务启动后,服务提供者向Eureka注册自己的信息,如调用地址、提供服务信息等 Eureka为服务注册中心,向外暴露自己的地址,负责管理、记录服务提供者的信息,同时将符合要求的服务提供者地址列表返回服务消费者 服务消费者向Eureka订阅服务,表达自己的需求,然后得到服务提供者消息,远程调用即可 Eureka包含两个组件:Eureka Server和Eureka Client,作用如下: Eureka Client是一个Java客户端,主要用来简化和Eureka Server的交互 Eureka Server提供服务发现的能力,各个微服务启动时,通过Eureka