首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >Consul 基础3

Consul 基础3

作者头像
franket
发布2021-12-01 17:06:48
发布2021-12-01 17:06:48
29000
代码可运行
举报
文章被收录于专栏:技术杂记技术杂记
运行总次数:0
代码可运行

运行Consul代理

Consul 是典型的C/S架构,可以运行在 服务模式客户模式

每一个数据中心必须有至少一个服务节点,3到5个服务节点最好,非常不建议只运行一个服务节点,因为在节点失效的情况下数据有极大的丢失风险

其它的所有节点都运行在客户端模式下,一个客户节点是非常轻量的注册服务进程,用来处理健康检查,转发请求到服务节点等事务,代理必须在集群中的每个节点上运行

以开发模式运行 Consul,这个模式可以快速启动一个单节点集群,但是由于并不保存状态,所以不要在生产环境中使用

代码语言:javascript
代码运行次数:0
运行
复制
[root@h104 consul]# consul agent -dev -bind=0.0.0.0
==> Starting Consul agent...
==> Error starting agent: Failed to get advertise address: Multiple private IPs found. Please configure one.
[root@h104 consul]# consul agent -dev -bind=192.168.100.104
==> Starting Consul agent...
==> Starting Consul agent RPC...
==> Consul agent running!
         Node name: 'h104'
        Datacenter: 'dc1'
            Server: true (bootstrap: false)
       Client Addr: 127.0.0.1 (HTTP: 8500, HTTPS: -1, DNS: 8600, RPC: 8400)
      Cluster Addr: 192.168.100.104 (LAN: 8301, WAN: 8302)
    Gossip encrypt: false, RPC-TLS: false, TLS-Incoming: false
             Atlas: <disabled>

==> Log data will now stream in as it occurs:

    2016/03/18 16:18:56 [INFO] serf: EventMemberJoin: h104 192.168.100.104
    2016/03/18 16:18:56 [INFO] serf: EventMemberJoin: h104.dc1 192.168.100.104
    2016/03/18 16:18:56 [INFO] raft: Node at 192.168.100.104:8300 [Follower] entering Follower state
    2016/03/18 16:18:56 [INFO] consul: adding LAN server h104 (Addr: 192.168.100.104:8300) (DC: dc1)
    2016/03/18 16:18:56 [INFO] consul: adding WAN server h104.dc1 (Addr: 192.168.100.104:8300) (DC: dc1)
    2016/03/18 16:18:56 [ERR] agent: failed to sync remote state: No cluster leader
    2016/03/18 16:18:57 [WARN] raft: Heartbeat timeout reached, starting election
    2016/03/18 16:18:57 [INFO] raft: Node at 192.168.100.104:8300 [Candidate] entering Candidate state
    2016/03/18 16:18:57 [DEBUG] raft: Votes needed: 1
    2016/03/18 16:18:57 [DEBUG] raft: Vote granted from 192.168.100.104:8300. Tally: 1
    2016/03/18 16:18:57 [INFO] raft: Election won. Tally: 1
    2016/03/18 16:18:57 [INFO] raft: Node at 192.168.100.104:8300 [Leader] entering Leader state
    2016/03/18 16:18:57 [INFO] raft: Disabling EnableSingleNode (bootstrap)
    2016/03/18 16:18:57 [INFO] consul: cluster leadership acquired
    2016/03/18 16:18:57 [DEBUG] raft: Node 192.168.100.104:8300 updated peer set (2): [192.168.100.104:8300]
    2016/03/18 16:18:57 [DEBUG] consul: reset tombstone GC to index 2
    2016/03/18 16:18:57 [INFO] consul: member 'h104' joined, marking health alive
    2016/03/18 16:18:57 [INFO] consul: New leader elected: h104
    2016/03/18 16:18:59 [INFO] agent: Synced service 'consul'
    2016/03/18 16:20:48 [DEBUG] agent: Service 'consul' in sync
    2016/03/18 16:21:53 [DEBUG] agent: Service 'consul' in sync
    2016/03/18 16:23:02 [INFO] agent.rpc: Accepted client: 127.0.0.1:41645
    2016/03/18 16:23:32 [DEBUG] agent: Service 'consul' in sync
...
...
...

本文系转载,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文系转载前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 运行Consul代理
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档