|
6 | 6 | </indexterm> |
7 | 7 |
|
8 | 8 | <para> |
9 | | - <literal>pg_standby</literal>is a production-ready program that can be used |
10 | | -to create a Warm Standby server.Other configuration is required as well, |
11 | | -all of which is described in themain server manual. |
| 9 | + <literal>pg_standby</literal>allows the creation of a Warm Standby server. |
| 10 | + Other configuration is required as well, all of which is described in the |
| 11 | + main server manual. |
12 | 12 | </para> |
13 | 13 | <para> |
14 | 14 | The program is designed to be a wait-for <literal>restore_command</literal>, |
|
17 | 17 | you could configure <literal>pg_standby</literal> in the following way: |
18 | 18 | </para> |
19 | 19 | <programlisting> |
20 | | -restore_command = 'pg_standby archiveDir %f %p' |
| 20 | +restore_command = 'pg_standby archiveDir %f %p %r' |
21 | 21 | </programlisting> |
22 | 22 | <para> |
23 | 23 | which would be sufficient to define that files will be restored from |
|
71 | 71 | with the pg_standby command usage as |
72 | 72 | </para> |
73 | 73 | <programlisting> |
74 | | - pg_standby [OPTION]...[ARCHIVELOCATION] [NEXTWALFILE] [XLOGFILEPATH] |
| 74 | + pg_standby [OPTION]... ARCHIVELOCATIONNEXTWALFILEXLOGFILEPATH [RESTARTWALFILE] |
75 | 75 | </programlisting> |
76 | 76 | <para> |
77 | 77 | When used within the <literal>restore_command</literal> the %f and %p macros |
78 | 78 | will provide the actual file and path required for the restore/recovery. |
79 | 79 | </para> |
| 80 | + <para> |
| 81 | + <literal>pg_standby</literal> assumes that <literal>ARCHIVELOCATION</literal> |
| 82 | + is a directory accessible by the server-owning user. |
| 83 | + </para> |
| 84 | + <para> |
| 85 | + If <literal>RESTARTWALFILE</literal> is specified, typically by using the |
| 86 | + <literal>%r</literal> option, then all files prior to this file will be |
| 87 | + removed from <literal>ARCHIVELOCATION</literal>. This then minimises the |
| 88 | + number of files that need to be held, whilst at the same time maintaining |
| 89 | + restart capability. This capability additionally assumes that |
| 90 | + <literal>ARCHIVELOCATION</literal> directory is writable. |
| 91 | + </para> |
80 | 92 |
|
81 | 93 | <table> |
82 | 94 | <title>Options</title> |
|
94 | 106 | <entry>-k numfiles</entry> |
95 | 107 | <entry> |
96 | 108 | <para> |
97 | | - Cleanup files in the archive so that we maintain no more |
98 | | - than this many files in the archive. |
| 109 | + Cleanup files in the archive so that we maintain no more than this |
| 110 | + many files in the archive. This parameter will be silently ignored if |
| 111 | + <literal>RESTARTWALFILE</literal> is specified, since that |
| 112 | + specification method is more accurate in determining the correct |
| 113 | + cut-off point in archive. |
99 | 114 | </para> |
100 | 115 | <para> |
101 | 116 | You should be wary against setting this number too low, |
|
108 | 123 | It is wholly unrelated to the setting of checkpoint_segments |
109 | 124 | on either primary or standby. |
110 | 125 | </para> |
| 126 | + <para> |
| 127 | + Setting <literal>numfiles</literal> to be zero will disable deletion |
| 128 | + of files from <literal>ARCHIVELOCATION</literal>. |
| 129 | + </para> |
111 | 130 | <para> |
112 | 131 | If in doubt, use a large value or do not set a value at all. |
113 | 132 | </para> |
| 133 | + <para> |
| 134 | + If you specify neither <literal>RESTARTWALFILE</> nor <literal>-k</>, |
| 135 | + then <literal>-k 0</> will be assumed, i.e. keep all files in archive. |
| 136 | + </para> |
114 | 137 | </entry> |
115 | 138 | </row> |
116 | 139 | <row> |
|
121 | 144 | WAL files will remain in archive |
122 | 145 | </para> |
123 | 146 | <para> |
124 | | - Link is more efficient, but the default is copy to |
125 | | - allow you to maintain the WAL archive for recovery |
126 | | - purposes as well as high-availability. |
| 147 | + Link is more efficient, but the default is copy to allow you to |
| 148 | + maintain the WAL archive for recovery purposes as well as |
| 149 | + high-availability. The default setting is not necessarily recommended, |
| 150 | + consult the main database server manual for discussion. |
127 | 151 | </para> |
128 | 152 | <para> |
129 | 153 | This option uses the Windows Vista command mklink |
|
144 | 168 | we will wait 5 secs, 10 secs then 15 secs before reporting |
145 | 169 | the failure back to the database server. This will be |
146 | 170 | interpreted as and end of recovery and the Standby will come |
147 | | - up fully as a result. <literal>Default=3</literal> |
| 171 | + up fully as a result. <literal>Default=3 Min=0</literal> |
148 | 172 | </para> |
149 | 173 | </entry> |
150 | 174 | </row> |
|
155 | 179 | if the file to be restored is available in the archive yet. |
156 | 180 | The default setting is not necessarily recommended, |
157 | 181 | consult the main database server manual for discussion. |
158 | | - <literal>Default=5</literal> |
| 182 | + <literal>Default=5, Min=1, Max=60</literal> |
159 | 183 | </entry> |
160 | 184 | </row> |
161 | 185 | <row> |
|
175 | 199 | the maximum number of seconds to wait for the next file, |
176 | 200 | after which recovery will end and the Standby will come up. |
177 | 201 | The default setting is not necessarily recommended, |
178 | | - consult the main database server manual for discussion. |
179 | | - <literal>Default=0</literal> |
| 202 | + consult the main database server manual for discussion. A setting of |
| 203 | + zero means wait forever. |
| 204 | + <literal>Default=0, Min=0</literal> |
180 | 205 | </entry> |
181 | 206 | </row> |
182 | 207 | </tbody> |
|
191 | 216 | </note> |
192 | 217 | </sect2> |
193 | 218 |
|
| 219 | + <sect2> |
| 220 | + <title>Supported versions</title> |
| 221 | + <para> |
| 222 | + <literal>pg_standby</literal> is designed to work with PostgreSQL 8.2 and |
| 223 | + and later. It is currently compatible across minor changes between the way |
| 224 | + 8.3 and 8.2 operate. |
| 225 | + </para> |
| 226 | + <para> |
| 227 | + PostgreSQL 8.3 provides the <literal>%r</literal> command line substitution, |
| 228 | + designed to let <literal>pg_standby</literal> know the last file it needs to |
| 229 | + keep. If the last parameter is omitted, no error is generated, allowing |
| 230 | + <literal>pg_standby</literal> to function correctly with PostgreSQL 8.2 |
| 231 | + also. With PostgreSQL 8.2, the <literal>-k</literal> option must be used if |
| 232 | + archive cleanup is required. This option remains available in 8.3. |
| 233 | + </para> |
| 234 | + </sect2> |
| 235 | + |
| 236 | + <sect2> |
| 237 | + <title>Additional design notes</title> |
| 238 | + <para> |
| 239 | + The use of a move command seems like it would be a good idea, but this would |
| 240 | + prevent recovery from being restartable. Also, the last WAL file is always |
| 241 | + requested twice from the archive. |
| 242 | + </para> |
| 243 | + </sect2> |
| 244 | + |
194 | 245 | <sect2> |
195 | 246 | <title>Examples</title> |
196 | 247 |
|
@@ -227,8 +278,7 @@ archive_command = 'copy %p ..\\archive\\%f' |
227 | 278 | *not* in the restore_command, in 8.2, 8.1, 8.0 on Windows. |
228 | 279 | </para> |
229 | 280 | <programlisting> |
230 | | -restore_command = 'pg_standby -c -d -s 5 -w 0 -t C:\pgsql.trigger.5442 |
231 | | - ..\archive %f %p 2>> standby.log' |
| 281 | +restore_command = 'pg_standby -c -d -s 5 -w 0 -t C:\pgsql.trigger.5442 ..\archive %f %p 2>> standby.log' |
232 | 282 | </programlisting> |
233 | 283 | <para> |
234 | 284 | which will |
|