Postgresql Higt AvailibilityPostgres

How to setup a Postgresql HA cluster with 2 nodes (and a witness) on 3 datacenters.
The purpose of this stuff is to show you how you can do a hight availibility Postgresql cluster avoiding split-brain.This is despite a "low-cost" solution. Your data are only present on two nodes.The witness is just running a small postgres database and pg_receivexlog binary.