Using Failover Manager for high availability v9
Note
This procedure is for setting up Failover Manager for a PEM server with a new installation, not with an existing one. The provided commands apply to the configuration on RHEL-based systems where HTTPD is used for the web server services.
Postgres Enterprise Manager (PEM) helps database administrators, system architects, and performance analysts to administer, monitor, and tune Postgres database servers.
Failover Manager is a high-availability tool from EDB that enables a Postgres primary node to failover to a standby node during a software or hardware failure on the primary.
The examples that follow use these IP addresses:
- 172.16.161.200 - PEM Primary
- 172.16.161.201 - PEM Standby 1
- 172.16.161.202 - PEM Standby 2
- 172.16.161.203 - EFM Witness Node
- 172.16.161.245 - PEM VIP (used by agents and users to connect)
The following must use the VIP address:
- The PEM agent binding of the monitored database servers
- Accessing the PEM web client
- Accessing the webserver services
Initial product installation and configuration
Install the following on the primary and one or more standbys:
- EDB Postgres Advanced Server (backend database for PEM Server)
- PEM server
- EDB Failover Manager 4.1
Refer to the installation instructions in the product documentation using these links or see the instructions on the EDB repos website. Replace
USERNAME:PASSWORD
with your username and password in the instructions to access the EDB repositories.Make sure that the database server is configured to use the scram-sha-256 authentication method, as the PEM server configuration script doesn't work with trust authentication.
You must install the
java-1.8.0-openjdk
package to install EFM.Configure the PEM server on the primary server as well as on all the standby servers with an initial configuration of type 1 (web services and database):
/usr/edb/pem/bin/configure-pem-server.sh -t 1
For more detail on configuration types see, Configuring the PEM server on Linux.
Add the following ports in the firewall on the primary and all the standby servers to allow the access:
8443
for PEM Server (https)5444
for EPAS 137800
for EFM7908
for EFM Admin
For example:
$ sudo firewall-cmd --zone=public --add-port=5444/tcp --permanent success $ sudo firewall-cmd --zone=public --add-port=8443/tcp --permanent success $ sudo firewall-cmd --zone=public --add-port=7800/tcp --permanent success $ sudo firewall-cmd --zone=public --add-port=7809/tcp --permanent success $ sudo firewall-cmd --reload success
Set up the primary node for streaming replication
Create the replication role:
$ /usr/edb/as13/bin/psql -h 172.16.161.200 -p 5444 -U enterprisedb edb -c “CREATE ROLE repl REPLICATION LOGIN PASSWORD 'password'”; CREATE ROLE
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.
Note
The configuration parameters might differ for different versions of the database server. You can email EDB Support at techsupport@enterprisedb.com for help with setting up these parameters.
Add the following entry in the host-based authentication (
/var/lib/edb/as13/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
Note
You can change the cidr range of the IP address, if needed.
Modify the host-based authentication (
/var/lib/edb/as13/data/pg_hba.conf
) file for the pem_user role to connect to all databases using the scram-sha-256 authentication method:# Allow local PEM agents and admins to connect to PEM server hostssl all +pem_user 172.16.161.201/24 scram-sha-256 hostssl pem +pem_user 127.0.0.1/32 scram-sha-256 hostssl pem +pem_agent 127.0.0.1/32 cert # Allow remote PEM agents and users to connect to PEM server hostssl pem +pem_user 0.0.0.0/0 scram-sha-256 hostssl pem +pem_agent 0.0.0.0/0 cert
Restart the EPAS 13 server.
systemctl restart edb-as-13.service
Set up the standby nodes for streaming replication
Stop the service for EPAS 13 on all the standby nodes:
$ systemctl stop edb-as-13.service
Note
This example uses the pg_basebackup utility to create the replicas of the PEM backend database server on the standby servers. When using pg_basebackup, you need to stop the existing database server and remove the existing data directories.
Remove the data directory of the database server on all the standby nodes:
$ sudo su - enterprisedb $ rm -rf /var/lib/edb/as13/data/*
Create the
.pgpass
file in the home directory of the enterprisedb user on all the standby nodes:$ sudo su - enterprisedb $ cat > ~/.pgpass << _EOF_ 172.16.161.200:5444:replication:repl:CHANGE_ME 172.16.161.201:5444:replication:repl:CHANGE_ME 172.16.161.202:5444:replication:repl:CHANGE_ME _EOF_ $ chmod 600 ~/.pgpass
Take the backup of the primary node on each of the standby nodes using pg_basebackup:
$ sudo su - enterprisedb /usr/edb/as13/bin/pg_basebackup -h 172.16.161.200 \ -D /var/lib/edb/as13/data -U repl -v -P -Fp -R -p 5444
The
backup
command creates thepostgresql.auto.conf
andstandby.signal
files on the standby nodes. Thepostgresql.auto.conf
file has the following content:sudo su - enterprisedb cat /var/lib/edb/as13/data/postgresql.auto.conf # Do not edit this file manually # It will be overwritten by the ALTER SYSTEM command. primary_conninfo = ‘user=repl passfile=