EDB failover manager, popularly known as EFM is a component of EDB postgres platform, is used for handling switchover and failover (including auto failover) in postgres cluster having streaming replication.
EFM cluster consists of below
1. One active primary server ( also master node), where transactions are happening
2. One or more standby database, which are synced with primary through streaming replication.
3. Witness server helps efm cluster in decision making , during master or standby failover scenario.
However if you have more than one standby node, then witness server is not required.
NOTE – > The default name of efm cluster is efm
MORE INFORMATION ABOUT EFM ON EDB WEBSITE:
PRE-REQUISITES:
- Streaming replication is already running fine between primary and standby server (Find steps here)
- Witness server has connectivity with both primary and standby server.
ENVIRONMENT DETAILS:
MASTER DB SERVER( MASTER) | 10.20.30.40 |
STANDBY DB SERVER (SLAVE) | 10.20.30.41 |
WITNESS SERVER | 10.20.30.42 |
1. Update pg_hba.conf file on both primary and standby server
Add host entries for primary and standby server in pg_hba.conf file of both servers and reload the config.
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 ident
host all all 10.20.30.40/32 md5
host all all 10.20.30.41/32 md5
host all all 10.20.30.42/32 md5
postgres=# select pg_reload_conf();
pg_reload_conf
----------------
t
(1 row)
2. Installing and configuring EFM on primary node:
1. Install efm package:
yum install edb-efm39
2. Encrypt db user password:
here we are using the db user enterprisedb for efm configuration.Make sure this user is a super user.
[enterprisedb@SCPrLBTB76 bin]$ /usr/edb/efm-3.9/bin/efm encrypt efm
This utility will generate an encrypted password for you to place in your
EFM cluster property file: /etc/edb/efm-3.9/efm.properties
Please enter the password and hit enter: --- Here put password of enterprisedb user
Please enter the password again to confirm:
The encrypted password is: 923dfba06cc8258dfd9c01de499e27ed
Please paste this into your efm.properties file
db.password.encrypted=923dfba06cc8258dfd9c01de499e27ed
efm.properties file:
3. Copy and provide permission to property files:
root# cd /etc/edb/efm-3.9
root# cp efm.properties.in efm.properties
root# cp efm.nodes.in efm.nodes
root# chmod 666 efm.properties
root# chmod 666 efm.nodes
4. Update the efm.properties file:
db.user=enterprisedb
db.password.encrypted=923dfba06cc8258dfd9c01de499e27ed
db.port=5432
db.database=edb
db.service.owner=enterprisedb
db.bin=/usr/edb/as11/bin
db.data.dir=/pgdata/edbdata
db.config.dir=/pgdata/edbdata
user.email=edb@dbaclass.com
bind.address=10.20.30.40:7800
admin.port=8001
is.witness=false
ping.server.ip=10.20.30.50 -- > all the nodes should be able to ping this server.
efm.loglevel=TRACE
NOTE – > ping.server.ip can be any ip , which has connectivity to all ips. If you have connectivity to internet, then leave it to default value.
For more information on properties file
5. start efm service:
systemctl start edb-efm-3.9
6. Add standby and witness node ip in allow-node list:
/usr/edb/efm-3.9/bin/efm allow-node efm 10.20.30.41
/usr/edb/efm-3.9/bin/efm allow-node efm 10.20.30.42
7. Check efm status:
[root@dbhost40 efm-3.9]# /usr/edb/efm-3.9/bin/efm cluster-status efm
Cluster Status: efm
Agent Type Address Agent DB VIP
-----------------------------------------------------------------------
Master 10.20.30.40 UP UP
Allowed node host list:
10.20.30.40
Membership coordinator: 10.20.30.40
Standby priority host list:
(List is empty.)
Promote Status:
DB Type Address WAL Received LSN WAL Replayed LSN Info
---------------------------------------------------------------------------
Master 10.20.30.40 0/F001AB8
No standby databases were found.
3. Installing and configuring EFM on standby node:
1. Install efm package:
yum install edb-efm39
2. Copy and provide permission to property files:
root# cd /etc/edb/efm-3.9
root# cp efm.properties.in efm.properties
root# cp efm.nodes.in efm.nodes
root# chmod 666 efm.properties
root# chmod 666 efm.nodes
3. Update the efm.properties file:
Either you can update the efm.properties file directly , or copy the file from master node.
The only change needed is the bind.address. rest are same as master node.
db.user=enterprisedb
db.password.encrypted=923dfba06cc8258dfd9c01de499e27ed
db.port=5432
db.database=edb
db.service.owner=enterprisedb
db.bin=/usr/edb/as11/bin
db.data.dir=/pgdata/edbdata
db.config.dir=/pgdata/edbdata
user.email=edb@dbaclass.com
bind.address=10.20.30.41:7800
admin.port=8001
is.witness=false
ping.server.ip=10.20.30.50
efm.loglevel=TRACE
4. Update the efm.nodes file :
Add the primary node ip and witness node ip:
[root@dbhost41 efm-3.9]# cat efm.nodes
# List of node address:port combinations separated by whitespace.
# The list should include at least the membership coordinator's address.
10.20.30.40:7800 10.20.30.42:7800
5. Start efm service:
systemctl start edb-efm-3.9
6. Check the cluster status:
[root@dbhost41 ~]$ /usr/edb/efm-3.9/bin/efm cluster-status efm
Cluster Status: efm
Agent Type Address Agent DB VIP
-----------------------------------------------------------------------
Master 10.20.30.40 UP UP
Standby 10.20.30.41 UP UP
Allowed node host list:
10.20.30.40 10.20.30.41
Membership coordinator: 10.20.30.40
Standby priority host list:
10.20.30.41
Promote Status:
DB Type Address WAL Received LSN WAL Replayed LSN Info
---------------------------------------------------------------------------
Master 10.20.30.40 0/F001AB8
Standby 10.20.30.41 0/F000000. 0/F001AB8
Standby database(s) in sync with master. It is safe to promote.
4. Installing and configuring EFM on witness node:
1. Install efm package:
yum install edb-efm39
2. Copy and provide permission to property files.
root# cd /etc/edb/efm-3.9
root# cp efm.properties.in efm.properties
root# cp efm.nodes.in efm.nodes
root# chmod 666 efm.properties
root# chmod 666 efm.nodes
3. Update efm.properties file:
Either you can update the efm.properties file directly , or copy the file from master node.
The only change needed is the bind.address and is.witness =true. Rest are same as master node.
db.user=enterprisedb
db.password.encrypted=923dfba06cc8258dfd9c01de499e27ed
db.port=5432
db.database=edb
db.service.owner=enterprisedb
db.bin=/usr/edb/as11/bin
db.data.dir=/pgdata/edbdata
db.config.dir=/pgdata/edbdata
user.email=edb@dbaclass.com
bind.address=10.20.30.42:7800
admin.port=8001
is.witness=true
ping.server.ip=10.21.172.21
efm.loglevel=TRACE
4. Add primary node and standby node ips :
[root@dbhost42 efm-3.9]# cat efm.nodes
# List of node address:port combinations separated by whitespace.
# The list should include at least the membership coordinator's address.
10.20.30.40:7800 10.20.30.41:7800
5. Start efm services:
systemctl start edb-efm-3.9
6. Check cluster status:
[root@dbhost42 ~]$ /usr/edb/efm-3.9/bin/efm cluster-status efm
Cluster Status: efm
Agent Type Address Agent DB VIP
-----------------------------------------------------------------------
Master 10.20.30.40 UP UP
Standby 10.20.30.41 UP UP
Witness 10.20.30.42 UP N/A
Allowed node host list:
10.20.30.40 10.20.30.41 10.20.30.42
Membership coordinator: 10.20.30.40
Standby priority host list:
10.20.30.41
Promote Status:
DB Type Address WAL Received LSN WAL Replayed LSN Info
---------------------------------------------------------------------------
Master 10.20.30.40 0/F001AB8
Standby 10.20.30.41 0/F000000. 0/F001AB8
Standby database(s) in sync with master. It is safe to promote.
With this our EFM setup completed . In the next article, we will explain different switchover and failover scenarios.
Is it mandatory to provide super user details while configuring? Or a normal user can be created and provide grant access to :-
GRANT pg_read_all_settings TO user_name
and provide access to below functions
pg_current_wal_lsn(), pg_last_wal_replay_lsn(), pg_wal_replay_resume(), pg_wal_replay_pause() would work?
Super user i.e enterprisedb user need to be provided inside property file.
Hi
I’m having this trouble
when I check the cluster status in the standby node is also set as “primary” not as “stand by”
do you have any idea of what this happens?
thanks a lot for your article … was very useful to me