Обсуждение: Pg_basebackup does not do aything

Поиск
Список
Период
Сортировка

Pg_basebackup does not do aything

От
thomas simon
Дата:
Hello,

I have a configuration in master (A) /slave (B) streaming replication.
I bought a third server (C), and I want to use C as my next master server.
In a first time, i would like to sync C as a slave, and in a second time
i would like to promote C to master, and change my current master (A) to
slave (the third server (B) would be out of the equation)

So I tried to use pg_basebackup on C, either synced on B if possible
(cascading replication), or in A if it is needed, but when i use the
command, nothing happened

My command is  :  pg_basebackup -D /data/postgresql/9.3/main -P -v -h
MASTER -U replicator -X s
(this command worked when I used it on my current slave)

In view pg_stat_replication on master, I have this (1st is my streaming
on slave, 2nd is the pg_basebackup I try to use)

  506 |  5828189 | replicator | walreceiver      | 172.25.1.2
|                 |       48022 | 2014-06-25 21:54:34.561107+02 |
streaming | 3E3/597E0000  | 3E3/597A0000   | 3E3/597A0000   |
3E3/5977F290    |             0 | async
  512 |  5828189 | replicator | pg_basebackup    | 172.25.1.3
|                 |       45573 | 2014-06-25 21:54:39.324114+02 |
backup  | 0/0           | 3DD/BDF88000   | 3DD/BDF88000   |
3DD/BDF67C98    |             0 | async


I try to use it on master and slave, but it does the same thing (nothing)
I am wrong in the way I try to use replication ?

Thanks
Thomas


Re: Pg_basebackup does not do aything

От
Matheus de Oliveira
Дата:

On Wed, Jun 25, 2014 at 4:58 PM, thomas simon <tsimon@neteven.com> wrote:
My command is  :  pg_basebackup -D /data/postgresql/9.3/main -P -v -h MASTER -U replicator -X s

I'm betting you are just waiting for a "spread" checkpoint. If that is the case, you can issue a CHECKPOINT command on the master and see if your backup start running, or you you can use "--checkpoint=fast" option for pg_basebackup.


--
Matheus de Oliveira
Analista de Banco de Dados
Dextra Sistemas - MPS.Br nível F!
www.dextra.com.br/postgres

Re: Pg_basebackup does not do aything

От
thomas simon
Дата:
Yes, it did the trick !
Thanks Matheus

Something I don't understand is how my 2nd slave will be synced to master, because master's archive command only sent WAL files to 1st slave.
Does I have to archive on both slaves ? (is it possible) ?
And what I am supposed to use with parameter "restore_command" ?
In this case, my new slave will not start if i dont start it just after the end of the pg_basebackup ?




Le 25/06/2014 22:49, Matheus de Oliveira a écrit :

On Wed, Jun 25, 2014 at 4:58 PM, thomas simon <tsimon@neteven.com> wrote:
My command is  :  pg_basebackup -D /data/postgresql/9.3/main -P -v -h MASTER -U replicator -X s

I'm betting you are just waiting for a "spread" checkpoint. If that is the case, you can issue a CHECKPOINT command on the master and see if your backup start running, or you you can use "--checkpoint=fast" option for pg_basebackup.


--
Matheus de Oliveira
Analista de Banco de Dados
Dextra Sistemas - MPS.Br nível F!
www.dextra.com.br/postgres


Re: Pg_basebackup does not do aything

От
Matheus de Oliveira
Дата:

On Wed, Jun 25, 2014 at 7:24 PM, thomas simon <tsimon@neteven.com> wrote:
Yes, it did the trick !
Thanks Matheus


You're welcome. Just know that this may cause some I/O storm if you have many dirty data in your buffer caches.
 
Something I don't understand is how my 2nd slave will be synced to master, because master's archive command only sent WAL files to 1st slave.
Does I have to archive on both slaves ? (is it possible) ?

Streaming Replication (configured by primary_conninfo) does not need to use archives, instead PG uses one dedicated process on each server (wal sender and wal receiver) that sends records of WAL from the sender (a master or another slave in cascading replication scenario) to the receiver.

So, you can, but you don't necessarily *need* to send the archives to the slaves.
 
And what I am supposed to use with parameter "restore_command" ?

It is recommended to configure it to grab archive files from somewhere (can be from other node) if you have archiving enabled. So, if the receiver can't keep up with the sender (e.g. when the WAL files are rotated and the sender does not have the files the receiver wants anymore), it can get the files it need from archiving.
 
In this case, my new slave will not start if i dont start it just after the end of the pg_basebackup ?

Yes. You have to start it after pg_basebackup. It is also recommended to use "-X stream" option for pg_basebackup, it will copy the necessary WAL files to the slave, and so it can start faster. Be aware that you'll need two slots of max_wal_sender to accomplish that (one for the data backup and other for the WAL files).


--
Matheus de Oliveira
Analista de Banco de Dados
Dextra Sistemas - MPS.Br nível F!
www.dextra.com.br/postgres

Re: Pg_basebackup does not do aything

От
John Scalia
Дата:
From your last message:
> It is recommended to configure it to grab archive files from somewhere (can be from other node) if you have archiving
enabled.So, if the receiver can't keep up with the sender  
> (e.g. when the WAL files are rotated and the sender does not have the files the receiver wants anymore), it can get
thefiles it need from archiving. 
>
According to the postgresql documentation at 25.2.3 Preparing the Master for Standby Servers, Set up continuous
archivingon the primary to an archive directory accessible from the  
standby.

I took this to mean the archive_command = "scp %p postgres@<IP of standby>:/<directory on standby>"

And yes, you can add a ";" at the end of this and specify a second server. That's what I'm doing. Oh, and you have to
setupssh keyrings so the scp will not prompt for a password.  
Anyway, I got the impression that the primary should push and the standby's should not pull WAL segments from this part
ofthe docs. Although, I can see how you could just specify  
the scp in the restore_command and do the pull. I just don't know the safety of doing that.
--
Jay