Not able to login to remote server through failover script.

From: Vivekanand Joshi <Vivekanand(dot)Joshi(at)nationstarmail(dot)com>
To: "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
Subject: Not able to login to remote server through failover script.
Date: 2016-12-25 06:43:31
Message-ID: MWHPR08MB29755D420BBBDB262913E17EE1970@MWHPR08MB2975.namprd08.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

I am trying to setup HA solution for PostgreSQL. For that, I am running pgpool service.

In that service, it calls a script whenever my primary node fails by calling it like this:

/etc/pgpool-II-94/failover.sh %d %H'

where %d is my node id and %H is the hostname for the new server. Think of them simply as two parameters.

My Failover script is below:

#!/bin/sh
failed_node=$1
new_master=$2
(
date
echo "Failed node: $failed_node"
set -x
/usr/bin/ssh -T -l postgres $new_master "/usr/pgsql-9.4/bin/repmgr -f /var/lib/pgsql/repmgr/repmgr.conf standby promote 2>/dev/null 1>/dev/null <&-"
exit 0;
) 2>&1 | tee -a /tmp/pgpool_failover.log

The problem I am facing here is that when this script gets executed, it gets executed as root and hence I cannot authenticate it for postgres user for other server.

How to run my pgpool service as postgres user itself so that my authentication get passed?

Right now I am using:

systemctl start pgpool-II-94

from postgres to postgres in all the servers I have setup passwordless ssh so that would not be an issue.

For example: when I run through postgres user

-bash-4.2$ /usr/bin/ssh -T -l postgres lbdevsecondary 'echo $HOSTNAME'
lbdevsecondary
But when I run through root user, it asks for password

/usr/bin/ssh -T -l postgres lbdevsecondary 'echo $HOSTNAME'
postgres(at)lbdevsecondary's password:
lbdevsecondary

Or please tell me a way to rewrite the above statement in the way that I first logged in as postgres user and then run the commands from my scripts.

I am using CentOS 7 and fairly new to Linux.

Thanks,
Vivek

Browse pgsql-admin by date

  From Date Subject
Next Message Luis Marin 2016-12-26 19:02:47 Re: Error Encrypting data folder
Previous Message Juan Albarran 2016-12-23 22:02:29 Error Encrypting data folder