Hansolos
Hansolos

Reputation: 1

Create failover postgresql cluster if you have 2 virtmachine without load balancing server

  1. Whats recommendation can you give me on setting up a database failover postgresql cluster? I have only 2 virtual machine.

Right now i read this https://wiki.clusterlabs.org/wiki/PgSQL_Replicated_Cluster

I have some questions about it:

  1. Where is it written in the configuration files when the second machine should turn on as an active one?
  2. How does the first car understand that the second car is active?
  3. Why does not the virtual IP address conflict?
  4. When the main machine turns on, how will the system understand what needs to be done replication from the second server?

Sorry for my bad English

Upvotes: 0

Views: 682

Answers (1)

user3792812
user3792812

Reputation: 155

Its almost 2 months you asked it but it seems you are in same boat as I was in few weeks back. I have gone through your link and it explains that you need to use corosync + pacemaker + pcs. Frankly, I have no experience on any of them but I used pgpool2 4.0.4 (latest at the time of writing) with PostgreSQL 9.5.14 and 10.7, successfully able to brought up 2 clusters in last 2 months.

With pgpool you do not need to use any other tool/library and all configuration goes to one file pgpool.conf along with few password (1 liners) in pool_password and pcp.conf. All the needed configuration of watchdog(component of pgpool cluster) to find out the live/dead status of cluster comes with pgpool and merely need configuration to handle it.

You may find more information on pgpool2 at here and about latest version at here. Also you may refer (just read first to get a gist of whole process) at link which is super useful and quite detailed on how the whole process goes.

Also let us know if you were able to setup cluster with mentioned technologies at your link.

Edit: you may find extracted configurations of pgpool.conf at my gist page I have kept only the settings which I changed. Rest have been left as default , or may be i forgot to add 1-2 to this. Most of the comment on the file come right from standard documentation and self-explanatory but few places I have added my own comment and they are

  1. vip configuration.
  2. At one place I am using a different postgres password.
  3. note about recovery_1st_stage
  4. note about key file referred by logdir

Also most important things is , sit back and read through original links referring to std. documentation to just a gist of what the whole thing/process is. It will be easier for you to modify it as per your needs later. I read it , 3-4 times ( slow learner ) both the documentation and then used a mix of both approaches. Also there are 4 files, i created

  1. recovery_1st_stage
  2. pgpool_remote_start.sh
  3. failover.sh
  4. promote_standby.sh

You will find guidance on these at both the places : std. documentation and other tutorial. they are plain sh file with a bunch of ssh and psql commands.

Upvotes: 2

Related Questions