HA PEM using the S1 architecture with EFM and a Virtual IP v10.2
This page provides detailed instructions to install and configure a High Availability (HA) PEM deployment according to reference architecture S1.
This example uses EDB Failover Manager (EFM 5.0) for cluster management, EDB Postgres Advanced Server (EPAS 17) as the PEM backend database and Virtual IP (VIP) as the mechanism for routing traffic to the primary on RHEL like systems.
Please see High Availability Patterns for PEM Deployment to understand other options.
Witness nodes vs standby nodes
In this example we configured a primary, two standbys, and a witness node. In reality, you only need a witness node if you have only two data nodes. If you are configuring three or more data nodes (e.g. a primary and two standbys), you may omit the steps pertaining to the witness node. If you are configuring only two data nodes, include the steps pertaining to the witness node.
The examples that follow use these IP addresses:
- 172.16.161.200 - PEM Backend Primary
- 172.16.161.201 - PEM Backend Standby 1
- 172.16.161.202 - PEM Backend Standby 2
- 172.16.161.203 - EFM Backend Witness Node
- 172.16.161.211 - PEM Web Application 1
- 172.16.161.212 - PEM Web Application 2
- 172.16.161.213 - PEM Web Application 3
- 172.16.161.245 - PEM VIP (used by agents and users to connect)
Deploying the PEM backend
Initial package installation and Postgres configuration
Perform the following steps on all backend nodes unless stated otherwise.
Install the following packages:
- EDB Postgres Advanced Server (backend database for PEM Server)
- sslutils (see Prerequisites in PEM server installation)
- PEM Server
- EDB Failover Manager
dnf -qy module disable postgresql dnf -y install epel-release dnf config-manager --set-enabled crb dnf -y install edb-as17-server edb-pem edb-as17-server-sslutils edb-efm50
Initialize a Postgres database and start the service.
PGSETUP_INITDB_OPTIONS="-E UTF-8" /usr/edb/as17/bin/edb-as-17-setup initdb systemctl start edb-as-17 systemctl enable edb-as-17
Open the following ports on the firewall:
5444
for EPAS7800
for EFMFor example:
firewall-cmd --zone=public --add-port=5444/tcp --permanent firewall-cmd --zone=public --add-port=7800/tcp --permanent firewall-cmd --reload
User and access configuration on the primary
Perform the following steps on the primary.
Create a superuser that can login using a password.
su - enterprisedb -c psql edb -c 'create role pemserver login superuser password your-password-here;'
Add the following line to the the
pg_hba.conf
file to permit the new user to connect from any of the server IPs. You may adjust the size of the subnet as appropriate to you network, but it must include all the PEM backend and web application nodes.hostssl all pemserver 172.16.161.1/24 scram-sha-256
Add the following line to the the
pg_hba.conf
file to permit other PEM users to connect to the PEM backend through the web application. You may adjust the size of the subnet as appropriate to you network, but it must include all the PEM web application nodes.hostssl all +pem_user 172.16.161.1/24 scram-sha-256
Restart the Postgres server.
systemctl restart edb-as-17
Configure PEM on the primary backend node
Configure the PEM database installation on the primary backend server only:
Manually assign the VIP to the primary. For example:
/usr/edb/efm-5.0/bin/efm_address add4 eth0 172.16.161.245/32
Run the PEM configuration script, specifying the VIP as the host and option 3 (Database):
/usr/edb/pem/bin/configure-pem-server.sh -t 3 -ho 172.16.161.245
You will be prompted for various additional details. For configuration options see, Configuring the PEM server on Linux.
Optionally, to synchronize PEM web application user preferences between instances, configure central storage of user preferences. At this stage, you can only complete the backend configuration. We will configure the web application later.
Copy the configuration record to the standbys
Copy the file /usr/edb/pem/share/.install-config
from the primary to all standbys.
This ensures you will be able to upgrade PEM from whichever node is the current primary in future.
Set up the primary node for streaming replication
Create the replication role:
psql -h 172.16.161.200 -p 5444 -U enterprisedb edb -c “CREATE ROLE repl REPLICATION LOGIN PASSWORD 'password'”;
Give the password of your choice.
Configure the following in the
postgresql.conf
file:wal_level = replica max_wal_senders = 10 wal_keep_size = 500 max_replication_slots = 10
For more information on configuring parameters for streaming replication, see the PostgreSQL documentation.
Add the following entry in the host-based authentication (
/var/lib/edb/as17/data/pg_hba.conf
) file to allow the replication user to connect from all the standbys:hostssl replication repl 172.16.161.201/24 scram-sha-256
Restart the EPAS server.
systemctl restart edb-as-17.service
Set up the standby nodes for streaming replication
Use the pg_basebackup utility to create replicas of the PEM backend database server on the standby servers.
Stop the service for EPAS on all the standby nodes:
systemctl stop edb-as-17.service
Remove the data directory of the database server on all the standby nodes:
su - enterprisedb rm -rf /var/lib/edb/as17/data/*
Create the
.pgpass
file in the home directory of the enterprisedb user on all the standby nodes and add the following content. Replace<password>
with the password of the replication user created previously.172.16.161.200:5444:replication:repl:<password> 172.16.161.201:5444:replication:repl:<password> 172.16.161.202:5444:replication:repl:<password>
Set the permissions on the file to restrict access
chmod 600 ~/.pgpass
Take a backup of the primary node on each of the standby nodes using pg_basebackup:
su - enterprisedb -c "\ /usr/edb/as17/bin/pg_basebackup \ -h 172.31.6.186 \ -D /var/lib/edb/as17/data \ -U repl \ -v -P -Fp -R -p 5444\ "
Start the EPAS database server on each of the standby nodes: