Not able to login to remote server through failover script.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@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


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux