33
Some checks failed
Deploy Nomad Configurations / deploy-nomad (push) Failing after 2m49s
Infrastructure CI/CD / Validate Infrastructure (push) Failing after 30s
Infrastructure CI/CD / Plan Infrastructure (push) Has been skipped
Infrastructure CI/CD / Apply Infrastructure (push) Has been skipped
Simple Test / test (push) Successful in 4s
Some checks failed
Deploy Nomad Configurations / deploy-nomad (push) Failing after 2m49s
Infrastructure CI/CD / Validate Infrastructure (push) Failing after 30s
Infrastructure CI/CD / Plan Infrastructure (push) Has been skipped
Infrastructure CI/CD / Apply Infrastructure (push) Has been skipped
Simple Test / test (push) Successful in 4s
This commit is contained in:
62
scripts/setup-consul-persistent-storage.sh
Executable file
62
scripts/setup-consul-persistent-storage.sh
Executable file
@@ -0,0 +1,62 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Consul 持久化存储配置脚本
|
||||
# 需要在每个 Nomad 节点上运行
|
||||
|
||||
set -e
|
||||
|
||||
echo "=== Consul 持久化存储配置 ==="
|
||||
|
||||
# 1. 创建数据目录
|
||||
CONSUL_DATA_DIR="/opt/consul/data"
|
||||
echo "创建 Consul 数据目录: $CONSUL_DATA_DIR"
|
||||
sudo mkdir -p $CONSUL_DATA_DIR
|
||||
sudo chown -R nomad:nomad $CONSUL_DATA_DIR
|
||||
sudo chmod 755 $CONSUL_DATA_DIR
|
||||
|
||||
# 2. 检查 Nomad 客户端配置
|
||||
NOMAD_CONFIG="/etc/nomad.d/nomad.hcl"
|
||||
echo "检查 Nomad 配置文件: $NOMAD_CONFIG"
|
||||
|
||||
# 3. 添加 host volume 配置
|
||||
if ! grep -q "consul-data" $NOMAD_CONFIG; then
|
||||
echo "添加 consul-data host volume 配置到 Nomad"
|
||||
|
||||
# 备份原配置
|
||||
sudo cp $NOMAD_CONFIG $NOMAD_CONFIG.backup.$(date +%Y%m%d_%H%M%S)
|
||||
|
||||
# 添加 host volume 配置
|
||||
sudo tee -a $NOMAD_CONFIG << 'EOF'
|
||||
|
||||
# Consul 持久化存储
|
||||
client {
|
||||
host_volume "consul-data" {
|
||||
path = "/opt/consul/data"
|
||||
read_only = false
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
echo "✅ 已添加 consul-data host volume 配置"
|
||||
else
|
||||
echo "✅ consul-data host volume 配置已存在"
|
||||
fi
|
||||
|
||||
# 4. 重启 Nomad 客户端
|
||||
echo "重启 Nomad 客户端以应用配置..."
|
||||
sudo systemctl restart nomad
|
||||
sleep 5
|
||||
|
||||
# 5. 验证配置
|
||||
echo "验证 Nomad 客户端状态..."
|
||||
sudo systemctl status nomad --no-pager -l
|
||||
|
||||
echo ""
|
||||
echo "=== 配置完成 ==="
|
||||
echo "数据目录: $CONSUL_DATA_DIR"
|
||||
echo "权限: $(ls -ld $CONSUL_DATA_DIR)"
|
||||
echo ""
|
||||
echo "下一步:"
|
||||
echo "1. 在所有节点 (ch4, ash3c, warden) 运行此脚本"
|
||||
echo "2. 停止当前 Consul job: nomad job stop consul-cluster-nomad"
|
||||
echo "3. 部署新的持久化配置: nomad job run consul-cluster-persistent.nomad"
|
||||
Reference in New Issue
Block a user