Forum Discussion

Luke_Drury_7634's avatar
Luke_Drury_7634
Icon for Nimbostratus rankNimbostratus
May 29, 2012

Promoting Postgres Database member to active with irule.

Hi folks,

 

 

I am trying to setup a active standby ha config for two large postgresql database servers with LTM version 10.2.

 

 

I have already found some great info here:

 

https://devcentral.f5.com/weblogs/r...ig-ip.aspx

 

 

On how to do the health monitors, so that part is covered.

 

 

My main problem is with the postgres db promotion from master to slave.

 

I was wondering if there might be a way of writing an irule that when it saw the active node as down it would run a bash script which would ssh into the slave and promote it to master.

 

Yeah I know it sounds kinda scary but I can't find any better way of doing automated postgres HA.

 

 

I am pretty sure there is a way in postgress to query a table to determine if the db is master or slave.

 

 

Has anyone had any experience with this type of setup?

 

 

Cheers Luke
  • Luke,

     

    Just wondering if you ever had success in setting this up. I am looking to do the same thing with a two-node postgresql streaming replication.

     

     

    Thanks

     

    • mgwlw's avatar
      mgwlw
      Icon for Nimbostratus rankNimbostratus
      Hi, this is also what we are looking for... Is there a way to achieve this? Any "success story" meanwhile? br,
  • we are doing an project something like that. there will be 2 pg node one is master and one is slave. I will write an pg health monitor to select who master is and put those two into same pool with the priority group activation. we will change the nodes manually but if you do not want any manual thing, you must write a simple select script like the one used above from database then according to that script's result, you should take action.

     

  • Hi Luke, As far as determining if Postgres is a master or slave, simply running select pg_is_in_recovery(); will return true or false. if its "t" it's a slave.