Consul 是 HashiCorp 公司推出的开源工具,用于实现分布式系统的服务发现与配置。与其他分布式服务注册与发现的方案,Consul的方案更“一站式” ,内置了服务注册与发现框架
介绍
据说使用起来也较 为简单。Consul使用Go语言编写,因此具有天然可移植性(支持Linux、windows和Mac OS X);安装包仅包含一个可执行文件,方便部署,与Docker等轻量级容器可无缝配合 。 基于 Mozilla Public License 2.0 的协议进行开源. Consul 支持健康检查,并允许 HTTP 和 DNS 协议调用 API 存储键值对. 一致性协议采用 Raft 算法,用来保证服务的高可用. 使用 GOSSIP 协议管理成员和广播消息, 并且支持 ACL 访问控制.
$ consul -v Consul v1.0.3 Protocol 2 spoken by default, understands 2 to 3 (agent will automatically use protocol >2 when speaking to compatible agents)
2018/02/03 15:37:32 [DEBUG] Using random ID "aef05660-c518-c124-f8bd-e2e8148b0fa2" as node ID 2018/02/03 15:37:32 [INFO] raft: Initial configuration (index=1): [{Suffrage:Voter ID:aef05660-c518-c124-f8bd-e2e8148b0fa2 Address:127.0.0.1:8300}] 2018/02/03 15:37:32 [INFO] raft: Node at 127.0.0.1:8300 [Follower] entering Follower state (Leader: "") 2018/02/03 15:37:32 [INFO] serf: EventMemberJoin: zhangxiaodeMacBook-Pro.local.dc1 127.0.0.1 2018/02/03 15:37:32 [INFO] serf: EventMemberJoin: zhangxiaodeMacBook-Pro.local 127.0.0.1 2018/02/03 15:37:32 [INFO] consul: Handled member-join event for server "zhangxiaodeMacBook-Pro.local.dc1" in area "wan" 2018/02/03 15:37:32 [INFO] consul: Adding LAN server zhangxiaodeMacBook-Pro.local (Addr: tcp/127.0.0.1:8300) (DC: dc1) 2018/02/03 15:37:32 [INFO] agent: Started DNS server 127.0.0.1:8600 (udp) 2018/02/03 15:37:32 [INFO] agent: Started DNS server 127.0.0.1:8600 (tcp) 2018/02/03 15:37:32 [INFO] agent: Started HTTP server on 127.0.0.1:8500 (tcp) 2018/02/03 15:37:32 [INFO] agent: started state syncer 2018/02/03 15:37:32 [WARN] raft: Heartbeat timeout from "" reached, starting election 2018/02/03 15:37:32 [INFO] raft: Node at 127.0.0.1:8300 [Candidate] entering Candidate state in term 2 2018/02/03 15:37:32 [DEBUG] raft: Votes needed: 1 2018/02/03 15:37:32 [DEBUG] raft: Vote granted from aef05660-c518-c124-f8bd-e2e8148b0fa2 in term 2. Tally: 1 2018/02/03 15:37:32 [INFO] raft: Election won. Tally: 1 2018/02/03 15:37:32 [INFO] raft: Node at 127.0.0.1:8300 [Leader] entering Leader state 2018/02/03 15:37:32 [INFO] consul: cluster leadership acquired 2018/02/03 15:37:32 [INFO] consul: New leader elected: zhangxiaodeMacBook-Pro.local 2018/02/03 15:37:32 [DEBUG] consul: Skipping self join check for "zhangxiaodeMacBook-Pro.local" since the cluster is too small 2018/02/03 15:37:32 [INFO] consul: member 'zhangxiaodeMacBook-Pro.local' joined, marking health alive 2018/02/03 15:37:33 [DEBUG] Skipping remote check "serfHealth" since it is managed automatically 2018/02/03 15:37:33 [INFO] agent: Synced node info 2018/02/03 15:37:33 [DEBUG] agent: Node info in sync 2018/02/03 15:37:33 [DEBUG] Skipping remote check "serfHealth" since it is managed automatically 2018/02/03 15:37:33 [DEBUG] agent: Node info in sync 2018/02/03 15:37:38 [DEBUG] http: Request GET /v1/event/list?wait=5s&index=1 (5.001249189s) from=127.0.0.1:54222