PostgreSQL La base de donnees la plus sophistiquee au monde.

Forums PostgreSQL.fr

Le forum officiel de la communauté francophone de PostgreSQL

Vous n'êtes pas identifié(e).

#1 04/05/2010 15:58:08

fadace
Membre

Log shipping et WAL/Standby

J'ai installé postresql 8.4.3 sur 2 machines similaires

J'ai configuré sur la base source postgresql.conf avec, entre autres, les paramètre suivants:

archive_mode  =  on  
archive_command  =  '/usr/bin/scp "%p" machine02:/data/DB/WAL/"%f"'  
archive_timeout = 60

J'ai configuré un canal ssh bidirectionnel entre les 2 machines

Les fichiers journaux sont transférés d'une machine à l'autre sans souci : le répertoire WAL a été créé sur les 2 machines.

J'ai fait le transfert comme spécifié dans la doc

psql -U postgres -h machine01 -p 5432 << EOF
SELECT pg_start_backup('debut_backup_wal', true);
EOF

tar -cvf /data/DB.tar /data/DB

psql -U postgres -h machine01 -p 5432 << EOF
SELECT pg_stop_backup();
EOF

gzip /data/DB.tar
scp /data/DB.tar.gz Machine02:/data/

Puis sur la machine 2, arrêt de l'instance à écraser, puis

cd /data
cp DB/*.conf .
gunzip DB.tar.gz
tar -xvf DB.tar
mv *.conf /data/DB/

J'ai bien créé le fichier recovery.conf. 

Lorsque je redémarre la 2ème base (standby), j'ai le msg suivant

2010-05-04 15:42:13 DFTLOG:  database system was interrupted; last known up at 2010-05-04 15:37:28 DFT
2010-05-04 15:42:13 DFTLOG:  starting archive recovery
2010-05-04 15:42:13 DFTLOG:  restore_command = '/usr/bin/cp "WAL/%f" "%p"'
cp: WAL/00000001.history: A file or directory in the path name does not exist.
cp: WAL/0000000100000000000000A1.00000020.backup: A file or directory in the path name does not exist.
cp: WAL/0000000100000000000000A1: A file or directory in the path name does not exist.
2010-05-04 15:42:13 DFTLOG:  automatic recovery in progress
2010-05-04 15:42:13 DFTLOG:  record with zero length at 0/A1000068
2010-05-04 15:42:13 DFTLOG:  redo is not required
cp: WAL/0000000100000000000000A1: A file or directory in the path name does not exist.
cp: WAL/00000002.history: A file or directory in the path name does not exist.
2010-05-04 15:42:14 DFTLOG:  selected new timeline ID: 2
cp: WAL/00000001.history: A file or directory in the path name does not exist.
2010-05-04 15:42:14 DFTLOG:  archive recovery complete
2010-05-04 15:42:14 DFTLOG:  autovacuum launcher started
2010-05-04 15:42:14 DFTLOG:  database system is ready to accept connections

... et effectivement, je n'ai pas le fichier 0000A1, j'ai les 0000A2, 0000A3, ... mais pas le 0000A1! Sur la machine souce, dans pg_xlog, j'ai par contre un fichier  0000000100000000000000A1.00000020.backup

et  pourquoi ma base standby est-elle ouverte ...

Une aide serait la bienvenue...

Hors ligne

#2 04/05/2010 16:35:55

gleu
Administrateur

Re : Log shipping et WAL/Standby

... et effectivement, je n'ai pas le fichier 0000A1, j'ai les 0000A2, 0000A3, ... mais pas le 0000A1! Sur la machine souce, dans pg_xlog, j'ai par contre un fichier  0000000100000000000000A1.00000020.backup

Ne pas avoir le fichier A1 tout en ayant le A1.backup est très étonnant. Vous n'auriez pas supprimé certains journaux de transactions archivés ? vous devez tous les avoir, de celui datant du lancement de pg_start_backup() au dernier.

et  pourquoi ma base standby est-elle ouverte ...

PostgreSQL a demandé à la restore_command de lui donner le journal A1. cp ne le trouvant pas, il renvoie le code d'erreur 1 à PostgreSQL, ce qui déclenche la fin de la restauration, et donc une mise à disposition de PostgreSQL. Rien que du très normal.


Guillaume.

Hors ligne

#3 04/05/2010 17:28:35

fadace
Membre

Re : Log shipping et WAL/Standby

J'ai recommencé toute ma procédure en dissociant, cette fois-ci, le répertoire WAL du PGDATA, afin de ne pas l'écraser lors de la copie.

Au niveau de mon backup, j'ai

 pg_start_backup
-----------------
 0/B8000020

 pg_stop_backup
----------------
 0/B9000000

Au niveau de mon pg_xlog source, j'ai

[postgres@gmapdba01] > ls
0000000100000000000000B7
0000000100000000000000B8
0000000100000000000000B8.00000020.backup
0000000100000000000000B9
0000000100000000000000BA
0000000100000000000000BB
0000000100000000000000BC
0000000100000000000000BD
0000000100000000000000BE
archive_status

Au niveau de mon répertoire WAL sur la cible, j'ai

0000000100000000000000B3                  
0000000100000000000000B7
0000000100000000000000B4                  
0000000100000000000000B7.00000020.backup
0000000100000000000000B4.00000020.backup  
0000000100000000000000B8
0000000100000000000000B5                  
0000000100000000000000B8.00000020.backup
0000000100000000000000B6

Dans mon fichier recovy.conf sur la cible, avant de démarrer la base, j'ai

restore_command = '/usr/bin/cp "/data/WAL/1P/%f" "%p"'

En redémarrant ma base, j'ai le msg

pg_ctl: another server might be running; trying to start server anyway
server starting

... bien qu'aucun autre serveur ne soit actif sur cette machine et sur ce port

.. et j'ai le log

2010-05-04 17:26:10 DFTLOG:  database system was interrupted; last known up at 2010-05-04 17:19:13 DFT
2010-05-04 17:26:10 DFTLOG:  starting archive recovery
2010-05-04 17:26:10 DFTLOG:  restore_command = '/usr/bin/cp "/data/WAL/1P/%f" "%p"'
cp: /data/WAL/1P/00000001.history: A file or directory in the path name does not exist.
2010-05-04 17:26:10 DFTLOG:  restored log file "0000000100000000000000B8.00000020.backup" from archive
2010-05-04 17:26:10 DFTLOG:  restored log file "0000000100000000000000B8" from archive
2010-05-04 17:26:10 DFTLOG:  automatic recovery in progress
2010-05-04 17:26:10 DFTLOG:  redo starts at 0/B8000068, consistency will be reached at 0/B9000000
2010-05-04 17:26:10 DFTLOG:  restored log file "0000000100000000000000B9" from archive
2010-05-04 17:26:10 DFTLOG:  consistent recovery state reached
cp: /data/WAL/1P/0000000100000000000000BA: A file or directory in the path name does not exist.
2010-05-04 17:26:10 DFTLOG:  unexpected pageaddr 0/B2000000 in log file 0, segment 186, offset 0
2010-05-04 17:26:10 DFTLOG:  redo done at 0/B9000068
2010-05-04 17:26:10 DFTLOG:  restored log file "0000000100000000000000B9" from archive
cp: /data/WAL/1P/00000002.history: A file or directory in the path name does not exist.
2010-05-04 17:26:10 DFTLOG:  selected new timeline ID: 2
cp: /data/WAL/1P/00000001.history: A file or directory in the path name does not exist.
2010-05-04 17:26:10 DFTLOG:  archive recovery complete
2010-05-04 17:26:11 DFTLOG:  database system is ready to accept connections
2010-05-04 17:26:11 DFTLOG:  autovacuum launcher started

m.s.

Dernière modification par fadace (04/05/2010 17:31:24)

Hors ligne

#4 04/05/2010 17:37:46

gleu
Administrateur

Re : Log shipping et WAL/Standby

Le « another server might be running; trying to start server anyway » est dû au fait que vous avez laissé le fichier postmaster.pid.

Pour la suite, il a restauré le journal B8, puis le journal B9. Le journal BA n'existant pas, la commande cp a renvoyé l'erreur « A file or directory in the path name does not exist. », ce qui a causé l'arrêt de la restauration et la mise à disposition d serveur PostgreSQL.

Tout a fonctionné correctement.


Guillaume.

Hors ligne

#5 04/05/2010 17:47:48

fadace
Membre

Re : Log shipping et WAL/Standby

Alors j'ai un problème de compréhension uniquement...

Mon but est d'obtenir une base en WSB.

Je m'attend à ce que mon serveur 2, lorsqu'il a lu tous les journaux disponibles, reste en attente des futurs journaux et ne s'ouvre pas.

Ce serait lors d'un crash de la base 1 que je souhaiterai rendre disponible la base 2...

Qu'ai-je raté ?

m.s. et merci de ton aide

Dernière modification par fadace (04/05/2010 17:55:02)

Hors ligne

#6 04/05/2010 18:01:18

gleu
Administrateur

Re : Log shipping et WAL/Standby

Que ce n'est pas à PostgreSQL d'être en attente, c'est à la commande fournie au restore_command. Comme cp n'attend pas, vous n'avez pas de Warm Standby. Il vous faut remplacer cp par un autre outil comme pg_standby. Ce document http://www.dalibo.org/hs44_la_replicati … ansactions pourrait vous être utile.


Guillaume.

Hors ligne

#7 05/05/2010 10:39:26

fadace
Membre

Re : Log shipping et WAL/Standby

Ok. J'ai compilé et configuré le pg_standby

restore_command = '/opt/postgresql84/bin/pg_standby -d -t /data/WAL/1P/stopstandby /data/WAL/1P %f %p %r >> /home/postgres/scripts/LOG/WSB.log 2>&1'

Au démarrage, j'ai maintenant

2010-05-05 09:52:52 DFTLOG:  database system was interrupted; last known up at 2010-05-05 09:32:38 DFT
2010-05-05 09:52:52 DFTLOG:  starting archive recovery
2010-05-05 09:52:52 DFTLOG:  restore_command = '/opt/postgresql84/bin/pg_standby -d -t /data/WAL/1P/stopstandby /data/WAL/1P
 %f %p %r >> /home/postgres/scripts/LOG/WSB.log 2>&1'

... et cela reste là, ce qui semble de bon augure

Concernant le log, j'ai

Trigger file            : /data/WAL/1P/stopstandby
Waiting for WAL file    : 00000001.history
WAL file path           : /data/WAL/1P/00000001.history
Restoring to            : pg_xlog/RECOVERYHISTORY
Sleep interval          : 5 seconds
Max wait interval       : 0 forever
Command for restore     : cp "/data/WAL/1P/00000001.history" "pg_xlog/RECOVERYHISTORY"
Keep archive history    : 000000000000000000000000 and later
running restore         :sh: cp:  not found.
sh: cp:  not found.
sh: cp:  not found.

sh et cp sont dans mon PATH (/usr/bin) mais cela semble indisposer le pg_standby. d'où tire-t-il sa commande sous "Command for restore" ?

D'autre part, je ne trouve effectivement pas de ficher /data/WAL/1P/00000001.history. D'où le tire-t-il ?

Sous pg_xlog, j'ai

drwx------    3 postgres postgres       4096 May 05 10:33 .
drwx------   11 postgres postgres       4096 May 05 10:36 ..
-rw-------    1 postgres postgres        252 May 05 09:50 00000001000000010000007C.00000020.backup
-rw-------    1 postgres postgres   16777216 May 05 10:32 000000010000000100000088
-rw-------    1 postgres postgres   16777216 May 05 10:33 000000010000000100000089
-rw-------    1 postgres postgres   16777216 May 05 10:02 00000001000000010000008A
-rw-------    1 postgres postgres   16777216 May 05 10:07 00000001000000010000008B
-rw-------    1 postgres postgres   16777216 May 05 10:12 00000001000000010000008C
-rw-------    1 postgres postgres   16777216 May 05 10:17 00000001000000010000008D
-rw-------    1 postgres postgres   16777216 May 05 10:22 00000001000000010000008E
-rw-------    1 postgres postgres   16777216 May 05 10:27 00000001000000010000008F
drwx------    2 postgres postgres        256 May 05 10:33 archive_status

Sous /data/WAL/1P/, j'ai

[postgres@gmapdba02] > ll
total 7012448
drwxr-xr-x    2 postgres postgres      16384 May 05 10:35 .
drwxr-xr-x    4 postgres postgres        256 May 05 10:33 ..
-rw-------    1 postgres postgres   16777216 May 04 17:05 0000000100000000000000B3
-rw-------    1 postgres postgres   16777216 May 04 17:07 0000000100000000000000B4
-rw-------    1 postgres postgres        252 May 04 17:08 0000000100000000000000B4.00000020.backup
-rw-------    1 postgres postgres   16777216 May 04 17:12 0000000100000000000000B5
-rw-------    1 postgres postgres   16777216 May 04 17:17 0000000100000000000000B6
-rw-------    1 postgres postgres   16777216 May 04 17:18 0000000100000000000000B7
-rw-------    1 postgres postgres        252 May 04 17:19 0000000100000000000000B7.00000020.backup
-rw-------    1 postgres postgres   16777216 May 04 17:20 0000000100000000000000B8
-rw-------    1 postgres postgres        252 May 04 17:21 0000000100000000000000B8.00000020.backup
-rw-------    1 postgres postgres   16777216 May 04 17:25 0000000100000000000000B9
-rw-------    1 postgres postgres   16777216 May 04 17:30 0000000100000000000000BA
-rw-------    1 postgres postgres   16777216 May 04 17:35 0000000100000000000000BB
-rw-------    1 postgres postgres   16777216 May 04 17:40 0000000100000000000000BC
-rw-------    1 postgres postgres   16777216 May 04 17:45 0000000100000000000000BD
-rw-------    1 postgres postgres   16777216 May 04 17:50 0000000100000000000000BE
-rw-------    1 postgres postgres   16777216 May 04 17:55 0000000100000000000000BF
-rw-------    1 postgres postgres   16777216 May 04 18:00 0000000100000000000000C0
-rw-------    1 postgres postgres   16777216 May 04 18:05 0000000100000000000000C1
-rw-------    1 postgres postgres   16777216 May 04 18:10 0000000100000000000000C2
-rw-------    1 postgres postgres   16777216 May 04 18:15 0000000100000000000000C3
-rw-------    1 postgres postgres   16777216 May 04 18:20 0000000100000000000000C4
-rw-------    1 postgres postgres   16777216 May 04 18:25 0000000100000000000000C5
-rw-------    1 postgres postgres   16777216 May 04 18:30 0000000100000000000000C6
-rw-------    1 postgres postgres   16777216 May 04 18:35 0000000100000000000000C7
-rw-------    1 postgres postgres   16777216 May 04 18:40 0000000100000000000000C8
-rw-------    1 postgres postgres   16777216 May 04 18:45 0000000100000000000000C9
-rw-------    1 postgres postgres   16777216 May 04 18:50 0000000100000000000000CA
-rw-------    1 postgres postgres   16777216 May 04 18:55 0000000100000000000000CB
-rw-------    1 postgres postgres   16777216 May 04 19:00 0000000100000000000000CC
-rw-------    1 postgres postgres   16777216 May 04 19:05 0000000100000000000000CD
-rw-------    1 postgres postgres   16777216 May 04 19:10 0000000100000000000000CE
-rw-------    1 postgres postgres   16777216 May 04 19:15 0000000100000000000000CF
-rw-------    1 postgres postgres   16777216 May 04 19:20 0000000100000000000000D0
-rw-------    1 postgres postgres   16777216 May 04 19:25 0000000100000000000000D1
-rw-------    1 postgres postgres   16777216 May 04 19:30 0000000100000000000000D2
-rw-------    1 postgres postgres   16777216 May 04 19:35 0000000100000000000000D3
-rw-------    1 postgres postgres   16777216 May 04 19:40 0000000100000000000000D4
-rw-------    1 postgres postgres   16777216 May 04 19:45 0000000100000000000000D5
-rw-------    1 postgres postgres   16777216 May 04 19:50 0000000100000000000000D6
-rw-------    1 postgres postgres   16777216 May 04 19:55 0000000100000000000000D7
-rw-------    1 postgres postgres   16777216 May 04 20:00 0000000100000000000000D8
-rw-------    1 postgres postgres   16777216 May 04 20:05 0000000100000000000000D9
-rw-------    1 postgres postgres   16777216 May 04 20:10 0000000100000000000000DA
-rw-------    1 postgres postgres   16777216 May 04 20:15 0000000100000000000000DB
-rw-------    1 postgres postgres   16777216 May 04 20:20 0000000100000000000000DC
-rw-------    1 postgres postgres   16777216 May 04 20:25 0000000100000000000000DD
-rw-------    1 postgres postgres   16777216 May 04 20:30 0000000100000000000000DE
-rw-------    1 postgres postgres   16777216 May 04 20:35 0000000100000000000000DF
-rw-------    1 postgres postgres   16777216 May 04 20:40 0000000100000000000000E0
-rw-------    1 postgres postgres   16777216 May 04 20:45 0000000100000000000000E1
-rw-------    1 postgres postgres   16777216 May 04 20:50 0000000100000000000000E2
-rw-------    1 postgres postgres   16777216 May 04 20:55 0000000100000000000000E3
-rw-------    1 postgres postgres   16777216 May 04 21:00 0000000100000000000000E4
-rw-------    1 postgres postgres   16777216 May 04 21:05 0000000100000000000000E5
-rw-------    1 postgres postgres   16777216 May 04 21:10 0000000100000000000000E6
-rw-------    1 postgres postgres   16777216 May 04 21:15 0000000100000000000000E7
-rw-------    1 postgres postgres   16777216 May 04 21:20 0000000100000000000000E8
-rw-------    1 postgres postgres   16777216 May 04 21:25 0000000100000000000000E9
-rw-------    1 postgres postgres   16777216 May 04 21:30 0000000100000000000000EA
-rw-------    1 postgres postgres   16777216 May 04 21:35 0000000100000000000000EB
-rw-------    1 postgres postgres   16777216 May 04 21:40 0000000100000000000000EC
-rw-------    1 postgres postgres   16777216 May 04 21:45 0000000100000000000000ED
-rw-------    1 postgres postgres   16777216 May 04 21:50 0000000100000000000000EE
-rw-------    1 postgres postgres   16777216 May 04 21:55 0000000100000000000000EF
-rw-------    1 postgres postgres   16777216 May 04 22:00 0000000100000000000000F0
-rw-------    1 postgres postgres   16777216 May 04 22:05 0000000100000000000000F1
-rw-------    1 postgres postgres   16777216 May 04 22:10 0000000100000000000000F2
-rw-------    1 postgres postgres   16777216 May 04 22:15 0000000100000000000000F3
-rw-------    1 postgres postgres   16777216 May 04 22:20 0000000100000000000000F4
-rw-------    1 postgres postgres   16777216 May 04 22:25 0000000100000000000000F5
-rw-------    1 postgres postgres   16777216 May 04 22:30 0000000100000000000000F6
-rw-------    1 postgres postgres   16777216 May 04 22:35 0000000100000000000000F7
-rw-------    1 postgres postgres   16777216 May 04 22:40 0000000100000000000000F8
-rw-------    1 postgres postgres   16777216 May 04 22:45 0000000100000000000000F9
-rw-------    1 postgres postgres   16777216 May 04 22:50 0000000100000000000000FA
-rw-------    1 postgres postgres   16777216 May 04 22:55 0000000100000000000000FB
-rw-------    1 postgres postgres   16777216 May 04 23:00 0000000100000000000000FC
-rw-------    1 postgres postgres   16777216 May 04 23:05 0000000100000000000000FD
-rw-------    1 postgres postgres   16777216 May 04 23:10 0000000100000000000000FE
-rw-------    1 postgres postgres   16777216 May 04 23:15 000000010000000100000000
-rw-------    1 postgres postgres   16777216 May 04 23:20 000000010000000100000001
-rw-------    1 postgres postgres   16777216 May 04 23:25 000000010000000100000002
-rw-------    1 postgres postgres   16777216 May 04 23:30 000000010000000100000003
-rw-------    1 postgres postgres   16777216 May 04 23:35 000000010000000100000004
-rw-------    1 postgres postgres   16777216 May 04 23:40 000000010000000100000005
-rw-------    1 postgres postgres   16777216 May 04 23:45 000000010000000100000006
-rw-------    1 postgres postgres   16777216 May 04 23:50 000000010000000100000007
-rw-------    1 postgres postgres   16777216 May 04 23:55 000000010000000100000008
-rw-------    1 postgres postgres   16777216 May 05 00:00 000000010000000100000009
-rw-------    1 postgres postgres   16777216 May 05 00:05 00000001000000010000000A
-rw-------    1 postgres postgres   16777216 May 05 00:10 00000001000000010000000B
-rw-------    1 postgres postgres   16777216 May 05 00:15 00000001000000010000000C
-rw-------    1 postgres postgres   16777216 May 05 00:20 00000001000000010000000D
-rw-------    1 postgres postgres   16777216 May 05 00:25 00000001000000010000000E
-rw-------    1 postgres postgres   16777216 May 05 00:30 00000001000000010000000F
-rw-------    1 postgres postgres   16777216 May 05 00:35 000000010000000100000010
-rw-------    1 postgres postgres   16777216 May 05 00:40 000000010000000100000011
-rw-------    1 postgres postgres   16777216 May 05 00:45 000000010000000100000012
-rw-------    1 postgres postgres   16777216 May 05 00:50 000000010000000100000013
-rw-------    1 postgres postgres   16777216 May 05 00:55 000000010000000100000014
-rw-------    1 postgres postgres   16777216 May 05 01:00 000000010000000100000015
-rw-------    1 postgres postgres   16777216 May 05 01:05 000000010000000100000016
-rw-------    1 postgres postgres   16777216 May 05 01:10 000000010000000100000017
-rw-------    1 postgres postgres   16777216 May 05 01:15 000000010000000100000018
-rw-------    1 postgres postgres   16777216 May 05 01:20 000000010000000100000019
-rw-------    1 postgres postgres   16777216 May 05 01:25 00000001000000010000001A
-rw-------    1 postgres postgres   16777216 May 05 01:30 00000001000000010000001B
-rw-------    1 postgres postgres   16777216 May 05 01:35 00000001000000010000001C
-rw-------    1 postgres postgres   16777216 May 05 01:40 00000001000000010000001D
-rw-------    1 postgres postgres   16777216 May 05 01:45 00000001000000010000001E
-rw-------    1 postgres postgres   16777216 May 05 01:50 00000001000000010000001F
-rw-------    1 postgres postgres   16777216 May 05 01:55 000000010000000100000020
-rw-------    1 postgres postgres   16777216 May 05 02:00 000000010000000100000021
-rw-------    1 postgres postgres   16777216 May 05 02:05 000000010000000100000022
-rw-------    1 postgres postgres   16777216 May 05 02:10 000000010000000100000023
-rw-------    1 postgres postgres   16777216 May 05 02:15 000000010000000100000024
-rw-------    1 postgres postgres   16777216 May 05 02:20 000000010000000100000025
-rw-------    1 postgres postgres   16777216 May 05 02:25 000000010000000100000026
-rw-------    1 postgres postgres   16777216 May 05 02:30 000000010000000100000027
-rw-------    1 postgres postgres   16777216 May 05 02:35 000000010000000100000028
-rw-------    1 postgres postgres   16777216 May 05 02:40 000000010000000100000029
-rw-------    1 postgres postgres   16777216 May 05 02:45 00000001000000010000002A
-rw-------    1 postgres postgres   16777216 May 05 02:50 00000001000000010000002B
-rw-------    1 postgres postgres   16777216 May 05 02:55 00000001000000010000002C
-rw-------    1 postgres postgres   16777216 May 05 03:00 00000001000000010000002D
-rw-------    1 postgres postgres   16777216 May 05 03:05 00000001000000010000002E
-rw-------    1 postgres postgres   16777216 May 05 03:10 00000001000000010000002F
-rw-------    1 postgres postgres   16777216 May 05 03:15 000000010000000100000030
-rw-------    1 postgres postgres   16777216 May 05 03:20 000000010000000100000031
-rw-------    1 postgres postgres   16777216 May 05 03:25 000000010000000100000032
-rw-------    1 postgres postgres   16777216 May 05 03:30 000000010000000100000033
-rw-------    1 postgres postgres   16777216 May 05 03:35 000000010000000100000034
-rw-------    1 postgres postgres   16777216 May 05 03:40 000000010000000100000035
-rw-------    1 postgres postgres   16777216 May 05 03:45 000000010000000100000036
-rw-------    1 postgres postgres   16777216 May 05 03:50 000000010000000100000037
-rw-------    1 postgres postgres   16777216 May 05 03:55 000000010000000100000038
-rw-------    1 postgres postgres   16777216 May 05 04:00 000000010000000100000039
-rw-------    1 postgres postgres   16777216 May 05 04:05 00000001000000010000003A
-rw-------    1 postgres postgres   16777216 May 05 04:10 00000001000000010000003B
-rw-------    1 postgres postgres   16777216 May 05 04:15 00000001000000010000003C
-rw-------    1 postgres postgres   16777216 May 05 04:20 00000001000000010000003D
-rw-------    1 postgres postgres   16777216 May 05 04:25 00000001000000010000003E
-rw-------    1 postgres postgres   16777216 May 05 04:30 00000001000000010000003F
-rw-------    1 postgres postgres   16777216 May 05 04:35 000000010000000100000040
-rw-------    1 postgres postgres   16777216 May 05 04:40 000000010000000100000041
-rw-------    1 postgres postgres   16777216 May 05 04:45 000000010000000100000042
-rw-------    1 postgres postgres   16777216 May 05 04:50 000000010000000100000043
-rw-------    1 postgres postgres   16777216 May 05 04:55 000000010000000100000044
-rw-------    1 postgres postgres   16777216 May 05 05:00 000000010000000100000045
-rw-------    1 postgres postgres   16777216 May 05 05:05 000000010000000100000046
-rw-------    1 postgres postgres   16777216 May 05 05:10 000000010000000100000047
-rw-------    1 postgres postgres   16777216 May 05 05:15 000000010000000100000048
-rw-------    1 postgres postgres   16777216 May 05 05:20 000000010000000100000049
-rw-------    1 postgres postgres   16777216 May 05 05:25 00000001000000010000004A
-rw-------    1 postgres postgres   16777216 May 05 05:30 00000001000000010000004B
-rw-------    1 postgres postgres   16777216 May 05 05:35 00000001000000010000004C
-rw-------    1 postgres postgres   16777216 May 05 05:40 00000001000000010000004D
-rw-------    1 postgres postgres   16777216 May 05 05:45 00000001000000010000004E
-rw-------    1 postgres postgres   16777216 May 05 05:50 00000001000000010000004F
-rw-------    1 postgres postgres   16777216 May 05 05:55 000000010000000100000050
-rw-------    1 postgres postgres   16777216 May 05 06:00 000000010000000100000051
-rw-------    1 postgres postgres   16777216 May 05 06:05 000000010000000100000052
-rw-------    1 postgres postgres   16777216 May 05 06:10 000000010000000100000053
-rw-------    1 postgres postgres   16777216 May 05 06:15 000000010000000100000054
-rw-------    1 postgres postgres   16777216 May 05 06:20 000000010000000100000055
-rw-------    1 postgres postgres   16777216 May 05 06:25 000000010000000100000056
-rw-------    1 postgres postgres   16777216 May 05 06:30 000000010000000100000057
-rw-------    1 postgres postgres   16777216 May 05 06:35 000000010000000100000058
-rw-------    1 postgres postgres   16777216 May 05 06:40 000000010000000100000059
-rw-------    1 postgres postgres   16777216 May 05 06:45 00000001000000010000005A
-rw-------    1 postgres postgres   16777216 May 05 06:50 00000001000000010000005B
-rw-------    1 postgres postgres   16777216 May 05 06:55 00000001000000010000005C
-rw-------    1 postgres postgres   16777216 May 05 07:00 00000001000000010000005D
-rw-------    1 postgres postgres   16777216 May 05 07:05 00000001000000010000005E
-rw-------    1 postgres postgres   16777216 May 05 07:10 00000001000000010000005F
-rw-------    1 postgres postgres   16777216 May 05 07:15 000000010000000100000060
-rw-------    1 postgres postgres   16777216 May 05 07:20 000000010000000100000061
-rw-------    1 postgres postgres   16777216 May 05 07:25 000000010000000100000062
-rw-------    1 postgres postgres   16777216 May 05 07:30 000000010000000100000063
-rw-------    1 postgres postgres   16777216 May 05 07:35 000000010000000100000064
-rw-------    1 postgres postgres   16777216 May 05 07:40 000000010000000100000065
-rw-------    1 postgres postgres   16777216 May 05 07:45 000000010000000100000066
-rw-------    1 postgres postgres   16777216 May 05 07:50 000000010000000100000067
-rw-------    1 postgres postgres   16777216 May 05 07:55 000000010000000100000068
-rw-------    1 postgres postgres   16777216 May 05 08:00 000000010000000100000069
-rw-------    1 postgres postgres   16777216 May 05 08:05 00000001000000010000006A
-rw-------    1 postgres postgres   16777216 May 05 08:10 00000001000000010000006B
-rw-------    1 postgres postgres   16777216 May 05 08:15 00000001000000010000006C
-rw-------    1 postgres postgres   16777216 May 05 08:20 00000001000000010000006D
-rw-------    1 postgres postgres   16777216 May 05 08:25 00000001000000010000006E
-rw-------    1 postgres postgres   16777216 May 05 08:30 00000001000000010000006F
-rw-------    1 postgres postgres   16777216 May 05 08:35 000000010000000100000070
-rw-------    1 postgres postgres   16777216 May 05 08:40 000000010000000100000071
-rw-------    1 postgres postgres   16777216 May 05 08:45 000000010000000100000072
-rw-------    1 postgres postgres   16777216 May 05 08:50 000000010000000100000073
-rw-------    1 postgres postgres   16777216 May 05 08:55 000000010000000100000074
-rw-------    1 postgres postgres   16777216 May 05 09:00 000000010000000100000075
-rw-------    1 postgres postgres   16777216 May 05 09:05 000000010000000100000076
-rw-------    1 postgres postgres   16777216 May 05 09:10 000000010000000100000077
-rw-------    1 postgres postgres   16777216 May 05 09:15 000000010000000100000078
-rw-------    1 postgres postgres   16777216 May 05 09:20 000000010000000100000079
-rw-------    1 postgres postgres   16777216 May 05 09:25 00000001000000010000007A
-rw-------    1 postgres postgres   16777216 May 05 09:30 00000001000000010000007B
-rw-------    1 postgres postgres   16777216 May 05 09:33 00000001000000010000007C
-rw-------    1 postgres postgres        252 May 05 09:50 00000001000000010000007C.00000020.backup
-rw-------    1 postgres postgres   16777216 May 05 09:38 00000001000000010000007D
-rw-------    1 postgres postgres   16777216 May 05 09:43 00000001000000010000007E
-rw-------    1 postgres postgres   16777216 May 05 09:48 00000001000000010000007F
-rw-------    1 postgres postgres   16777216 May 05 09:53 000000010000000100000080
-rw-------    1 postgres postgres   16777216 May 05 09:58 000000010000000100000081
-rw-------    1 postgres postgres   16777216 May 05 10:03 000000010000000100000082
-rw-------    1 postgres postgres   16777216 May 05 10:08 000000010000000100000083
-rw-------    1 postgres postgres   16777216 May 05 10:13 000000010000000100000084
-rw-------    1 postgres postgres   16777216 May 05 10:18 000000010000000100000085
-rw-------    1 postgres postgres   16777216 May 05 10:23 000000010000000100000086
-rw-------    1 postgres postgres   16777216 May 05 10:28 000000010000000100000087
-rw-------    1 postgres postgres   16777216 May 05 10:33 000000010000000100000088
-rw-------    1 postgres postgres   16777216 May 05 10:34 000000010000000100000089
-rw-------    1 postgres postgres        252 May 05 10:35 000000010000000100000089.00000020.backup

m.s.

Dernière modification par fadace (05/05/2010 10:40:30)

Hors ligne

#8 05/05/2010 11:05:48

gleu
Administrateur

Re : Log shipping et WAL/Standby

sh et cp sont dans mon PATH (/usr/bin) mais cela semble indisposer le pg_standby. d'où tire-t-il sa commande sous "Command for restore" ?

Il utilise en dur soit cp soit ln. À priori, l'utilisateur qui exécute pg_standby (postgres je suppose) n'a pas accès à la commande cp. Le PATH pourrait ne pas être correctement défini pour l'utilisateur postgres. Ou un autre composant système empêcherait son utilisation. Ne connaissant pas AIX, je ne peux pas trop m'avancer. Mais le problème est clair : cp est introuvable pour cet utilisateur.

D'autre part, je ne trouve effectivement pas de ficher /data/WAL/1P/00000001.history. D'où le tire-t-il ?

Le fichier 1.history n'existe jamais. Une fois que le serveur en attente sera mis à disposition des utilisateurs, PostgreSQL créera un fichier 2.history qui lui sera utilisé par le prochain serveur en warmstandby. Bref, autrement dit, vous pouvez ignorer ce message.


Guillaume.

Hors ligne

#9 05/05/2010 14:06:21

fadace
Membre

Re : Log shipping et WAL/Standby

J'utilise pourtant moi aussi l'utilisateur postgres

La question a se poser est peut-être dans le shell qu'il utilise.

Je suis perso le Korn shell , et c'est celui qui et utilisé par défaut pour le login postgres.

Un which cp retourne la bonne commande.

J'ai essayé en mode "bourrin" : j'ai recompilé le pg_standby en hard-codant le chemin pour la commande cp

SET_RESTORE_COMMAND("/usr/bin/cp", WALFilePath, xlogFilePath);

et là, ça semble marcher... mais c'est de loin pas très élégant...
D'autres soucis semble persister

Trigger file            : /data/WAL/1P/stopstandby
Waiting for WAL file    : 00000001.history
WAL file path           : /data/WAL/1P/00000001.history
Restoring to            : pg_xlog/RECOVERYHISTORY
Sleep interval          : 5 seconds
Max wait interval       : 0 forever
Command for restore     : /usr/bin/cp "/data/WAL/1P/00000001.history" "pg_xlog/RECOVERYHISTORY"
Keep archive history    : 000000000000000000000000 and later
running restore         :cp: /data/WAL/1P/00000001.history: A file or directory in the path name does not exist.
cp: /data/WAL/1P/00000001.history: A file or directory in the path name does not exist.
cp: /data/WAL/1P/00000001.history: A file or directory in the path name does not exist.
cp: /data/WAL/1P/00000001.history: A file or directory in the path name does not exist.
not restored
history file not found
Trigger file            : /data/WAL/1P/stopstandby
Waiting for WAL file    : 0000000100000001000000B5.00000020.backup
WAL file path           : /data/WAL/1P/0000000100000001000000B5.00000020.backup
Restoring to            : pg_xlog/RECOVERYHISTORY
Sleep interval          : 5 seconds
Max wait interval       : 0 forever
Command for restore     : /usr/bin/cp "/data/WAL/1P/0000000100000001000000B5.00000020.backup" "pg_xlog/RECOVERYHISTORY"
Keep archive history    : 000000000000000000000000 and later
running restore         : OK
Trigger file            : /data/WAL/1P/stopstandby
Waiting for WAL file    : 0000000100000001000000B5
WAL file path           : /data/WAL/1P/0000000100000001000000B5
Restoring to            : pg_xlog/RECOVERYXLOG
Sleep interval          : 5 seconds
Max wait interval       : 0 forever
Command for restore     : /usr/bin/cp "/data/WAL/1P/0000000100000001000000B5" "pg_xlog/RECOVERYXLOG"
Keep archive history    : 000000000000000000000000 and later
running restore         : OK
Trigger file            : /data/WAL/1P/stopstandby
Waiting for WAL file    : 0000000100000001000000B6
WAL file path           : /data/WAL/1P/0000000100000001000000B6
Restoring to            : pg_xlog/RECOVERYXLOG
Sleep interval          : 5 seconds
Max wait interval       : 0 forever
Command for restore     : /usr/bin/cp "/data/WAL/1P/0000000100000001000000B6" "pg_xlog/RECOVERYXLOG"
Keep archive history    : 0000000100000001000000B5 and later
WAL file not present yet. Checking for trigger file...
WAL file not present yet. Checking for trigger file...
WAL file not present yet. Checking for trigger file...
WAL file not present yet. Checking for trigger file...
WAL file not present yet. Checking for trigger file...
WAL file not present yet. Checking for trigger file...
WAL file not present yet. Checking for trigger file...
WAL file not present yet. Checking for trigger file...
WAL file not present yet. Checking for trigger file...
WAL file not present yet. Checking for trigger file...

ou est-ce un message normal qui spécifie qu'il est en attente de futurs fichiers ?

Dans le log de la base, cela semble aller au mieux :

2010-05-05 14:11:06 DFTLOG:  database system was interrupted while in recovery at log time 2010-05-05 14:05:19 DFT
2010-05-05 14:11:06 DFTHINT:  If this has occurred more than once some data might be corrupted and you might need to choose
an earlier recovery target.
2010-05-05 14:11:06 DFTLOG:  starting archive recovery
2010-05-05 14:11:06 DFTLOG:  restore_command = '/opt/postgres84/bin/pg_standby -d -t /data/WAL/1P/stopstandby /data/WAL/1P %
f %p %r >> /home/postgres/scripts/LOG/WSB_POEL1P.log 2>&1'
2010-05-05 14:11:36 DFTLOG:  restored log file "0000000100000001000000B6" from archive
2010-05-05 14:11:36 DFTLOG:  automatic recovery in progress
2010-05-05 14:11:36 DFTLOG:  redo starts at 1/B6000068, consistency will be reached at 1/B7000000
2010-05-05 14:11:36 DFTLOG:  restored log file "0000000100000001000000B7" from archive
2010-05-05 14:11:36 DFTLOG:  consistent recovery state reached

Dernière modification par fadace (05/05/2010 14:13:15)

Hors ligne

#10 05/05/2010 14:17:19

Marc Cousin
Membre

Re : Log shipping et WAL/Standby

WAL file not present yet. Checking for trigger file... est normal. C'est le message d'attente d'un nouveau WAL.


Marc.

Hors ligne

#11 05/05/2010 14:19:06

gleu
Administrateur

Re : Log shipping et WAL/Standby

et là, ça semble marcher... mais c'est de loin pas très élégant...

Oui, mais ça fonctionne. En tout cas, ce n'est pas un problème de PostgreSQL ou de pg_standby.

ou est-ce un message normal qui spécifie qu'il est en attente de futurs fichiers ?

Oui, c'est normal. Il est en attente, c'est tout.


Guillaume.

Hors ligne

#12 05/05/2010 14:27:21

fadace
Membre

Re : Log shipping et WAL/Standby

Merci de votre aide

Hors ligne

#13 05/05/2010 14:34:47

Marc Cousin
Membre

Re : Log shipping et WAL/Standby

Vous devriez peut être tracer les variables d'environnement (PATH surtout) que voit pg_standby. Sous linux on peut le voir par le /proc, je ne sais pas si vous avez le même genre de choses sous AIX. Sinon il vous suffit de faire un printf de la variable dans votre code, vu que vous avez déjà commencé à le modifier.


Marc.

Hors ligne

#14 05/05/2010 16:32:22

fadace
Membre

Re : Log shipping et WAL/Standby

Encore un détail : lorsque j'exécute un touch stopstandby, ma base finit bien par s'ouvrr, et cela marche, par contre, ces messages vous dises-ils qqch ? Dois-je m'en alarmer ?

Au niveau du log ph_standby

WAL file not present yet. Checking for trigger file...
WAL file not present yet. Checking for trigger file...
WAL file not present yet. Checking for trigger file...
trigger file found: smart failover
Trigger file            : /data/WAL/1P/stopstandby
Waiting for WAL file    : 0000000100000001000000D7
WAL file path           : /data/WAL/1P/0000000100000001000000D7
Restoring to            : pg_xlog/RECOVERYXLOG
Sleep interval          : 5 seconds
Max wait interval       : 0 forever
Command for restore     : /usr/bin/cp "/data/WAL/1P/0000000100000001000000D7" "pg_xlog/RECOVERYXLOG"
Keep archive history    : 000000000000000000000000 and later
trigger file found: smart failover
running restore         : OK

Trigger file            : /data/WAL/1P/stopstandby
Waiting for WAL file    : 00000002.history
WAL file path           : /data/WAL/1P/00000002.history
Restoring to            : pg_xlog/RECOVERYHISTORY
Sleep interval          : 5 seconds
Max wait interval       : 0 forever
Command for restore     : /usr/bin/cp "/data/WAL/1P/00000002.history" "pg_xlog/RECOVERYHISTORY"
Keep archive history    : 000000000000000000000000 and later
running restore         :cp: /data/WAL/1P/00000002.history: A file or directory in the path name does no
t exist.
cp: /data/WAL/1P/00000002.history: A file or directory in the path name does not exist.
cp: /data/WAL/1P/00000002.history: A file or directory in the path name does not exist.
cp: /data/WAL/1P/00000002.history: A file or directory in the path name does not exist.
not restored
history file not found
Trigger file            : /data/WAL/1P/stopstandby
Waiting for WAL file    : 00000001.history
WAL file path           : /data/WAL/1P/00000001.history
Restoring to            : pg_xlog/RECOVERYHISTORY
Sleep interval          : 5 seconds
Max wait interval       : 0 forever
Command for restore     : /usr/bin/cp "/data/WAL/1P/00000001.history" "pg_xlog/RECOVERYHISTORY"
Keep archive history    : 000000000000000000000000 and later
running restore         :cp: /data/WAL/1P/00000001.history: A file or directory in the path name does no
t exist.
cp: /data/WAL/1P/00000001.history: A file or directory in the path name does not exist.
cp: /data/WAL/1P/00000001.history: A file or directory in the path name does not exist.
cp: /data/WAL/1P/00000001.history: A file or directory in the path name does not exist.
not restored
history file not found

Au niveau de la base

2010-05-05 16:18:54 DFTLOG:  restored log file "0000000100000001000000D6" from archive
2010-05-05 16:23:55 DFTLOG:  restored log file "0000000100000001000000D7" from archive
2010-05-05 16:25:40 DFTLOG:  could not open file "pg_xlog/0000000100000001000000D8" (log file 1, segment 216): A file or directory in the path name does not exist.
2010-05-05 16:25:40 DFTLOG:  redo done at 1/D7000068
2010-05-05 16:25:40 DFTLOG:  last completed transaction was at log time 2010-05-05 14:37:59.802477+02
2010-05-05 16:25:40 DFTLOG:  restored log file "0000000100000001000000D7" from archive
2010-05-05 16:26:10 DFTLOG:  selected new timeline ID: 2
2010-05-05 16:26:40 DFTLOG:  archive recovery complete
2010-05-05 16:26:40 DFTLOG:  database system is ready to accept connections
2010-05-05 16:26:40 DFTLOG:  autovacuum launcher started

Hors ligne

#15 05/05/2010 16:35:47

gleu
Administrateur

Re : Log shipping et WAL/Standby

Non, ces messages sont normaux. Par exemple, dans celui de PostgreSQL, il est indiqué « could not open file "pg_xlog/0000000100000001000000D8" ». Il a demandé le journal à pg_standby mais celui n'a pas pu lui fournir car il a détecté le fichier trigger avant d'avoir ce fichier. PostgreSQL, tout ce qu'il sait, c'est que pg_standby lui a renvoyé un code 1 pour lui indiquer que le fichier n'existe pas. Donc PostgreSQL l'indique dans ces logs et commence une nouvelle timeline. Rien que du normal.


Guillaume.

Hors ligne

#16 10/05/2010 10:31:27

fadace
Membre

Re : Log shipping et WAL/Standby

Ok. ça semble marcher maintenant.
J'ai par contre un cas étrange sur mon environnement de staging.
Si je contrôle la base Cible, et son journal d'alerte, j'ai un récurrent

2010-05-10 10:30:05 DFTLOG:  starting archive recovery
2010-05-10 10:30:05 DFTLOG:  restore_command = '/opt/postgres84/bin/pg_standby -d -t /data/WAL/DB1S/stopstandby /data/WAL/DB1S %f %p %r >> /home/postgres/scripts/LOG/WSB_DB1S.log 2>&1'
2010-05-10 10:30:08 DFTFATAL:  the database system is starting up
2010-05-10 10:30:08 DFTFATAL:  the database system is starting up
2010-05-10 10:30:08 DFTFATAL:  the database system is starting up
...

plutôt que l'attendu

2010-05-10 10:23:18 DFTLOG:  restored log file "000000010000003800000044" from archive

jusqu'au consistant state

Fadace

Hors ligne

#17 10/05/2010 10:55:05

gleu
Administrateur

Re : Log shipping et WAL/Standby

"FATAL:  the database system is starting up" indique simplement que quelqu'un essaie de se connecter alors que le serveur est dans la phase de restauration. Rien que du normal.


Guillaume.

Hors ligne

Pied de page des forums