@@ -2,16 +2,18 @@ pg_standby README2006/12/08 Simon Riggs
2
2
3
3
o What is pg_standby?
4
4
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.
8
10
9
11
The program is designed to be a wait-for restore_command,
10
12
required to turn a normal archive recovery into a Warm Standby.
11
13
Within the restore_command of the recovery.conf you could
12
14
configure pg_standby in the following way:
13
15
14
- restore_command = 'pg_standby archiveDir %f %p'
16
+ restore_command = 'pg_standby archiveDir %f %p %r '
15
17
16
18
which would be sufficient to define that files will be restored
17
19
from archiveDir.
@@ -42,18 +44,27 @@ o How to use pg_standby?
42
44
43
45
The basic usage should be like this:
44
46
45
- restore_command = 'pg_standby archiveDir %f %p'
47
+ restore_command = 'pg_standby archiveDir %f %p %r '
46
48
47
49
with the pg_standby command usage as
48
50
49
- pg_standby [OPTION]...[ ARCHIVELOCATION] [ NEXTWALFILE] [ XLOGFILEPATH]
51
+ pg_standby [OPTION]... ARCHIVELOCATION NEXTWALFILE XLOGFILEPATH [RESTARTWALFILE ]
50
52
51
53
When used within the restore_command the %f and %p macros
52
54
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.
53
64
54
65
o options
55
66
56
- pg_standbyhas number of options.
67
+ pg_standbyallows the following command line switches
57
68
58
69
-c
59
70
use copy/cp command to restore WAL files from archive
@@ -63,7 +74,10 @@ o options
63
74
64
75
-k numfiles
65
76
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.
67
81
68
82
You should be wary against setting this number too low,
69
83
since this may mean you cannot restart the standby. This
@@ -75,15 +89,24 @@ o options
75
89
It is wholly unrelated to the setting of checkpoint_segments
76
90
on either primary or standby.
77
91
92
+ Setting numfiles to be zero will disable deletion of files
93
+ from ARCHIVELOCATION.
94
+
78
95
If in doubt, use a large value or do not set a value at all.
79
96
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
+
80
101
-l
81
102
use ln command to restore WAL files from archive
82
103
WAL files will remain in archive
83
104
84
105
Link is more efficient, but the default is copy to
85
106
allow you to maintain the WAL archive for recovery
86
107
purposes as well as high-availability.
108
+ The default setting is not necessarily recommended,
109
+ consult the main database server manual for discussion.
87
110
88
111
This option uses the Windows Vista command mklink
89
112
to provide a file-to-file symbolic link. -l will
@@ -99,14 +122,14 @@ o options
99
122
the failure back to the database server. This will be
100
123
interpreted as and end of recovery and the Standby will come
101
124
up fully as a result.
102
- Default=3
125
+ Default=3, Min=0
103
126
104
127
-s sleeptime
105
128
the number of seconds to sleep between testing to see
106
129
if the file to be restored is available in the archive yet.
107
130
The default setting is not necessarily recommended,
108
131
consult the main database server manual for discussion.
109
- Default=5
132
+ Default=5, Min=1, Max=60
110
133
111
134
-t triggerfile
112
135
the presence of the triggerfile will cause recovery to end
@@ -119,9 +142,10 @@ o options
119
142
-w maxwaittime
120
143
the maximum number of seconds to wait for the next file,
121
144
after which recovery will end and the Standby will come up.
145
+ A setting of zero means wait forever.
122
146
The default setting is not necessarily recommended,
123
147
consult the main database server manual for discussion.
124
- Default=0
148
+ Default=0, Min=0
125
149
126
150
Note: --help is not supported since pg_standby is not intended
127
151
for interactive use, except during dev/test
@@ -148,8 +172,7 @@ o examples
148
172
Note that backslashes need to be doubled in the archive_command, but
149
173
*not* in the restore_command, in 8.2, 8.1, 8.0 on Windows.
150
174
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'
153
176
154
177
which will
155
178
- use a copy command to restore WAL files from archive
@@ -158,7 +181,26 @@ o examples
158
181
- never timeout if file not found
159
182
- stop waiting when a trigger file called C:\pgsql.trigger.5442 appears
160
183
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
+
161
197
o reported test success
162
198
163
199
SUSE Linux 10.2
164
200
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.