consul

服务注册发现、配置中心集一体的 Spring Cloud Consul

心已入冬 提交于 2019-11-28 19:18:21
前面讲了 Eureka 和 Spring Cloud Config,今天介绍一个全能选手 「Consul」。它是 HashiCorp 公司推出,用于提供服务发现和服务配置的工具。用 go 语言开发,具有很好的可移植性。被 Spring Cloud 纳入其中,Eureka 停止新版本开发,更多的想让开发者使用 Consul 来作为服务注册发现使用。 Consul 提供的功能包括如下几个: 服务发现 Consul 让服务注册和服务发现(通过 DNS 和 HTTP 接口)更加简单,甚至对于外部服务(例如SaaS)注册也一样。 故障检测 通过健康检查,服务发现可以防止请求被路由到不健康的主机,并且可以使服务容易断开(不再提供服务)。 多数据中心 Consul 不需要复杂的配置即可简便的扩展到多个数据中心,查找其它数据中心的服务或者只请求当前数据中心的服务。 键值存储 灵活的键值存储,提供动态配置、特征标记、协作、leader 选举等功能,通过长轮询实现配置改变的即时通知。 Spring Cloud Consul 将 Consul 进行自动配置和进一步封装。 Spring Cloud Consul 可替代已有的 Spring Cloud Eureka,也就是当做服务注册发现框架使用。并且 Eureka 2.x 版本也已经停止开发,并且 Spring Cloud 官方也建议用 Spring

golang微服务框架go-micro 入门笔记1.搭建 go-micro环境

馋奶兔 提交于 2019-11-28 17:36:58
微服务的本质是让专业的人做专业的事情,做出更好的东西。 golang 具备高并发,静态编译等特性,在性能、安全等方面具备非常大的优势。 go-micro 是基于 golang 的微服务编程框架, go-micro 操作简单、编码高效、功能强大。但是网络上资料偏少,本系列文章定位最简单最容易上手的 go-micro 入门教程,所有案列来自实操,而非网络上的复制粘贴。 本章节的目的是让大家最快速搭建好 go-micro 环境 软件 环境 操作系统 win10 golang go 12.7/AMD64 micro micro version 1.8.4 consul consul 1.5.4 安装micro 最快速有效的方法是使用 GO1.11 以上版本并且设置环境变量 #linux 下 export GO111MODULE=on export GOPROXY=https://goproxy.io # windows下设置如下环境变量 setx GO111MODULE on setx GOPROXY https://goproxy.io # 使用如下指令安装 go get -u -v github.com/micro/micro go get -u -v github.com/micro/go-micro 如果没有git请自行安装git #下载地址 https://git-scm.com

golang微服务框架go-micro 入门笔记1.搭建 go-micro环境

ε祈祈猫儿з 提交于 2019-11-28 12:26:53
微服务的本质是让专业的人做专业的事情,做出更好的东西。 golang 具备高并发,静态编译等特性,在性能、安全等方面具备非常大的优势。 go-micro 是基于 golang 的微服务编程框架, go-micro 操作简单、编码高效、功能强大。但是网络上资料偏少,本系列文章定位最简单最容易上手的 go-micro 入门教程,所有案列来自实操,而非网络上的复制粘贴。 本章节的目的是让大家最快速搭建好 go-micro 环境 软件 环境 操作系统 win10 golang go 12.7/AMD64 micro micro version 1.8.4 consul consul 1.5.4 安装micro 最快速有效的方法是使用 GO1.11 以上版本并且设置环境变量 #linux 下 export GO111MODULE=on export GOPROXY=https://goproxy.io # windows下设置如下环境变量 setx GO111MODULE on setx GOPROXY https://goproxy.io # 使用如下指令安装 go get -u -v github.com/micro/micro go get -u -v github.com/micro/go-micro 如果没有git请自行安装git #下载地址 https://git-scm.com

Consul+Spring boot的服务注册和服务注销

﹥>﹥吖頭↗ 提交于 2019-11-28 12:22:17
一图胜千言 先看一看要做事情,需要在Consul上面实现注册中心的功能,并以2个Spring boot项目分别作为生产者,消费者。 Consul 假设已经完成文章 《Consul的开发者模式之Docker版》 中的所有的配置,并启动了Consul,访问: http://localhost:8500/ui/dc1/services 即如下图: 生产者 生产者-目录结构 这里就是一个简单的spring boot工程。 生产者-build.gradle plugins { id 'org.asciidoctor.convert' version '1.5.3' id 'org.springframework.boot' version '2.1.6.RELEASE' id 'java' } apply plugin: 'io.spring.dependency-management' group = 'com.zyl' version = '0.0.1-SNAPSHOT' sourceCompatibility = '1.8' configurations { developmentOnly runtimeClasspath { extendsFrom developmentOnly } compileOnly { extendsFrom annotationProcessor } }

从零开始搭建spring-cloud(0) --springboot与springcloud的关系

老子叫甜甜 提交于 2019-11-28 09:38:03
Spring Cloud provides tools for developers to quickly build some of the common patterns in distributed systems (e.g. configuration management, service discovery, circuit breakers, intelligent routing, micro-proxy, control bus, one-time tokens, global locks, leadership election, distributed sessions, cluster state). Coordination of distributed systems leads to boiler plate patterns, and using Spring Cloud developers can quickly stand up services and applications that implement those patterns. They will work well in any distributed environment, including the developer’s own laptop, bare metal

How can I 'join' two metrics in a Prometheus query?

柔情痞子 提交于 2019-11-28 08:14:20
I am using the consul exporter to ingest the health and status of my services into Prometheus. I'd like to fire alerts when the status of services and nodes in Consul is critical and then use tags extracted from Consul when routing those alerts. I understand from this discussion that service tags are likely to be exported as a separate metric, but I'm not sure how to join one series with another so I can leverage the tags with the health status. For example, the following query: max(consul_health_service_status{status="critical"}) by (service_name, status,node) == 1 could return: {node="app

最简单环境让Surging先跑起来

半城伤御伤魂 提交于 2019-11-28 07:37:39
一、准备环境 1.consul 2.Redis 系统win7+ 、dotnet core SDK 2.2 二、编译代码 git克隆代码,从github克隆代码太慢可以考虑使用码云加速。 我这里有建一个镜像库,https://gitee.com/imiyu/surging 编译 如果有项目编译失败,报以上提示,修改项目的语言版本为7.3 三、修改配置 启动 修改配置surgingSettings.json 去掉Packages中的SkywalkingModule;EventBusRabbitMQModule; 如果默认配置使用的zookeeper 则修改为ConsulModule。 启动Consul (开发模式) consul agent -dev 启动 redis redis-server redis.windows.conf 启动项目Surging.Services.Server 启动成功,打开浏览器试一下:http://127.0.0.1:280/swagger/index.html 找到sayhello try it,展开的表单中name 随便输入字符,运行。 返回json { "Entity": "1323 say:hello", "IsSucceed": true, "Message": "", "StatusCode": 200 } OK 至此

springcloud(一)

孤者浪人 提交于 2019-11-28 07:16:24
Spring Cloud是什么鬼?   Spring Cloud是一个基于Spring Boot实现的云应用开发工具,它为基于JVM的云应用开发中的配置管理、服务发现、断路器、智能路由、微代理、控制总线、全局锁、决策竞选、分布式会话和集群状态管理等操作提供了一种简单的开发方式。 微服务是可以独立部署、水平扩展、独立访问(或者有独立的数据库)的服务单元,springcloud就是这些微服务的大管家,采用了微服务这种架构之后,项目的数量会非常多,springcloud做为大管家需要管理好这些微服务,自然需要很多小弟来帮忙。 主要的小弟有:Spring Cloud Config、Spring Cloud Netflix(Eureka、Hystrix、Zuul、Archaius...)、Spring Cloud Bus、Spring Cloud for Cloud Foundry、Spring Cloud Cluster、Spring Cloud Consul、Spring Cloud Security、Spring Cloud Sleuth、Spring Cloud Data Flow、Spring Cloud Stream、Spring Cloud Task、Spring Cloud Zookeeper、Spring Cloud Connectors、Spring Cloud

go micro v1.9.1 安装

女生的网名这么多〃 提交于 2019-11-28 03:57:49
1. 安装protoc-gen-micro 1) protoc 到 https://github.com/protocolbuffers/protobuf/releases 下载编译好的版本 protoc-3.9.1-win64.zip 。 2) protoc的go插件protoc-gen-go GIT_TAG="v1.2.0" # change as needed go get -d -u github.com/golang/protobuf/protoc-gen-go git -C "$(go env GOPATH)"/src/github.com/golang/protobuf checkout $GIT_TAG go install github.com/golang/protobuf/protoc-gen-go 也可以直接到 https://github.com/golang/protobuf/tree/v1.3.2 下载。 离线下载需要手动编译。 进入$GOPATH/src/github.com/golang/protobuf/protoc-gen-go go build -o protoc-gen-go main.go 3) go get github.com/micro/protoc-gen-micro 若开发环境无法上网,可以直接在 https://github

Docker跨主机通信(九)

我的未来我决定 提交于 2019-11-28 03:12:21
容器网络 在前面的博客中已经详细讲解了几种网络方案: none, host, bridge,user-defined。但是他们只是解决了单个主机间的容器的通信问题,并不能实现多个主机容器之间的通信。本篇博客将详细介绍如何实现该功能。 跨主机网络方案包括两大类: docker原生的:overlay和macvlan 第三方方案:flannel、weave和calico 本篇博客将详细讲解overlay以及weave两种方案。 overlay Docerk overlay 网络需要一个 key-value 数据库用于保存网络状态信息,包括 Network、Endpoint、IP 等。Consul、Etcd 和 ZooKeeper 都是 Docker 支持的 key-vlaue 软件,我们这里使用 Consul。 在 docker 主机 host1(172.20.10.2)和 host2(172.20.10.7)上实践各种跨主机网络方案,在 172.20.10.2 上部署支持的组件,比如 Consul。 第一步:启动路由转发功能 两台主机上面都需要开启 [root@ken3 ~]# echo "1" > /proc/sys/net/ipv4/ip_forward 第二步:运行consul 最简单的方式是以容器方式运行 Consul: [root@ken1 ~]# docker run -d