How to switch master server and warm standby (with streaming replication) in PostgreSQL?
Keep in mind that currently you cannot demote a master to a standby.  Doing so will corrupt your database!

The basic documentation for doing this is at: http://www.postgresql.org/docs/9.1/static/warm-standby-failover.html

However the basic thing is you can't switch these other than:


Turn off primary
Promote secondary
Rebuild former primary as new secondary off the new primary.