DBAtlas · 数据库运维图谱

使用 Patroni 执行手动故障转移

PostgreSQLPatroni

命令

# Manual failover while the leader is unhealthy (candidate is mandatory):
patronictl -c /etc/patroni/patroni.yml failover <cluster> --candidate <member> --force
# Verify the result and the new timeline:
patronictl -c /etc/patroni/patroni.yml list <cluster>
patronictl -c /etc/patroni/patroni.yml history <cluster>

作用

无论 leader 状态如何,都会提升指定的副本;用于自动故障转移未发生或选错节点的情况。

适用场景

当 leader 不可达/不健康而自动故障转移没有启动(例如处于 pause 模式),或必须强制迁移到特定节点时。

注意

使用异步复制时,候选者尚未接收的事务会丢失(RPO > 0)。如果 leader 健康,请使用 switchover 而不是 failover。旧 leader 恢复后可能需要 pg_rewind(如果启用了 use_pg_rewind)或 reinit。

在 DBAtlas 中打开 →

相关内容