...
In this third part of the high availability series we will show you how to configure Postgresql for high availability. In Part #1 we made a simple Vidispine cluster, and in Part #2 we added HAProxy, and in the final Part #4 we will show how you can work with SolrCloud.
...
PostgreSQL HA
...
Configuration
In this part, we will make use of the PostgreSQL “stream replication” (binary replication) feature and pgpool-II to setup a HA PostgreSQL backend. “Stream replication” is a new feature since PostgreSQL 9.0, so make sure PostgreSQL 9.0 or above is used.
...
For more detailed explanation about stream replication, please refer to https://wiki.postgresql.org/wiki/Binary_Replication_Tutorial
https://www.postgresql.org/docs/9.1/static/runtime-config.html
...
Testing environment
Ubuntu 12.04 + PostgreSQL 9.1.8
...
Code Block |
---|
/var/lib/PostgreSQL/9.1/main |
...
Installation
Install PostgreSQL on server 1 and server 2 as usual, and make sure the databases are initialized and running without problems.
...
Code Block |
---|
apt-get install postgresql-contrib apt-get install pgpool2 |
...
Configuration
STREAM REPLICATION
First of all, please make sure that the user running PostgreSQL primary server is able to access standby servers using the following command without entering password:
...
Restart standby server. It will then start streaming replication.
...
Verify
Run these commands on primary and standby respectively:
...
Code Block |
---|
[primary]$ ps -aux | grep sender [standby]$ ps -aux | grep receiver |
...
Failover
Now, consider the pgpool server.
...
Code Block |
---|
#! /bin/sh # Failover command for streaming replication. # This script assumes that DB node 0 is primary, and 1 is standby. # # If standby goes down, do nothing. If primary goes down, create a # trigger file so that standby takes over primary node. # # Arguments: $1: failed node id. $2: new master hostname. $3: path to # trigger file. failed_node=$1 #new_master=$2 #trigger_file=$3 # Do nothing if standby goes down. if [ $failed_node = 1 ]; then exit 0; fi # Create the trigger file. /usr/bin/ssh -T postgres@10.185.20.2 /bin/touch /var/lib/postgresql/pg_trigger_test exit 0; |
...
Pgpooladmin (
...
optional)
There is a web tool called pgpoolAdmin that can assist with the configure files and monitor the backend servers.
...
For more information, please refer to https://pgpool.projects.pgfoundry.org/pgpoolAdmin/doc/index_en.html
Read the next the next part in the series here, and learn how to set up Vidispine with SolrCloud.:
Page Tree | ||
---|---|---|
|