1.consul的下载
mkdir -p /root/consul/data && cd /root/consul
wget https://releases.hashicorp.com/consul/1.18.0/consul_1.18.0_linux_amd64.zip
unzip consul_1.18.0_linux_amd64.zip
mv consul /usr/local/bin/
2.配置文件
// 配置文件路径: /root/consul/consul_service.json
{
"server": true,
"ui":true,
"datacenter": "dc1",
"data_dir": "/root/consul/data",
"node_name": "192.168.56.102",
"bootstrap_expect":1,
"client_addr": "0.0.0.0",
"bind_addr": "192.168.56.102"
}
- data_dir:数据存储地址
- ui:开启ui页面
3.开机自启动配置
文件路径:/usr/lib/systemd/system/consul.service
[Unit]
Description=consul server
After=network.target
[Service]
Type=simple
User=root
ExecStart=/usr/local/bin/consul agent -config-dir=/root/consul/consul_service.json
Restart=on-failure
[Install]
WantedBy=multi-user.target
4.consul启动
systemctl start consul # 启动
systemctl status consul # 查看状态
systemctl enable consul # 开机自启动
5.访问地址及效果
访问地址:192.168.56.102:8500
效果如下: