mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-26 08:36:30 +00:00
Add instructions for upgrading from repmgr2 to repmgr3
This commit is contained in:
12
README.md
12
README.md
@@ -28,6 +28,18 @@ New features in `repmgr 3` include:
|
|||||||
* replication slot support (PostgreSQL 9.4 and later)
|
* replication slot support (PostgreSQL 9.4 and later)
|
||||||
* usability improvements, including better logging and error reporting
|
* usability improvements, including better logging and error reporting
|
||||||
|
|
||||||
|
Upgrading from repmgr 2
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
`repmgr 3` is largely compatible with `repmgr 2`; the only step required
|
||||||
|
to upgrade is to update the `repl_nodes` table to the definition needed
|
||||||
|
by `repmgr 3`. See the file `sql/repmgr2_repmgr3.sql` for details on how
|
||||||
|
to do this.
|
||||||
|
|
||||||
|
`repmgrd` must *not* be running while `repl_nodes` is being updated.
|
||||||
|
|
||||||
|
Existing `repmgr.conf` files can be retained as-is.
|
||||||
|
|
||||||
Conceptual Overview
|
Conceptual Overview
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
|
|||||||
76
sql/repmgr2_repmgr3.sql
Normal file
76
sql/repmgr2_repmgr3.sql
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
/*
|
||||||
|
* Update a repmgr 2.x installation to repmgr 3.0
|
||||||
|
* ----------------------------------------------
|
||||||
|
*
|
||||||
|
* 1. Stop any running repmgrd instances
|
||||||
|
* 2. On the master node, execute the SQL statements listed below,
|
||||||
|
* taking care to identify the master node and any inactive
|
||||||
|
* nodes
|
||||||
|
* 3. Restart repmgrd (being sure to use repmgr 3.0)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the search path to the name of the schema used by
|
||||||
|
* your rempgr installation
|
||||||
|
* (this should be "repmgr_" + the cluster name defined in
|
||||||
|
* 'repmgr.conf')
|
||||||
|
*/
|
||||||
|
|
||||||
|
-- SET search_path TO 'name_of_repmgr_schema';
|
||||||
|
|
||||||
|
BEGIN;
|
||||||
|
|
||||||
|
ALTER TABLE repl_nodes RENAME TO repl_nodes2_0;
|
||||||
|
|
||||||
|
CREATE TABLE repl_nodes (
|
||||||
|
id INTEGER PRIMARY KEY,
|
||||||
|
type TEXT NOT NULL CHECK (type IN('master','standby','witness')),
|
||||||
|
upstream_node_id INTEGER NULL REFERENCES repl_nodes (id),
|
||||||
|
cluster TEXT NOT NULL,
|
||||||
|
name TEXT NOT NULL,
|
||||||
|
conninfo TEXT NOT NULL,
|
||||||
|
slot_name TEXT NULL,
|
||||||
|
priority INTEGER NOT NULL,
|
||||||
|
active BOOLEAN NOT NULL DEFAULT TRUE
|
||||||
|
);
|
||||||
|
|
||||||
|
INSERT INTO repl_nodes
|
||||||
|
(id, type, cluster, name, conninfo, priority)
|
||||||
|
SELECT id,
|
||||||
|
CASE
|
||||||
|
WHEN witness IS TRUE THEN 'witness'
|
||||||
|
ELSE 'standby'
|
||||||
|
END AS type,
|
||||||
|
cluster,
|
||||||
|
name,
|
||||||
|
conninfo,
|
||||||
|
priority
|
||||||
|
FROM repl_nodes2_0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* You'll need to set the master explicitly; the following query
|
||||||
|
* should identify the master node ID but will only work if all
|
||||||
|
* standby servers are connected:
|
||||||
|
*
|
||||||
|
* SELECT id FROM repmgr_test.repl_nodes WHERE name NOT IN (SELECT application_name FROM pg_stat_replication)
|
||||||
|
*
|
||||||
|
* If in doubt, execute 'repmgr cluster show' will definitively identify
|
||||||
|
* the master.
|
||||||
|
*/
|
||||||
|
UPDATE repl_nodes SET type = 'master' WHERE id = $master_id;
|
||||||
|
|
||||||
|
/* If any nodes are known to be inactive, update them here */
|
||||||
|
|
||||||
|
-- UPDATE repl_nodes SET active = FALSE WHERE id IN (...);
|
||||||
|
|
||||||
|
/* When you're sure of your changes, commit them */
|
||||||
|
|
||||||
|
-- COMMIT;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* execute the following command when you are sure you no longer
|
||||||
|
* require the old table:
|
||||||
|
*/
|
||||||
|
|
||||||
|
-- DROP TABLE repl_nodes2_0;
|
||||||
Reference in New Issue
Block a user