查看k8s pod部署的pg postgres集群状态是否正常
·
#!/bin/bash
# 执行 `patronictl list` 命令并统计运行的实例数量
running_count=$(kubectl exec -it postgres-database-cluster-1-0 -n postgres -- \
bash -c "export LC_ALL=en_US.UTF-8; export LANG=en_US.UTF-8; \
/database/patroni/bin/patronictl --config-file=/database/patroni/run/patroni.yml list" | grep -c running)
# 检查运行实例的数量,并输出相应的消息
if [ "$running_count" -eq 3 ]; then
echo "postgres 集群正常"
else
echo "postgres 集群异常,当前运行的实例数量为: $running_count"
fi
更多推荐
所有评论(0)