-
Notifications
You must be signed in to change notification settings - Fork 364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Could someone provide a docker-compose.yml example? #379
Comments
I'm working on it, trying a lot of setups and figuring out some docs inconsistencies. I will add some notes while that.
|
version: '3'
services:
etcd1:
image: bitnami/etcd:3.4.3
command: etcd -name etcd1
environment:
ETCD_ENABLE_V2: 'true'
ALLOW_NONE_AUTHENTICATION: 'yes'
ETCD_LISTEN_PEER_URLS: http://0.0.0.0:2380
ETCD_INITIAL_ADVERTISE_PEER_URLS: http://10.0.0.11:2380
ETCD_LISTEN_CLIENT_URLS: http://0.0.0.0:2379
ETCD_ADVERTISE_CLIENT_URLS: http://10.0.0.11:2379
ETCD_INITIAL_CLUSTER: etcd1=http://etcd1:2380,etcd2=http://etcd2:2380
ETCD_INITIAL_CLUSTER_STATE: new
ETCD_INITIAL_CLUSTER_TOKEN: pgEtcdCluster
networks:
network:
ipv4_address: 10.0.0.11
etcd2:
image: bitnami/etcd:3.4.3
command: etcd -name etcd2
environment:
ETCD_ENABLE_V2: 'true'
ALLOW_NONE_AUTHENTICATION: 'yes'
ETCD_LISTEN_PEER_URLS: http://0.0.0.0:2380
ETCD_INITIAL_ADVERTISE_PEER_URLS: http://10.0.0.12:2380
ETCD_LISTEN_CLIENT_URLS: http://0.0.0.0:2379
ETCD_ADVERTISE_CLIENT_URLS: http://10.0.0.12:2379
ETCD_INITIAL_CLUSTER: etcd1=http://etcd1:2380,etcd2=http://etcd2:2380
ETCD_INITIAL_CLUSTER_STATE: new
ETCD_INITIAL_CLUSTER_TOKEN: pgEtcdCluster
networks:
network:
ipv4_address: 10.0.0.12
postgres-node1:
image: spilo:latest
environment:
ETCD_HOSTS: etcd1:2379,etcd2:2379
PGPASSWORD_STANDBY: ${DB_PASS}
PGPASSWORD_ADMIN: ${DB_PASS}
PGPASSWORD_SUPERUSER: ${DB_PASS}
SCOPE: pgCluster
networks:
network:
ipv4_address: 10.0.0.21
volumes:
- db-data1:/home/postgres/pgdata
postgres-node2:
image: spilo:latest
environment:
ETCD_HOSTS: etcd1:2379,etcd2:2379
PGPASSWORD_STANDBY: ${DB_PASS}
PGPASSWORD_ADMIN: ${DB_PASS}
PGPASSWORD_SUPERUSER: ${DB_PASS}
SCOPE: pgCluster
networks:
network:
ipv4_address: 10.0.0.22
volumes:
- db-data2:/home/postgres/pgdata
haproxy:
image: haproxy:2.0-alpine
environment:
MAX_CONN: 10000
PG_NODE1_HOST: postgres-node1
PG_NODE2_HOST: postgres-node2
expose:
- '2345'
ports:
- '2345:2345'
- '7000:7000'
networks:
network:
volumes:
- ./conf/haproxy:/usr/local/etc/haproxy:ro
networks:
network:
ipam:
config:
- subnet: 10.0.0.1/24
volumes:
db-data1:
db-data2: I came up with something like this, any comments about will be appreciated. |
@mths0x5f I do not work at zalando but I'm using this image with docker swarm. First of all this image already contains etcd so you do not need a separate one.
and for the run1: (needs to be marked as executable)
run2:
run3:
|
Thank you! I hardly would've known this. P.S.: From your example, setting PATRONI_POSTGRESQL_LISTEN is necessary? |
If I remember correctly I was unable to connect with pgadmin without the PATRONI_POSTGRESQL_LISTEN option, but it was quite some time ago... |
Thank you both for sharing this info! @mths0x5f Did you manage to successfully run your cluster and what stack do you use in the end ? Can you share it please ? @sonix07 What image do you use (spiloimage:notlatest) ? Did you build it yourself ? Any directions how to build it or where to get it ? Thanks in advance! |
@sonix07 Ah I think I got it, you mean Spilo already contains etcd. |
@xirius @sonix07 @mths0x5f @CyberDem0n @feikesteenbergen
I am new to the cluster and postgres thing. Any help will be appreciated from anyone. |
@pravnkr no I did not edit the docker file. I build the image myself and it is running in production. You can run multiple processes in a container if you want, using
If you need to have an application transparent failover process you will need to run haproxy in front of your spilo cluster. This is an example haproxy.cfg that works with a 5 node spilo setup.
Just one word of advice that would have saved me a lot of time, etcd is very sensitive to spikes in latency (this can cause a new master being elected). |
Thanks @sonix07 for the prompt response. am i correct ?
@sonix07 wrote: just help me with these last questions if you can..That will be a great help for me. |
@pravnkr with this spilo the etcd service is started automatically so you will run 1 etcd per DB node anyway, maybe this can be turned off but I have not looked into it.
|
@sonix07 Hi, I updated my HAProxy to 2.2 and now it reports that |
@xirius haven't looked into it at all. maybe the changelog of haproxy could give some hint? |
@sonix07 I looked at the logs but it doesn't give me any clue unfortunately:
There is an announcement about HAProxy 2.2 release where they say there are some changes to the health checks but I cannot figure out what has to be changed. |
@sonix07 something I don't get yet: how do you connect your application to the postgres DB in the cluster? What is the public facing name and how do you configure that? |
you connect to HAProxy on port 5000 (makes sure you always connect to the manager node with read and write access to the DB) |
So haproxy is the single point of failure in your example, right? Or is that configured in HA? |
of course you would run more than one instance of HAProxy to avoid it being a SPOF... but you could also talk to patroni directly via rest (port 8008 in my example) and have the logic for failover built in to your application. |
@sonix07
/home/tstest/run3 , /home/tstest/spilo3/pgdata, /home/tstest/etcd3. Can you explain this? These resides in the host directory right? Am I suppose to create a volume in docker and include the run3 file here? What do /spilo3/pgdata and /etcd3 contains? |
Hi, Is there a complete docker stack example including HAProxy with auto failover/-failback somewhere on github available? |
I know this is a completely newbie question, but I'm using Docker Swarm to deploy things and I can't "speak" Kubernetes.
For what I've found, I just need to use to setup HAProxy, etcd and spilo, right?
A docker-compose.yml more or less like the one supplied for Patroni testing is enough?
My apologies for such inconvenience but any help would be appreciated.
The text was updated successfully, but these errors were encountered: