consul集群部署三server一client

环境:
consul:consul_1.16.2_linux_amd64.zip centos7.9
server:192.168.50.154 192.168.50.155 192.168.50.156
client:192.168.70.64

安装目录:

[root@rabbit4-64 consul]# pwd
/app/consul
[root@rabbit4-64 consul]# ls
consul  consul_1.16.2_linux_amd64.zip  consul.json  data
[root@rabbit4-64 consul]# 

192.168.70.64 client

[root@rabbit4-64 consul]# cat consul.json 
{
    "datacenter": "ybjdc1",
    "data_dir": "/app/consul/data",
    "log_level": "INFO",
    "node_name": "",
    "server": false,
    "ui": true,
    "bootstrap_expect": 0,
    "bind_addr": "192.168.70.64",
    "client_addr": "192.168.70.64",
    "retry_join": ["192.168.50.154","192.168.50.155","192.168.50.156"],
    "retry_interval": "3s",
    "raft_protocol": 3,
    "enable_debug": false,
    "rejoin_after_leave": true,
    "enable_syslog": false
}

192.168.50.154 server

[root@first-1 consul]# cat consul.json 
{
    "datacenter": "ybjdc1",
    "data_dir": "/app/consul/data",
    "log_level": "INFO",
    "node_name": "",
    "server": true,
    "ui": true,
    "bootstrap_expect": 2,
    "bind_addr": "192.168.50.154",
    "client_addr": "192.168.50.154",
    "advertise_addr": "192.168.50.154",
    "retry_join": ["192.168.50.155","192.168.50.156"],
    "retry_interval": "3s",
    "raft_protocol": 3,
    "enable_debug": false,
    "rejoin_after_leave": true,
    "enable_syslog": false
}

192.168.50.155 server

[root@second-2 consul]# cat consul.json 
{
    "datacenter": "ybjdc1",
    "data_dir": "/app/consul/data",
    "log_level": "INFO",
    "node_name": "",
    "server": true,
    "ui": true,
    "bootstrap_expect": 2,
    "bind_addr": "192.168.50.155",
    "client_addr": "192.168.50.155",
    "advertise_addr": "192.168.50.155",
    "retry_join": ["192.168.50.154","192.168.50.156"],
    "retry_interval": "3s",
    "raft_protocol": 3,
    "enable_debug": false,
    "rejoin_after_leave": true,
    "enable_syslog": false
}

192.168.50.156 server

[root@three-3 consul]# cat consul.json 
{
    "datacenter": "ybjdc1",
    "data_dir": "/app/consul/data",
    "log_level": "INFO",
    "node_name": "",
    "server": true,
    "ui": true,
    "bootstrap_expect": 2,
    "bind_addr": "192.168.50.156",
    "client_addr": "192.168.50.156",
    "advertise_addr": "192.168.50.156",
    "retry_join": ["192.168.50.154","192.168.50.155"],
    "retry_interval": "3s",
    "raft_protocol": 3,
    "enable_debug": false,
    "rejoin_after_leave": true,
    "enable_syslog": false
}

做成服务:

[root@rabbit4-64 consul]# cat /etc/systemd/system/consul.service 
[Unit]
Description=Consul agent server
Documentation=https://www.consul.io/
Requires=network-online.target
After=network-online.target
[Service]
EnvironmentFile=-/etc/sysconfig/consul
Environment=GOMAXPROCS=4
Restart=on-failure
#User=consul
LimitNOFILE=65536
ExecStart=/app/consul/consul agent -config-file /app/consul/consul.json
ExecReload=/bin/kill -HUP $MAINPID
KillSignal=SIGINT
[Install]
WantedBy=multi-user.target

访问测试:http://192.168.50.154:8500/ui/ybjdc1/services/consul/instances
在这里插入图片描述

启动注意点:
可以先使用/app/consul/consul agent -config-file /app/consul/consul.json命令启动,会出现以下错误,但是当全部启动后,就没有出现connect: connection refused的情况了

2024-03-26T11:26:03.758+0800 [ERROR] agent.server.raft: failed to appendEntries to: peer="{Voter 31e197d0-480a-018f-392c-9a81fce11f98 192.168.50.155:8300}" error=EOF
2024-03-26T11:26:03.821+0800 [ERROR] agent.server.raft: failed to appendEntries to: peer="{Voter 31e197d0-480a-018f-392c-9a81fce11f98 192.168.50.155:8300}" error="dial tcp 192.168.50.154:0->192.168.50.155:8300: connect: connection refused"
2024-03-26T11:26:03.888+0800 [ERROR] agent.server.raft: failed to appendEntries to: peer="{Voter 31e197d0-480a-018f-392c-9a81fce11f98 192.168.50.155:8300}" error="dial tcp 192.168.50.154:0->192.168.50.155:8300: connect: connection refused"

相关推荐

  1. HBase学习部署

    2024-03-29 10:36:06       56 阅读
  2. Etcd实战()-部署etcd

    2024-03-29 10:36:06       51 阅读
  3. Redis学习--部分概念

    2024-03-29 10:36:06       36 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-03-29 10:36:06       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-03-29 10:36:06       100 阅读
  3. 在Django里面运行非项目文件

    2024-03-29 10:36:06       82 阅读
  4. Python语言-面向对象

    2024-03-29 10:36:06       91 阅读

热门阅读

  1. 【AI】安装web UI时总是报找不到yaml

    2024-03-29 10:36:06       39 阅读
  2. Qlib-Server部署

    2024-03-29 10:36:06       38 阅读
  3. python解决序列重叠问题

    2024-03-29 10:36:06       34 阅读
  4. SQL查询:如何在where条件中使用子查询

    2024-03-29 10:36:06       39 阅读
  5. 【期刊介绍】ICLR

    2024-03-29 10:36:06       38 阅读
  6. 抖音美女直播听小说项目全攻略【鹏哥创业】

    2024-03-29 10:36:06       156 阅读
  7. volatile关键字的作用、原理

    2024-03-29 10:36:06       42 阅读
  8. playbook的介绍、应用与实施

    2024-03-29 10:36:06       30 阅读
  9. String 类的常用方法都有那些?

    2024-03-29 10:36:06       40 阅读
  10. Dubbo负载均衡

    2024-03-29 10:36:06       35 阅读