repmgr standby switchover repmgr standby switchover repmgr standby switchover promote a standby to primary and demote the existing primary to a standby Description Promotes a standby to primary and demotes the existing primary to a standby. This command must be run on the standby to be promoted, and requires a passwordless SSH connection to the current primary. If other standbys are connected to the demotion candidate, &repmgr; can instruct these to follow the new primary if the option --siblings-follow is specified. This requires a passwordless SSH connection between the promotion candidate (new primary) and the standbys attached to the demotion candidate (existing primary). Performing a switchover is a non-trivial operation. In particular it relies on the current primary being able to shut down cleanly and quickly. &repmgr; will attempt to check for potential issues but cannot guarantee a successful switchover. &repmgr; will refuse to perform the switchover if an exclusive backup is running on the current primary. For more details on performing a switchover, including preparation and configuration, see section . From repmgr 4.2, &repmgr; will instruct any running repmgrd instances to pause operations while the switchover is being carried out, to prevent repmgrd from unintentionally promoting a node. For more details, see . Users of &repmgr; versions prior to 4.2 should ensure that repmgrd is not running on any nodes while a switchover is being executed. Options Promote standby to primary, even if it is behind or has diverged from the original primary. The original primary will be shut down in any case, and will need to be manually reintegrated into the replication cluster. Check prerequisites but don't actually execute a switchover. Success of does not imply the switchover will complete successfully, only that the prerequisites for performing the operation are met. Ignore warnings and continue anyway. Specifically, if a problem is encountered when shutting down the current primary, using will cause &repmgr; to continue by promoting the standby to be the new primary, and if is specified, attach any other standbys to the new primary. Use pg_rewind to reintegrate the old primary if necessary (and the prerequisites for using pg_rewind are met). If using PostgreSQL 9.3 or 9.4, and the pg_rewind binary is not installed in the PostgreSQL bin directory, provide its full path. For more details see also . System username for remote SSH operations (defaults to local system user). Don't pause repmgrd while executing a switchover. This option should not be used unless you take steps by other means to ensure repmgrd is paused or not running on all nodes. Have standbys attached to the old primary follow the new primary. Configuration file settings Note that following parameters in repmgr.conf are relevant to the switchover operation: x with "repmgr standby switchover " replication_lag_critical with "repmgr standby switchover " If replication lag (in seconds) on the standby exceeds this value, the switchover will be aborted (unless the -F/--force option is provided) shutdown_check_timeout with "repmgr standby switchover " maximum number of seconds to wait for the demotion candidate (current primary) to shut down, before aborting the switchover. Note that this parameter is set on the node where repmgr standby switchover is executed (promotion candidate); setting it on the demotion candidate (former primary) will have no effect. In versions prior to &repmgr; 4.2, repmgr standby switchover would use the values defined in reconnect_attempts and reconnect_interval to determine the timeout for demotion candidate shutdown. standby_reconnect_timeout with "repmgr standby switchover " maximum number of seconds to attempt to wait for the demotion candidate (former primary) to reconnect to the promoted primary (default: 60 seconds) Note that this parameter is set on the node where repmgr standby switchover is executed (promotion candidate); setting it on the demotion candidate (former primary) will have no effect. node_rejoin_timeout with "repmgr standby switchover " maximum number of seconds to attempt to wait for the demotion candidate (former primary) to reconnect to the promoted primary (default: 60 seconds) Note that this parameter is set on the the demotion candidate (former primary); setting it on the node where repmgr standby switchover is executed will have no effect. However, this value must be less than on the promotion candidate (node where repmgr standby switchover is executed). Execution Execute with the --dry-run option to test the switchover as far as possible without actually changing the status of either node. External database connections, e.g. from an application, should not be permitted while the switchover is taking place. In particular, active transactions on the primary can potentially disrupt the shutdown process. Event notifications standby_switchover and standby_promote event notifications will be generated for the new primary, and a node_rejoin event notification for the former primary (new standby). If using an event notification script, standby_switchover will populate the placeholder parameter %p with the node ID of the former primary. Exit codes Following exit codes can be emitted by repmgr standby switchover: The switchover completed successfully. The switchover could not be executed. The switchover was executed but a problem was encountered. Typically this means the former primary could not be reattached as a standby. Check preceding log messages for more information. See also For more details see the section .