Spring Cloud之Consul服务注册与发现 - 07(个人笔记)

1、Consul简介

Consul是一套开源的分布式服务发现和配置管理系统,有HashiCorp公司使用Go语言开发,提供了微服务系统中服务治理、配置中心、控制总线等功能。每个功能可以单独使用,也可以一起使用以构建全方位的服务网格,Consul提供了一套完整的服务网格解决方案。

优点:基于raft协议,简洁;支持健康检查,同时支持HTTPDNS协议,支持跨数据中心的WAN集群,提供了图形化界面;支持跨平台,支持Linux、Mac、Windows。

Consul的功能:

  • 实现服务注册发现,提供了了HTTP和DNS两种发现方式
  • 健康检测,支持多种方式,Http,Tcp,Docker,Shell脚本定制
  • KV存储(key、value的存储方式)
  • 支持多数据中心
  • 可视化Web界面

下载地址:https://www.consul.io/downloads

Consul中文使用教程:https://www.springcloud.cc/spring-cloud-consul.html

2、安装并运行Consul

macOS环境下,使用homebrew方式在Mac上安装Consul。记录详细流程操作。

2-1、安装应用

使用命令$ brew install consul安装:

test-MBP:~ test$ brew install consul
Updating Homebrew…
==> Downloading https://ghcr.io/v2/homebrew/core/consul/manifests/1.9.5
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/consul/blobs/sha256:043b458e21e
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Pouring consul–1.9.5.big_sur.bottle.tar.gz
==> Caveats
To have launchd start consul now and restart at login:
brew services start consul
Or, if you don’t want/need a background service you can just run:
consul agent -dev -bind 127.0.0.1
==> Summary

上一篇:业界标杆阿里又爆新作!甩出SpringCloud进阶神技,上线一周,在Github上热度飙升!


下一篇:如何在kubernetes中使用Spring Cloud微服务