Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf18dfc4

Browse files
committed
Minor improvements in backup and recovery:
- create a separate archive_mode GUC, on which archive_command is dependent- %r option in recovery.conf sends last restartpoint to recovery command- %r used in pg_standby, updated README- minor other code cleanup in pg_standby- doc on Warm Standby now mentions pg_standby and %r- log_restartpoints recovery option emits LOG message at each restartpoint- end of recovery now displays last transaction end time, as requested by Warren Little; also shown at each restartpoint- restart archiver if needed to carry away WAL files at shutdownSimon Riggs
1 parent8096314 commitf18dfc4

File tree

12 files changed

+356
-118
lines changed

12 files changed

+356
-118
lines changed

‎contrib/pg_standby/README.pg_standby

Lines changed: 55 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@ pg_standby README2006/12/08 Simon Riggs
22

33
o What is pg_standby?
44

5-
pg_standby is a production-ready program that can be used to
6-
create a Warm Standby server. Other configuration is required
7-
as well, all of which is described in the main server manual.
5+
pg_standby allows the creation of a Warm Standby server.
6+
It is designed to be a production-ready program, as well as a
7+
customisable template should you require specific modifications.
8+
Other configuration is required as well, all of which is
9+
described in the main server manual.
810

911
The program is designed to be a wait-for restore_command,
1012
required to turn a normal archive recovery into a Warm Standby.
1113
Within the restore_command of the recovery.conf you could
1214
configure pg_standby in the following way:
1315

14-
restore_command = 'pg_standby archiveDir %f %p'
16+
restore_command = 'pg_standby archiveDir %f %p %r'
1517

1618
which would be sufficient to define that files will be restored
1719
from archiveDir.
@@ -42,18 +44,27 @@ o How to use pg_standby?
4244

4345
The basic usage should be like this:
4446

45-
restore_command = 'pg_standby archiveDir %f %p'
47+
restore_command = 'pg_standby archiveDir %f %p %r'
4648

4749
with the pg_standby command usage as
4850

49-
pg_standby [OPTION]...[ARCHIVELOCATION] [NEXTWALFILE] [XLOGFILEPATH]
51+
pg_standby [OPTION]... ARCHIVELOCATIONNEXTWALFILEXLOGFILEPATH [RESTARTWALFILE]
5052

5153
When used within the restore_command the %f and %p macros
5254
will provide the actual file and path required for the restore/recovery.
55+
56+
pg_standby assumes that ARCHIVELOCATION is directory accessible by the
57+
server-owning user.
58+
59+
If RESTARTWALFILE is specified, typically by using the %r option, then all files
60+
prior to this file will be removed from ARCHIVELOCATION. This then minimises
61+
the number of files that need to be held, whilst at the same time maintaining
62+
restart capability. This capability additionally assumes that ARCHIVELOCATION
63+
directory is writable.
5364

5465
o options
5566

56-
pg_standbyhas number of options.
67+
pg_standbyallows the following command line switches
5768

5869
-c
5970
use copy/cp command to restore WAL files from archive
@@ -63,7 +74,10 @@ o options
6374

6475
-k numfiles
6576
Cleanup files in the archive so that we maintain no more
66-
than this many files in the archive.
77+
than this many files in the archive. This parameter will
78+
be silently ignored if RESTARTWALFILE is specified, since
79+
that specification method is more accurate in determining
80+
the correct cut-off point in archive.
6781

6882
You should be wary against setting this number too low,
6983
since this may mean you cannot restart the standby. This
@@ -75,15 +89,24 @@ o options
7589
It is wholly unrelated to the setting of checkpoint_segments
7690
on either primary or standby.
7791

92+
Setting numfiles to be zero will disable deletion of files
93+
from ARCHIVELOCATION.
94+
7895
If in doubt, use a large value or do not set a value at all.
7996

97+
If you specify neither RESTARTWALFILE nor -k, then -k 0
98+
will be assumed, i.e. keep all files in archive.
99+
Default=0, Min=0
100+
80101
-l
81102
use ln command to restore WAL files from archive
82103
WAL files will remain in archive
83104

84105
Link is more efficient, but the default is copy to
85106
allow you to maintain the WAL archive for recovery
86107
purposes as well as high-availability.
108+
The default setting is not necessarily recommended,
109+
consult the main database server manual for discussion.
87110

88111
This option uses the Windows Vista command mklink
89112
to provide a file-to-file symbolic link. -l will
@@ -99,14 +122,14 @@ o options
99122
the failure back to the database server. This will be
100123
interpreted as and end of recovery and the Standby will come
101124
up fully as a result.
102-
Default=3
125+
Default=3, Min=0
103126

104127
-s sleeptime
105128
the number of seconds to sleep between testing to see
106129
if the file to be restored is available in the archive yet.
107130
The default setting is not necessarily recommended,
108131
consult the main database server manual for discussion.
109-
Default=5
132+
Default=5, Min=1, Max=60
110133

111134
-t triggerfile
112135
the presence of the triggerfile will cause recovery to end
@@ -119,9 +142,10 @@ o options
119142
-w maxwaittime
120143
the maximum number of seconds to wait for the next file,
121144
after which recovery will end and the Standby will come up.
145+
A setting of zero means wait forever.
122146
The default setting is not necessarily recommended,
123147
consult the main database server manual for discussion.
124-
Default=0
148+
Default=0, Min=0
125149

126150
Note: --help is not supported since pg_standby is not intended
127151
for interactive use, except during dev/test
@@ -148,8 +172,7 @@ o examples
148172
Note that backslashes need to be doubled in the archive_command, but
149173
*not* in the restore_command, in 8.2, 8.1, 8.0 on Windows.
150174

151-
restore_command = 'pg_standby -c -d -s 5 -w 0 -t C:\pgsql.trigger.5442
152-
..\archive %f %p 2>> standby.log'
175+
restore_command = 'pg_standby -c -d -s 5 -w 0 -t C:\pgsql.trigger.5442 ..\archive %f %p 2>> standby.log'
153176

154177
which will
155178
- use a copy command to restore WAL files from archive
@@ -158,7 +181,26 @@ o examples
158181
- never timeout if file not found
159182
- stop waiting when a trigger file called C:\pgsql.trigger.5442 appears
160183

184+
o supported versions
185+
186+
pg_standby is designed to work with PostgreSQL 8.2 and later. It is
187+
currently compatible across minor changes between the way 8.3 and 8.2
188+
operate.
189+
190+
PostgreSQL 8.3 provides the %r command line substitution, designed to
191+
let pg_standby know the last file it needs to keep. If the last
192+
parameter is omitted, no error is generated, allowing pg_standby to
193+
function correctly with PostgreSQL 8.2 also. With PostgreSQL 8.2,
194+
the -k option must be used if archive cleanup is required. This option
195+
remains available in 8.3.
196+
161197
o reported test success
162198

163199
SUSE Linux 10.2
164200
Windows XP Pro
201+
202+
o additional design notes
203+
204+
The use of a move command seems like it would be a good idea, but
205+
this would prevent recovery from being restartable. Also, the last WAL
206+
file is always requested twice from the archive.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp