CentOS7 Consul 开机自启动 Systemd服务

Linux CentOS7 Consul 开机自启动 Systemd服务

一、路径/usr/lib/systemd/system/,新建一个service命名为,consul.service

[Unit]
Description=consul
After=network.target

[Service]
ExecStart=/usr/local/consul/start.sh
KillSignal=SIGTERM

[Install]
WantedBy=multi-user.target
二、编辑/usr/local/consul/start.sh,注意LF格式

#!/bin/bash
/usr/bin/consul agent -server -ui -node=192.168.211.202 -data-dir=/usr/local/consul/data/ -config-dir=/usr/local/consul/config/ -log-file=/usr/local/consul/log/consul_log-$(date +%Y-%m-%d–%H-%M)
三、执行命令

运行

systemctl start consul

开机运行

systemctl enable consul

四、如果重新加载配置文件,则直接运行consul reload即可,consul leave同理


CentOS7 Consul 开机自启动 Systemd服务
https://blog.jeecloud.cn/2020/11/25/20201125142043/
作者
pshgao
发布于
2020年11月25日
许可协议