Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

To monitor the databases you can for example use pgwatch2

...

Setup VMs

install Postgres

Configure Logical Replication

  1. inistiate 2 new PostgresSQL database clusters

  2. Configure Publisher server with “wal_level=logical“

  3. Start the instance

  4. 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

  1. Create a publication on the Publish Server

  2. Create a subscription on the Subscriber Server

  3. 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