consul

Spring Boot + Spring Cloud 构建微服务系统(一):服务注册和发现(Consul)

蹲街弑〆低调 提交于 2019-12-17 01:48:41
使用Consul提供注册和发现服务 什么是 Consul Consul 是 HashiCorp 公司推出的开源工具,用于实现分布式系统的服务发现与配置。与其它分布式服务注册与发现的方案,Consul 的方案更“一站式”,内置了服务注册与发现框架、分布一致性协议实现、健康检查、Key/Value 存储、多数据中心方案,不再需要依赖其它工具(比如 ZooKeeper 等)。使用起来也较为简单。Consul 使用 Go 语言编写,因此具有天然可移植性(支持Linux、windows和Mac OS X);安装包仅包含一个可执行文件,方便部署,与 Docker 等轻量级容器可无缝配合。 Consul 安装 访问 Consul 官网 ,根据操作系统类型,选择下载 Consul 的最新版本。我这里选择windows版本。 下载下来是一个zip压缩包,解压之后,是一个exe可执行文件。 打开CMD终端,进入consul.exe所在目录,执行如下命令启动Consul服务。 cd C:\consul_1.3.0_windows_amd64  # 进入consul.exe所在目录 consul agent -dev # 启动服务, -dev 表示开发模式运行,另外还有 -server 表示服务模式运行 启动过程信息如下图所示。 启动成功之后,访问 http://localhost:8500 , 可以查看

002-consul使用技巧

旧时模样 提交于 2019-12-14 19:39:43
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> consul 使用技巧 查看所有注册的服务 consul catalog services 配置consul.json { "server": true, "datacenter": "testgame", "client_addr": "0.0.0.0", "advertise_addr":"192.168.83.70", "bootstrap_expect": 1, "enable_syslog": true, "enable_script_checks": true, "data_dir": "/usr/local/consul/data", "node_name": "consul01", "ui":true, "recursors" : ["8.8.8.8"], "ports" : { "dns" : 53, "http": 8500, "server": 8300 } } 启动 /usr/local/consul/consul agent --config-dir=/usr/local/consul/conf/consul.json -ui 提示:如果想添加服务,则修改启动命令,并在conf/目录下添加json配置文件 添加json文件 echo '{"service": {"name": "web

Consul not deregistering zombie services

a 夏天 提交于 2019-12-14 03:42:02
问题 I am deploying a simple hello world nginx container with marathon, and everything seems to work well, except that I have 6 containers that will not deregister from consul. docker ps shows none of the containers are running. I tried using the /v1/catalog/deregister endpoint to deregister the services, but they keep coming back. I then killed the registrator container, and tried deregistering again. They came back. I am running registrator with docker run -d --name agent-registrator -v /var/run

个推基于 Consul 的配置管理

蓝咒 提交于 2019-12-14 00:18:23
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 作者:个推应用平台基础架构高级研发工程师 阿飞 在微服务架构体系中,由于微服务众多,服务之间又有互相调用关系,因此,一个通用的分布式配置管理是必不可少的。一般来说,配置管理需要解决配置集中管理、在系统运行期间可实现动态配置、配置修改后支持自动刷新等问题。 在大多数微服务体系中,都会有一个名为配置文件的功能模块来提供统一的分布式配置管理。构建配置中心,统一对应用中各个微服务进行管理,对微服务体系的意义重大。 Consul为什么适合做配置管理 Consul作为轻量级的分布式K/V存储系统,搭建方便,可用性高,并且支持多数据中心,提供Web UI进行K/V管理。此外Consul还可以结合Consul-Template或者在代码中引入Consul Client的相关依赖创建Watcher来实时Watch K/V的变化,是配置管理的不二之选。 下图为个推微服务体系基于Consul配置管理的整体设计。其中,CCenter就是在Consul的基础上进行二次开发的配置中心。 微服务体系下配置的分类和组织形式 在实践中,不同产品线的配置会放置在Consul的不同路径下,实现不同产品线配置之间的隔离。 按照配置的用途,可将同一产品线下的配置分为三类: 1.API网关相关配置; 2.服务注册与发现相关配置; 3.应用相关配置。 其中

Consul Template

↘锁芯ラ 提交于 2019-12-13 23:56:08
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 在consul-template没出现之前,大家构建服务发现系统,大多采用的是zookeeper、etcd+confd这样类似的系统,之前写过一篇consul+confd的文,讲的是如何动态生成配置文件的,如今consul官方推出了自己的模板系统,就是consul-template,这样的话动态的配置系统可以分化为etcd+confd和consul+consul-template两大阵营。consul是一个和etcd类似但又强于etcd的系统,关于etcd和consul可以翻阅以前的文章,consul-template的定位就和confd差不多一样了,confd的后端可以是etcd或者consul,相信consul搭配consul-template能发挥更大的效果。consul-template提供了一个便捷的方式从consul中获取存储的值,consul-template守护进程会查询consul实例,来更新系统上指定的任何模板,当更新完成后,模板可以选择运行一些任意的命令。 consul template的使用场景:consul template可以查询consul中的服务目录、key、key-values等。这种强大的抽象功能和查询语言模板可以使consul template特别适合动态的创建配置文件

001-Consul

白昼怎懂夜的黑 提交于 2019-12-13 23:38:45
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> Consul安装(单节点) mkdir -p /data/consul cd /data/consul wget https://releases.hashicorp.com/consul/1.6.2/consul_1.6.2_linux_amd64.zip unzip consul_1.6.2_linux_amd64.zip 复制consul:cp consul /usr/local/bin/,可以直接使用访问consul命令。 配置修改(开发者模式启用,供测试) 自定义端口 consul agent -dev -http-port 8080 指定配置文件 consul agent -dev -config-dir /etc/consul.d/ 就是指定加载置文件的目录,该目录下所有的以.json结尾配置文件加载进去,它的加载顺序是根据26个字母的顺序加进行加载配置文件的。目录必需为consul.d,文件内容都是json格式的数据。默认后面文件定义配置会覆盖前面文件定义的配置 /etc/consul.d/test.json { "ports": { "http": 8088 } } 公网可以访问 -client 0.0.0.0 consul agent -dev -http-port 8080 -client

针对alibaba的分布式事务组件使用说明

半城伤御伤魂 提交于 2019-12-13 17:05:18
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 分布式事务应用搭建 系统采用alibaba系统的springcloud,分布式事务采用seata来进行管理,需要进行以下配置操作。 下列操作,都是针对centos7以上版本 linux进行的操作 安装nacos应用服务器 下载对应版本的nacos安装包,目前采用的是1.1.3 下载地址: https://github.com/seata/seata/releases 下载对应操作系统版本 nacos-server-1.1.3.tar.gz 将文件进行解压: Tar –zxvf nacos-server-1.1.3.tar.gz 注意:必须在安装jdk1.8以上版本上进行运行此应用 启动nacos命令 打开bin目录执行以下命令 ./startup.sh –m standalone(单机模式运行) 需要将8848端口进行开放 firewall-cmd --zone=public --add-port=8848/tcp --permanent firewall-cmd --reload 安装jdk 下载对应的jdk安装文件,目前采用的版本是1.8.0_232 下载地址: https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads

Consul https support for spring boot application

狂风中的少年 提交于 2019-12-13 08:07:52
问题 I have a spring boot application that runs on https. Consul is unable to do the health check due to the application is https. When i change it to http, it works. Any solution for this? thanks 回答1: Check out below Spring boot configuration. Notice the scheme property Secondly add your SSL certificate under trusted root certificates 来源: https://stackoverflow.com/questions/42335690/consul-https-support-for-spring-boot-application

Docker swarm: How to manually set node names?

自古美人都是妖i 提交于 2019-12-12 15:23:31
问题 For some background on my environment: I have docker swarm running on 3 ubuntu 14.04 vagrant boxes. The swarm master is running on 1 machine (with consul) and the other 2 machines are running swarm workers that are joined to the master. I set up the environment following the documentation page https://docs.docker.com/swarm/install-manual/. It is working correctly so that any docker -H :4000 <some_docker_command> run from my master machine works fine. Service discovery is active as I am

Achieve Fault Tolerance with Consul Cluster

坚强是说给别人听的谎言 提交于 2019-12-12 15:17:15
问题 I have created consul server cluster using different ports in localhost. I used below commands for that. server 1: consul agent -server -bootstrap-expect=3 -data-dir=consul-data -ui -bind=127.0.0.1 -dns-port=8601 -http-port=8501 -serf-lan-port=8303 -serf-wan-port=8304 -server-port=8305 -node=node1 server 2: consul agent -server -bootstrap-expect=3 -data-dir=consul-data2 -ui -bind=127.0.0.1 -dns-port=8602 -http-port=8502 -serf-lan-port=8306 -serf-wan-port=8307 -server-port=8308 -node=node2