1、下载consul
官网上下载consul,下载地址是https://www.consul.io/downloads.html,根据不同操作系统选中不同的版本。
2、解压
List-1
xx@xx-ubuntu:/opt/software/tool$ ll
total 130916
-rwxr-xr-x 1 mjduan mjduan 99396904 11月 15 06:42 consul*
-rw-rw-r-- 1 mjduan mjduan 34591598 12月 16 19:47 consul_1.4.0_linux_amd64.zip
3、执行启动命令
List-2
xx@xx-ubuntu:/opt/software/tool$ ./consul agent -dev
==> Starting Consul agent...
==> Consul agent running!
Version: 'v1.4.0'
Node ID: '47a39e6c-656a-0198-c9ab-5e036ec416b7'
Node name: 'xx-ubuntu'
Datacenter: 'dc1' (Segment: '<all>')
Server: true (Bootstrap: false)
Client Addr: [127.0.0.1] (HTTP: 8500, HTTPS: -1, gRPC: 8502, DNS: 8600)
Cluster Addr: 127.0.0.1 (LAN: 8301, WAN: 8302)
Encrypt: Gossip: false, TLS-Outgoing: false, TLS-Incoming: false
==> Log data will now stream in as it occurs:
4、查看节点信息
List-3
xx@xx-ubuntu:/opt/software/tool$ ./consul members
Node Address Status Type Build Protocol DC Segment
xx-ubuntu 127.0.0.1:8301 alive server 1.4.0 2 dc1 <all>
5、浏览器中查看
在浏览器中输入http://localhost:8500
图5.1 consul管理界面
注意,关闭服务时,直接ctrl+c即可。
注意,上面描述并非集群模式,只适合在开发环境中使用。
consul与euraka类似,也用于服务注册与发现,很可惜netflex不再维护euraka了。
Reference:
- https://www.cnblogs.com/java-zhao/p/5356744.html