copilot-cli icon indicating copy to clipboard operation
copilot-cli copied to clipboard

how to configure primary-replica configuration for postgres containers by aws copilot

Open Dhina-test opened this issue 3 years ago • 10 comments

we are hosting postgres containers into ecs by aws copilot , so how to configure master slave configuration for database containers by aws copilot. Can anyone please help

Dhina-test avatar Aug 26 '22 16:08 Dhina-test

For database replication how to configure master and slave configuration ecs db(postgres) containers by aws copilot

Dhina-test avatar Aug 26 '22 16:08 Dhina-test

Would storage helps with data transfer between master and slave containers in your case?

In the meanwhile, if any one has existing set up, please feel free to share and it'll be very appreciated!

Lou1415926 avatar Aug 26 '22 22:08 Lou1415926

@Lou1415926 , Is there any option to create secondary container from copy of primary container ?

Dhina-test avatar Aug 26 '22 22:08 Dhina-test

Yes.

In the meantime you can also look into RDS's read replica option. You should be able to create an RDS database with PostgreSQL engine as an addon.

Lou1415926 avatar Aug 26 '22 22:08 Lou1415926

As of now we are hosting db in ecs containers , can you please help to configure replica from primary to secondary by copilot

Dhina-test avatar Aug 26 '22 22:08 Dhina-test

@Lou1415926 , Now i created 2 ecs containers by copilot , and mounted two different efs volumes for both the containers , Now to how to make sync with primary and secondary ?? can you please help

Dhina-test avatar Aug 26 '22 22:08 Dhina-test

Hopefully this post can help!

Lou1415926 avatar Aug 26 '22 22:08 Lou1415926

Or you can set up two Backend services: a master service, and some slave services. When master services receive WRITE to the database, it connects to the slave service via. service discovery endpoint replicating the data. That's potentially an option to explore too.

Lou1415926 avatar Aug 26 '22 23:08 Lou1415926

Hey @Dhina-test! Have you looked at https://github.com/bitnami/containers/tree/main/bitnami/postgresql? I think that looks like the easiest way to deploy postgres in a container with a primary/replica setup - they have a nice guide for it here.

Assuming you're deploying this as two Copilot backend services, then you can just configure the environment variables on the primary and replia services following that guide, using service discovery URLs like @Lou1415926 mentioned.

dannyrandall avatar Aug 26 '22 23:08 dannyrandall

yes @dannyrandall , I am deploying two copilot backend postgres containers , mounted two different efs volumes .checking to configure one as primary and another as a replica.

Dhina-test avatar Aug 26 '22 23:08 Dhina-test

This issue is stale because it has been open 60 days with no response activity. Remove the stale label, add a comment, or this will be closed in 14 days.

github-actions[bot] avatar Sep 12 '23 00:09 github-actions[bot]

This issue is closed due to inactivity. Feel free to reopen the issue if you have any further questions!

github-actions[bot] avatar Sep 26 '23 00:09 github-actions[bot]