...
To monitor the databases you can for example use pgwatch2
...
Setup VMs
install Postgres
Configure Logical Replication
inistiate 2 new PostgresSQL database clusters
Configure Publisher server with “wal_level=logical“
Start the instance
Create a database and the tables
Configure primary server
Code Block |
---|
# create database cluster
initdb -D /var/lib/postgresql/daselement-munich_publication |
Edit the config to set the primary database cluster to the Logical Replication mode
Code Block |
---|
# edit postgresql.conf
vi /var/lib/postgresql/daselement-munich_publication/postgresql.conf |
Code Block |
---|
# edit line for wal_level to logical
wal_level = logical |
Now start the database cluster
Code Block |
---|
# start the database cluster
pg_ctl -D /var/lib/postgresql/daselement-munich_publication start |
Configure subscriber server
Code Block |
---|
# create database cluster
initdb -D /var/lib/postgresql/daselement-munich_subscription
# start the database cluster
pg_ctl -D /var/lib/postgresql/daselement-munich_subscription start |
Configure Logical Replication
Create a publication on the Publish Server
Create a subscription on the Subscriber Server
Test the replication
...
Code Block |
---|
# create a symbolic link to initdb to access the command
sudo ln -s /usr/lib/postgresql/14/bin/initdb /usr/local/bin
# now you can run ...
initdb |
pg_ctl: command not found
The pg_ctl is located in the installation directory of Postgres.
Fix for Ubuntu:
Code Block |
---|
# create a symbolic link to initdb to access the command sudo ln -s /usr/lib/postgresql/14/bin/pg_ctl /usr/local/bin # now you can run ... pg_ctl |