一、下载解压包
1
2
3
4
5
| wget https://releases.hashicorp.com/consul/1.11.4/consul_1.11.4_linux_amd64.zip
mkdir -p /data/consul/{conf,data,logs,bin}
unzip consul_1.11.4_linux_amd64.zip -d /data/consul/bin/
|
命令自动补全
1
2
| consul -autocomplete-install
complete -C /usr/local/bin/consul consul
|
二、安装
2.1 创建配置文件
vim /data/consul/conf/consul.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| {
"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
}
}
|
2.2 创建启动脚本
vim /usr/lib/systemd/system/consul.service
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| [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
|
2.3 启动脚本
1
2
| systemctl daemon-reload
systemctl start consul
|