Consul单机部署

2024-08-07 12:46:03 浏览数 (1)

下载

代码语言:javascript复制
https://releases.hashicorp.com/consul/1.11.4/consul_1.11.4_linux_amd64.zip

解压

代码语言:javascript复制
mkdir -p /data/consul/{conf,data,logs,bin}
unzip consul_1.11.4_linux_amd64.zip -d /data/consul/bin/

自动补全

代码语言:javascript复制
consul -autocomplete-install
complete -C /usr/local/bin/consul consul

编辑配置文件 vim /data/consul/conf/consul.json

代码语言:javascript复制
{
       "bind_addr": "192.168.1.100",
       "bootstrap_expect": 1,
       "client_addr": "192.168.1.100",
       "data_dir": "/data/consul/data/",
       "datacenter": "dec1",
       "disable_update_check": false,  
       "enable_syslog": true,
       "log_level": "INFO",
       "server": true, 
       "syslog_facility": "local0",
       "ui": true,
       "performance": {
            "raft_multiplier": 1
      }
   }

创建启动脚本 vim /usr/lib/systemd/system/consul.service

代码语言:javascript复制
[Unit]
Description="HashiCorp Consul - A service mesh solution"
Documentation=https://www.consul.io/
Requires=network-online.target
After=network-online.target

[Service]
Type=notify
User=root
ExecStart=/data/consul/bin/consul agent -config-dir=/data/consul/conf/
ExecReload=/bin/kill --signal HUP $MAINPID
KillMode=process
KillSignal=SIGTERM
Restart=on-failure
LimitNOFILE=10240
LimitNPROC=10240

[Install]
WantedBy=multi-user.target

启动

代码语言:javascript复制
systemctl daemon-reload
systemctl start consul

0 人点赞