Sometimes backup or restore fails due to a missing entry in the pg_hba.conf of the segments. However, navigating to each segment host and updating every pg_hba.conf file involves a lot of manual labor.
This document provides a simple method (using Unix commands) that can be used to update all the pg_hba.conf files of the segments that are part of the cluster.
The script below can be used to add the entry in the pg_hba.conf file of all the segments.
Note- Please make sure all the commands below are on one line after you are in the gpssh prompt since gpssh doesn't take multiple line commands.
GPDV version 4 and 5:
gpssh -f ~/gpconfigs/hostfile
ps -ef | grep postgres | grep silent | grep -v grep | awk '{print $10}' | while read line ; do cp $line"/pg_hba.conf" $line"/pg_hba.conf.bk."$(date +"%m-%d-%Y-%H:%M:%S") ; done
ps -ef | grep postgres | grep silent | grep -v grep | awk '{print $10}' | while read line ; do echo "host all gpadmin 172.28.12.250/32 trust" >> $line"/pg_hba.conf" ;done
ps -ef | grep postgres | grep silent | grep -v grep | awk '{print $10}' | while read line ; do tail -1 $line/pg_hba.conf ;done
gpssh -f ~/gpconfigs/hostfile
ps -ef | grep postgres | grep green | grep -v grep | awk '{print $10}' | while read line ; do cp $line"/pg_hba.conf" $line"/pg_hba.conf.bk."$(date +"%m-%d-%Y-%H:%M:%S") ; done
ps -ef | grep postgres | grep green | grep -v grep | awk '{print $10}' | while read line ; do echo "host all gpadmin 172.28.12.250/32 trust" >> $line"/pg_hba.conf" ;done
ps -ef | grep postgres | grep green | grep -v grep | awk '{print $10}' | while read line ; do tail -1 $line/pg_hba.conf ;done
Pivotal Greenplum Database (GPDB) all versions