Creating PGD nodes#
It’s just Postgres#
A PGD node is just a Postgres instance with the BDR extension installed. The BDR extension enables bidirectional replication between nodes and is the foundation of PGD.
That means, in the most general terms, you can create a PGD node by installing Postgres and the BDR extension, and then configuring the node to connect to the other nodes in the PGD group. But there are some specifics to consider.
Which Postgres version?#
PGD is built on top of Postgres, so the distribution and version of Postgres you use for your PGD nodes is important. The version of Postgres you use must be compatible with the version of PGD you are using. You can find the compatibility matrix in the release notes . Features and functionality in PGD may depend on the distribution of Postgres you are using. The EDB Postgres Advanced Server is the recommended distribution for PGD. PGD also supports EDB Postgres Extended Server and Community Postgres .
Installing Postgres#
You must install your selected Postgres distribution on each node you are configuring. You can find installation instructions for each distribution in the EDB Postgres Advanced Server documentation , EDB Postgres Extended Server documentation , and the Postgres installation documentation . You can also refer to the Installing the database and pgd which covers the installation of Postgres.
Installing the BDR extension#
The BDR extension is the key to PGD’s distributed architecture. You need to install the BDR extension on each node in your PGD cluster. The BDR extension is available from the EDB Postgres Distributed repository. You need to add the EDB repository to your package management system on Linux and then install the PGD package. You can find the repository configuration instructions in the Configuring PGD repositories .
Once the repository is configured, you can install the PGD package with
your package manager. The package name is
edb-pgd6-expanded-pg<postgres_distribution><version> where
<postgres_distribution> is the Postgres distribution you are using
and <version> is the version of Postgres you are using. For example,
if you are using community Postgres 14, the package name is
edb-pgd6-expanded-pg14 . For details on package naming, see
Installing the database and pgd .
Configuring the database for PGD#
This process is specific to PGD and involves configuring the Postgres instance to work with the BDR extension and adjusting various settings to work with the PGD cluster. The steps are as follows:
Add the BDR extension
$libdir/bdrat the start of theshared_preload_librariessetting inpostgresql.conf.Set the
wal_levelGUC variable tologicalinpostgresql.conf.Turn on commit timestamp tracking by setting
track_commit_timestampto'on'inpostgresql.conf.Increase the maximum worker processes to 16 or higher by setting
max_worker_processesto'16'inpostgresql.conf.
Add rules to
pg_hba.confto allow nodes to connect to each other. - Ensure that these lines are present inpg_hba.conf:
host all all all md5
host replication all all md5
Add a
.pgpassfile to allow nodes to authenticate each other.Configure a user with sufficient privileges to log in to the other nodes.
See
- The Password File in the Postgres documentation for more on the
.pgpassfile.
Once these steps are complete, restart the Postgres instance to apply the changes.
Setting up the replicated database#
Create a database within Postgres to use as PGD’s replicated database.
You can do this with the CREATE DATABASE command. The created
database should be the name of the database that other nodes in the PGD
cluster replicate. The convention is to name the database pgddb .
Log into that specific database instance you have configured and set up
the BDR extension. You can do this by running the
CREATE EXTENSION bdr; command as superuser. This command creates the
BDR extension within that database.
Next steps#
The node is now configured and ready to be join a group, or start a group, in the PGD cluster. You can find instructions for joining a node to a group in the Creating and joining PGD groups section.