Installing and Upgrading Spock
The pgedge repository provides Spock 5.0.13, the latest stable release of
Spock, for Postgres 16, 17, and 18, and the Postgres 19 release candidate.
Spock 6.0.0 is available as a beta release; the steps on this page install
Spock 5.0 and upgrade a cluster between Spock 5.0 releases. For Spock 6, see
the Spock 6 documentation.
Spock 5.0.13 runs on:
- RHEL 9 / 10
- AlmaLinux
- Rocky Linux
- Oracle Enterprise Linux (OEL)
Installing Spock
The pgedge-enterprise-all_18 and pgedge-enterprise-postgres_18
packages include Spock; if you have installed either package, Spock is
already on the host. To install Spock on its own for Postgres 18, use the
command:
sudo dnf install -y pgedge-spock50_18
To enable Spock, add the following parameters to the end of the
/var/lib/pgsql/18/data/postgresql.conf file:
wal_level = logical
max_worker_processes = 10
max_replication_slots = 10
max_wal_senders = 10
shared_preload_libraries = 'spock'
track_commit_timestamp = on
If your server has the output_plugin_libraries parameter, also add
spock_output to that parameter:
output_plugin_libraries = 'pgoutput, test_decoding, spock_output'
Restart Postgres, and then create the extension in the database that Spock will replicate:
sudo systemctl restart postgresql-18
sudo -u postgres psql -d database_name -c "CREATE EXTENSION spock;"
To create nodes and subscriptions and build a cluster, see the Spock documentation.
Upgrading Spock
Before performing an upgrade to a newer version of Spock, ensure you have a current backup of your system.
-
Before starting to upgrade individual nodes, disable Auto-DDL on all of the nodes in your cluster:
After stopping automatic DDL replication on all of the nodes in your cluster, update the Spock extension on each node.ALTER SYSTEM SET spock.enable_ddl_replication = off; ALTER SYSTEM SET spock.include_ddl_repset = off; ALTER SYSTEM SET spock.allow_ddl_from_functions = off; SELECT pg_reload_conf(); -
Stop the Postgres Server:
sudo systemctl stop postgresql-<xx>or
pg_ctl -D /path/to/data stop -m fast -
Upgrade the Spock package using your package manager:
sudo dnf upgrade pgedge-spock50_<xx>For example, to upgrade to the latest version supported on Postgres 18, use the command:
sudo dnf upgrade pgedge-spock50_18 -
Start the Postgres server:
pg_ctl -D /path/to/data startor:
systemctl start postgresql-18 -
Connect with psql and upgrade the version of the Spock Extension registered with Postgres:
SELECT extname, extversion FROM pg_extension WHERE extname = 'spock';If the command does not return the latest Spock extension version, run the following commands:
ALTER EXTENSION spock UPDATE;SELECT extname, extversion FROM pg_extension WHERE extname = 'spock'; -
Use psql to verify the node's replication status:
SELECT sub_name, sub_enabled FROM spock.subscription; SELECT slot_name, active FROM pg_replication_slots; SELECT * FROM spock.node;When you've upgraded the Spock extension on all of the nodes in your cluster, enable Auto-DDL (as needed):
ALTER SYSTEM SET spock.enable_ddl_replication = on; ALTER SYSTEM SET spock.include_ddl_repset = on; ALTER SYSTEM SET spock.allow_ddl_from_functions = on; SELECT pg_reload_conf();