Module W2B
Dalibo SCOP
24.12
18 décembre 2024
Cette formation est sous licence CC-BY-NC-SA. Vous êtes libre de la redistribuer et/ou modifier aux conditions suivantes :
PostgreSQL® Postgres® et le logo Slonik sont des marques déposées par PostgreSQL Community Association of Canada.
Ce document ne couvre que les versions supportées de PostgreSQL au moment de sa rédaction, soit les versions 13 à 17.
pg_is_in_recovery()
-- primaire SELECT pg_wal_lsn_diff ( pg_current_wal_lsn(), '0/73D3C1F0' );
-- secondaire SELECT now() - pg_last_xact_replay_timestamp() ; -- si activité
Type de réplication & lag des secondaires :
SELECT * FROM pg_stat_replication ; -[ RECORD 1 ]----+------------------------------ pid | 286511 usesysid | 10 usename | postgres application_name | secondaire2 client_addr | 192.168.0.55 client_hostname | client_port | -1 backend_start | 2023-12-19 10:41:47.431471+01 backend_xmin | state | streaming sent_lsn | 14/C402A000 write_lsn | 14/C402A000 flush_lsn | 14/C402A000 replay_lsn | 14/C311D460 write_lag | 00:00:00.032183 flush_lag | 00:00:00.032601 replay_lag | 00:00:02.984354 sync_priority | 1 sync_state | sync reply_time | 2023-12-19 11:05:37.903584+01
pg_replication_slots
pg_stat_wal_receiver
pg_stat_archiver
pg_wal_lsn_diff()
pg_last_wal_replay_lsn()
pg_stat_database_conflicts
log_recovery_conflict_waits
wal_standby_streaming_delay
hot_standby_feedback
on
wal_receiver_status_interval
pg_wal_replay_pause()
pg_wal_replay_resume()
pg_is_wal_replay_paused()
pg_dump
En synchrone, lors d’un COMMIT :
COMMIT
# s1 synchrone, s2 en dépannage synchronous_standby_names = 'FIRST 1 (s1, s2)' # 2 synchrones au moins synchronous_standby_names = 'ANY 2 (s1,s2,s3)' # n'importe quel secondaire synchronous_standby_names = '*'
SET synchronous_commit = off / local / remote_write / on / remote_apply
archive_command
restore_command
cp
scp
lftp
rsync
archive_cleanup_command = '/usr/pgsql-14/bin/pg_archivecleanup -d rep_archives/ %r'
max_replication_slots
SELECT pg_create_physical_replication_slot ('nomsecondaire') ;
postgresql.conf
primary_slot_name = 'nomsecondaire'
max_slot_wal_keep_size
wal_level = replica
archive_mode = on
archive_library
archive_timeout
wal_sender_timeout
max_wal_senders
wal_keep_size
archive_cleanup_command
primary_conninfo
wal_receiver_timeout
hot_standby
primary_slot_name
max_standby_archive_delay
max_standby_streaming_delay
N’hésitez pas, c’est le moment !
https://dali.bo/w2b_quiz