Home > Mobile >  Patroni switchover. How to choose target server in API-request?
Patroni switchover. How to choose target server in API-request?

Time:06-03

Simple question. We have Postgres cluster with 3 servers, for example:

- serverA_1
- serverA_2
- serverB. 

Server A-2 cant't be leader without manual switch. For example right now leader is serverA-1. I want't to switchover leader in serverB. What API request I should send?

curl -s http://serverA_1:8008/switchover -XPOST -d '{"leader":"serverA_1"}'

or

curl -s http://serverB:8008/switchover -XPOST -d '{"leader":"serverB"}'

Logic said me that second request, bit in our current jenkins job used first (as if we say current leader, that you are not leader now).

CodePudding user response:

Example: perform a failover to the specific node:

$ curl -s http://localhost:8009/failover -XPOST -d '{"candidate":"postgresql1"}'

Successfully failed over to "postgresql1"

Example: schedule a switchover from the leader to any other healthy replica in the cluster at a specific time:

$ curl -s http://localhost:8008/switchover -XPOST -d
'{"leader":"postgresql0","scheduled_at":"2019-09-24T12:00 00"}'

Switchover scheduled

CodePudding user response:

This one is work for switchover with patroni in maintance enable mode:

curl -s http://server_A1:8008/switchover -XPOST -d '{"leader":"server_A1", "candidate":"serverB"}'
  • Related