Consul
安装部署
MacOS
bash
brew tap hashicorp/tap
brew install hashicorp/tap/consul
# 启动服务
brew services start consul
# 停止
brew services stop consul
# 重启服务
brew services restart consul
本地配置文件
shell
# 创建数据目录
mkdir -p /Users/elvea/Tools/cloud/consul/data
# 新建本地配置文件
touch /Users/elvea/Tools/cloud/consul/config.json
# 打开配置文件
open -e /Users/elvea/Tools/cloud/consul/config.json
内容如下
json
{
"datacenter": "main",
"data_dir": "/Users/elvea/Tools/cloud/consul/data",
"encrypt": "zy6X5+0XjV7LfR4mZ5kL3Q==",
"bind_addr": "127.0.0.1",
"client_addr": "0.0.0.0",
"ui": true,
"server": true,
"bootstrap_expect": 1
}
修改服务配置文件
shell
open -e /opt/homebrew/opt/consul/homebrew.mxcl.consul.plist
找到下面内容
<array>
<string>/opt/homebrew/opt/consul/bin/consul</string>
<string>agent</string>
<string>-dev</string>
<string>-bind</string>
<string>127.0.0.1</string>
</array>
替换成下面内容
<array>
<string>/opt/homebrew/opt/consul/bin/consul</string>
<string>agent</string>
<string>-config-file</string>
<string>/Users/elvea/Tools/cloud/consul/config.json</string>
</array>
RHEL
安装
shell
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
sudo yum -y install consul
系统服务
bash
# 随系统启动
sudo systemctl enable consul.service
# 启动服务
sudo systemctl start consul.service
# 重启服务
sudo systemctl restart consul.service
# 停止服务
sudo systemctl stop consul.service