Consul简介
Consul 是一套开源的分布式服务发现和配置管理系统,由 HashiCorp 公司用 Go 语言开发。
它具有很多优点。包括: 基于 raft 协议,比较简洁; 支持健康检查, 同时支持 HTTP 和 DNS 协议 支持跨数据中心的 WAN 集群 提供图形界面 跨平台,支持 Linux、Mac、Windows
Consul环境搭建
官方下载地址下载window版,解压得到一个可执行文件。
设置环境变量,让我们直接在cmd里可直接使用consul使命。在path后面添加consul所在目录例如D:softconsul_1.1.0_windows_amd64
启动consul命
consul agent -dev -ui -node=cy
-dev开发服务器模式启动,-node结点名为cy,-ui可以用界面访问,默认能访问。
Maven依赖信息org.springframework.boot
spring-boot-starter-parent
2.0.1.RELEASE
org.springframework.cloud
spring-cloud-dependencies
Finchley.M7
pom
import
org.springframework.boot
spring-boot-starter-web
org.springframework.cloud
spring-cloud-starter-consul-discovery
spring-milestones
Spring Milestones
https://repo.spring.io/libs-milestone
false
客户端配置文件###eureka 服务端口号
server:
port: 8502
spring:
application:
name: consul-order
####consul注册中心地址
cloud:
consul:
host: localhost
port: 8500
discovery:
hostname: 192.168.18.220