快速创建 consul 集群

操作环境

  • 三台AlpineLinux主机
  • 主机名分别为host-11/12/13
  • IP地址分别为192.168.0.11/12/13

自动执行脚本

#!/bin/sh
#

###############################################################
# consul-1/2/3

apk add consul
rc-update add consul boot

cat <<EOF >/etc/consul/server.json
{
  "datacenter": "test",
  "data_dir": "/var/consul",
  "server": true,
  "bootstrap_expect": 3,
  "bind_addr": "{{ GetInterfaceIP \"eth0\" }}",
  "client_addr": "0.0.0.0",
  "retry_join": [
    "192.168.0.11",
    "192.168.0.12",
    "192.168.0.13"
  ],
  "ui_config": {
    "enabled": true
  }
}
EOF

rc-service consul start

###############################################################
# consul-cli

consul members

consul operator raft list-peers
文章作者: 若海; 原文链接: https://www.rehiy.com/post/280/; 转载需声明来自技术写真 - 若海

评论已关闭