P
P
pashtet512014-02-26 09:15:13
PostgreSQL
pashtet51, 2014-02-26 09:15:13

Why does PostgreSQL have a write delay from master to slave?

Good day!
At the moment I'm fiddling with streaming replication and along the way there are a lot of misunderstandings.
Set a goal to make a bunch of master-slave server. But not just with streaming replication, but with some delay. That is, the data should appear on the slave, for example, 30 minutes after the recording on the master. This is due to the fact that if the user messes up in the main database, it was possible to roll the backup to the state "it was 30 minutes ago", since changes in the database occur quite often, and it will be very painful to roll a daily backup, as a lot of data will be lost.
Proceeding from a task in view began to pick aside WRITE AHEAD LOG. I messed up to such an extent that I ended up confused.
What is currently available. I give separate lines of the postgresql.conf config
1. On the master:

wal_level = hot_standby
#checkpoint_segments = 16
checkpoint_timeout = 30min
archive_mode = on
archive_command = 'copy %p "path_to_wal\\%f"'
archive_timeout = 3600

max_wal_senders = 2
wal_keep_segments = 32

2. On the slave:
postgresql.conf
wal_level = hot_standby
checkpoint_timeout = 30min

max_wal_senders = 2
hot_standby = on

recovery.conf
standby_mode = on
primary_conninfo = 'host port user'
trigger_file = '%\\PostgreSQL\\9.1\\failover'
restore_command = 'copy "\\X: %f" %p'
archive_cleanup_command = '"%\\PostgreSQL\\9.1\\bin\\pg_archivecleanup" %r'

The rest of the lines in the WAL and Replication sections are commented out.
Is it possible to make a delay? If so, how?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry Guketlev, 2014-02-26
@Yavanosta

Well, you can stupidly in the forehead. Replace archive_command = 'copy %p "path_to_wal\\%f"' with archive_command = 'copy %p "path_to_temp_wal\\%f"'
Then make a script in the scheduler that will transfer archivelogs from path_to_temp_wal to path_to_wal every half hour.

P
Pilat, 2014-02-28
@Pilat

There is barman - archive log manager. It does just what you need, with some delay, and allows you to get the base for any date by simple means.

A
Alexander Korotkov, 2014-03-27
@smagen

In 9.4 it will be supported, committed to the master branch
git.postgresql.org/gitweb/?p=postgresql.git;a=comm...
And the task
now usually solved with PITR.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question