Re: setting up streaming replication

From: Ron <ronljohnsonjr(at)gmail(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: setting up streaming replication
Date: 2023-10-24 01:28:21
Message-ID: 7a9570a6-07a9-4b41-b419-b4a0aa67fc53@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 10/23/23 18:16, Brad White wrote:
> I'm stumped.
>
> Using this command to set up the slave and replication on PG v 15:
> "C:\Program Files\PostgreSQL\15\bin\pg_basebackup" -h 192.168.1.126 -U
> pgrep_user -p 5433 -D "C:\Program Files\PostgreSQL\15\data" -Fp -Xs -R
>
> If I have PG running on the remote server and the data directory is
> intact, then I get an error, Data exists and is not empty.
>
> If I shut down PG, delete data\*, restart PG, then it fails to start
> because the conf files are missing.
>
> If I leave PG shut down and run pg_basebackup, it times out and asks if pg
> is running and listening on the port. Of course it is not.
>
> I see lots of posts on how to use pg_basebackup, but apparently this isn't
> interesting because no one mentions whether pg should be running on
> the remote server.

No, it should not.

This is what works for me, in Linux on the standby system, where "buddy" and
"basebackup" are references in .pg_service.conf to the primary server:
PGHOST=...
pg_ctl status && pg_ctl stop -mfast
psql service=buddy -Xac "select pg_drop_replication_slot(slot_name)
                         from pg_replication_slots
                         where slot_name = 'pgstandby1';"
/usr/bin/rm -r $PGDATA/*
pg_basebackup --dbname=service=basebackup -D $PGDATA --progress \
              --checkpoint=fast -v \
              --write-recovery-conf --wal-method=stream \
              --create-slot --slot=pgstandby1 --compress=server-zstd
pg_ctl start -wt90 -l ${MajVer}/pgstart_standby.log

Source:
https://www.tecmint.com/configure-postgresql-streaming-replication-in-centos-8/

--
Born in Arizona, moved to Babylonia.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David Rowley 2023-10-24 02:13:27 Re: partitioning
Previous Message pf 2023-10-24 00:03:16 Re: Disk wait problem...