mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
add a haproxy router for a single connection point
This commit is contained in:
@@ -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
@@ -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
|
||||
Executable
+16
@@ -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
|
||||
Reference in New Issue
Block a user