add a haproxy router for a single connection point

This commit is contained in:
Christopher Winslett
2015-03-16 15:46:27 -07:00
parent d3f96ad2ca
commit 04631800f2
3 changed files with 45 additions and 0 deletions
+8
View File
@@ -14,6 +14,14 @@ From there, you will see a high-availability cluster start up. Test
different settings in the YAML files to see how behavior changes. Kill
some of the different components to see how the system behaves.
To get a haproxy load balancing between these two hosts, run:
```
> haproxy -f haproxy.cfg
> sh haproxy_status.sh 127.0.0.1 5432 15432
> sh haproxy_status.sh 127.0.0.1 5433 15433
```
# Requirements on a Mac
Run the following on a Mac to install requirements:
+21
View File
@@ -0,0 +1,21 @@
global
maxconn 100
defaults
log global
mode tcp
retries 2
timeout client 30m
timeout connect 4s
timeout server 30m
timeout check 5s
frontend ft_postgresql
bind *:5000
default_backend bk_db
backend bk_db
option httpchk GET
server postgresql_127.0.0.1_5432 127.0.0.1:5432 maxconn 100 check port 15432
server postgresql_127.0.0.1_5433 127.0.0.1:5433 maxconn 100 check port 15433
+16
View File
@@ -0,0 +1,16 @@
#!/bin/bash
while true
do {
response=$(echo "SELECT pg_is_in_recovery();" | psql -t postgres --port $2 --host $1 2> /dev/null)
if [ "${response}" == " f" ]
then
echo "HTTP/1.1 200 OK"
echo "X-XLOG-POSITION: $(echo "SELECT pg_current_xlog_location();" | psql -t postgres 2> /dev/null | tr -d ' ' | head -n 1)"
else
echo "HTTP/1.1 503 Service unavailable"
echo "X-XLOG-POSITION: $(echo "SELECT pg_last_xlog_replay_location();" | psql -t postgres 2> /dev/null | tr -d ' ' | head -n 1)"
fi
} | nc -l $3; done