Re: Configuration of django with master slave replication Postgres

From: Prince Pathria <prince(dot)pathria(at)goevive(dot)com>
To: soumitra bhandary <soumitra(dot)bhandary(at)hotmail(dot)com>
Cc: Thomas Poty <thomas(dot)poty(at)gmail(dot)com>, "shreeyansh2014(at)gmail(dot)com" <shreeyansh2014(at)gmail(dot)com>, "pgsql-admin(at)lists(dot)postgresql(dot)org" <pgsql-admin(at)lists(dot)postgresql(dot)org>
Subject: Re: Configuration of django with master slave replication Postgres
Date: 2019-04-04 13:06:36
Message-ID: CAON0Dax0A6rQAUQEcXNzoJ0Qc9s5J3Ec-DfEqXMamx4PQTpjyw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

I didn't configured watchdog mode(was not required for my use case).
Assuming you're using streaming replication, you can use my config.
Steps:1 Install pgpool as per your OS
Step:2 configure your /etc/pgpool/pool_hba.conf and pg_hba.conf as per your
requirement.
Step:3 create a file /etc/pgpool/pool_passwd for pgpool to connect to
postgres. use tool pg_md5, it will fill the file with username and
password.
Step:4 configure pgpool.conf as per your requirement. I'm attaching mine
for your reference.

http://www.pgpool.net/docs/latest/en/html/runtime-config-connection.html
http://www.pgpool.net/docs/latest/en/html/runtime-config-load-balancing.html
http://www.pgpool.net/docs/latest/en/html/runtime-config-backend-settings.html
http://www.pgpool.net/docs/latest/en/html/runtime-config-connection-pooling.html
http://www.pgpool.net/docs/latest/en/html/auth-methods.html
http://www.pgpool.net/docs/latest/en/html/pcp-commands.html
http://www.pgpool.net/docs/latest/en/html/runtime-config-logging.html
http://www.pgpool.net/docs/latest/en/html/runtime-config-running-mode.html
http://www.pgpool.net/docs/latest/en/html/runtime-streaming-replication-check.html

Go through them as well.

Happy to help :)
Prince Pathria Systems Engineer Evive +91 9478670472 goevive.com

On Thu, Apr 4, 2019 at 6:10 PM Prince Pathria <prince(dot)pathria(at)goevive(dot)com>
wrote:

> Hi Soumitra,
> In pgpool-II you can configure watchdog mode, so if one pgpool fails the
> other node of pgpool gets the VIP so that no change is required on client
> side.
> Can you show you django dsn config once?
> I'm assuming you can do same with pgpool, " Even for that reason in django
> I have to configure dsn like that so that it can automatically switch to
> other node if one node is not reachable." If you switch your dsn IPs and
> ports with 2 of pgpool node(if one pgpool fails dsn will switch to other
> pgpool node).
>
> Happy to help :)
> Prince Pathria Systems Engineer Evive +91 9478670472 goevive.com
>
>
> On Wed, Apr 3, 2019 at 5:47 AM soumitra bhandary <
> soumitra(dot)bhandary(at)hotmail(dot)com> wrote:
>
>> Hi Prince,
>>
>> Can you please share me the steps to set up pgpool. Also if I use single
>> pgpool that could led to the single point failure. Even for that reason in
>> django I have to configure dsn like that so that it can automatically
>> switch to other node if one node is not reachable. How to do that??
>>
>> Sent from my iPhone
>>
>> On 03-Apr-2019, at 2:10 AM, Prince Pathria <prince(dot)pathria(at)goevive(dot)com>
>> wrote:
>>
>> PgPool-II is very much suitable for your case. It will distribute your
>> read queries on master and slaves + automatic master switch detection +
>> connection pools.
>>
>> Happy to help :)
>> Prince Pathria Systems Engineer Evive +91 9478670472 goevive.com
>>
>>
>> On Tue, Apr 2, 2019 at 5:52 PM Thomas Poty <thomas(dot)poty(at)gmail(dot)com> wrote:
>>
>>> As you are using pg 9.5, these links may help :
>>>
>>>
>>> https://severalnines.com/blog/postgresql-load-balancing-using-haproxy-keepalived
>>> https://clusterlabs.github.io/PAF/
>>>
>>> Le mar. 2 avr. 2019 à 13:50, soumitra bhandary <
>>> soumitra(dot)bhandary(at)hotmail(dot)com> a écrit :
>>>
>>>>
>>>> Hi
>>>> Does anyone have any idea with django how to configure multiple dsn
>>>> that will automatically switch to new Postgres master host in case of
>>>> failover happens to previous master and auto promotion of new master is
>>>> done with repmgr.
>>>>
>>>>
>>>> My configuration is as below
>>>>
>>>> Master and asynchronous slave node . Repmgrd is configured to take care
>>>> of autofailover and promotion of new master node.
>>>>
>>>> But from application side with django how to make datasource so that it
>>>> automatically switches to new master node in case of failover.
>>>> Please share the steps.
>>>>
>>>>
>>>> Sent from my iPhone
>>>>
>>>>

Attachment Content-Type Size
pgpool.conf application/octet-stream 38.5 KB

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Keith Fiske 2019-04-04 13:27:02 Re: archive_command options?
Previous Message Prince Pathria 2019-04-04 12:40:13 Re: Configuration of django with master slave replication Postgres