Re: Create a standby server

From: Mateusz Henicz <mateuszhenicz(at)gmail(dot)com>
To: normandavis1990 <normandavis1990(at)proton(dot)me>
Cc: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Create a standby server
Date: 2024-03-11 12:09:56
Message-ID: CAN6i3YPZfzBJ673+SpeLM6NTDo9y236XP8CZazh9jzmqfDkaCw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hey,
Check your parameter primary_conninfo on any standby server, you should
find here information about the user used for replication and its password
or path to .pgpass file, where the password is stored. If there is no
password or .pgpass file defined, then you do not need any password most
likely, and you are likely using the "trust" authentication method in your
pg_hba.conf for replication.

To create a replica pretty much all you have to do is to add your new
standby server to pg_hba.conf, so you are allowed to connect and run on
your new standby:
pg_basebackup -h <primary IP address> -U <replicator_user> -R -D /data_pg
-X stream
and then start it using
pg_ctl -D /data_pg start

There can be some parameters that need to be adjusted, like
listen_addresses for example, unless you are using "*" for it. And maybe
max_wal_senders/max_replication_slots can be too low and you may have to
increase it, but if there is any problem and you will try to start your new
replica it will just fail and you will get information about what was wrong
to your logfile, so it is easy to find.

By adding -R to pg_basebackup you will get your replication configuration
generated automatically to postgresql.auto.conf and -X will stream all WAL
files generated during pg_basebackup execution to your new replica server.
If you prefer to use replication slots you may also add -C -S <slot_name>
to get a replication slot created automatically by pg_basebackup.

Good luck!

Cheers,
Mateusz

pon., 11 mar 2024 o 12:51 normandavis1990 <normandavis1990(at)proton(dot)me>
napisał(a):

> Hello,
> I have a master and tow standby servers. I want to create another
> one. These servers are made by someone else and I am a newbie in PostgreSQL.
> I found the following two tutorials:
>
> https://linuxconfig.org/how-to-create-a-hot-standby-with-postgresql
>
>
> https://github.com/GoogleCloudPlatform/community/blob/master/archived/setting-up-postgres-hot-standby.md
>
> A) Which on is better and easier?
>
> B) In these articles, to create a Standby server, a user is created in the
> database. Because there are already two Standby servers, this user is
> probably created. How can I find it? Can I use that user to build a third
> server?
>
>
> Cheers.
>
>
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stephen Frost 2024-03-11 12:13:45 Re: Create a standby server
Previous Message Stephen Frost 2024-03-11 11:56:31 Re: could not open file "global/pg_filenode.map": Operation not permitted