Re: - PostgreSQL Replication Types

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Will McCormick <wmccormick(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: - PostgreSQL Replication Types
Date: 2015-12-17 15:37:39
Message-ID: 5672D6C3.5020504@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 12/17/2015 07:17 AM, Will McCormick wrote:
> I inherited a 9.1 replication environment
>
> Few basic questions that I can't find clear answers / clarifications for
> if possible:
>
> 3 types of replication in 9.1 I've read about from the offical docs:
>
> 1) warm standby
> 2) hot standby
> 3) streaming replication
>
> I'm using streaming replication I believe, the only indication I have
> is that there is the primary_conninfo on the standby. Is this the only
> indication?

On standby:

http://www.postgresql.org/docs/9.1/interactive/functions-admin.html
"
pg_last_xlog_receive_location()

Get last transaction log location received and synced to disk by
streaming replication. While streaming replication is in progress this
will increase monotonically. If recovery has completed this will remain
static at the value of the last WAL record received and synced to disk
during recovery. If streaming replication is disabled, or if it has not
yet started, the function returns NULL."

>
> Is it possible to get if using streaming replication under normal
> operations?
>
> /cp: cannot stat `/opt/postgres/9.1/archive/000000070000000F00000057':
> No such file or directory/
>
> /cp: cannot stat `/opt/postgres/9.1/archive/000000070000000F00000057':
> No such file or directory/
>
> /LOG: streaming replication successfully connected to primary/
>
> /FATAL: could not receive data from WAL stream: FATAL: requested WAL
> segment 000000070000000F00000057 has already been removed/

Assuming above is from standby log, correct?

The cp lines would seem to indicate a restore_command in the standby
recovery.conf, is that the case?:

http://www.postgresql.org/docs/9.1/static/archive-recovery-settings.html

restore_command (string)

The FATAL indicates that the WAL file has already been recycled on the
master.

See:

http://www.postgresql.org/docs/9.1/interactive/runtime-config-replication.html#RUNTIME-CONFIG-REPLICATION-MASTER

"wal_keep_segments (integer)

Specifies the minimum number of past log file segments kept in the
pg_xlog directory, in case a standby server needs to fetch them for
streaming replication. Each segment is normally 16 megabytes. If a
standby server connected to the primary falls behind by more than
wal_keep_segments segments, the primary might remove a WAL segment still
needed by the standby, in which case the replication connection will be
terminated. (However, the standby server can recover by fetching the
segment from archive, if WAL archiving is in use.)

This sets only the minimum number of segments retained in pg_xlog;
the system might need to retain more segments for WAL archival or to
recover from a checkpoint. If wal_keep_segments is zero (the default),
the system doesn't keep any extra segments for standby purposes, so the
number of old WAL segments available to standby servers is a function of
the location of the previous checkpoint and status of WAL archiving.
This parameter has no effect on restartpoints. This parameter can only
be set in the postgresql.conf file or on the server command line.
"

http://www.postgresql.org/docs/9.1/interactive/warm-standby.html#STREAMING-REPLICATION

"If you use streaming replication without file-based continuous
archiving, you have to set wal_keep_segments in the master to a value
high enough to ensure that old WAL segments are not recycled too early,
while the standby might still need them to catch up. If the standby
falls behind too much, it needs to be reinitialized from a new base
backup. If you set up a WAL archive that's accessible from the standby,
wal_keep_segments is not required as the standby can always use the
archive to catch up."

>
> /
> /
>
> My understanding is that warm standby and hot standby do log shipping
> and there is a greater window for transactions not to be send to the
> standby because WAL XLOG must be filled.

Hot versus warm standby refer to whether it is possible to run read only
queries on the standby in the first case or not in the second case.

>
>
> Whereas Streaming replication basically sends at the transaction level?

The difference you are looking for is log shipping versus streaming,
where log shipping moves complete WAL files and streaming streams the
same files.

See here for more detail:

http://www.postgresql.org/docs/9.1/interactive/high-availability.html

>
>
> I'm sure this is somewhat misinformed!
>
>
> Thanks,
>
>
> Will
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Steele 2015-12-17 15:46:08 Re: - PostgreSQL Replication Types
Previous Message Will McCormick 2015-12-17 15:17:47 - PostgreSQL Replication Types