1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474
|
.\" Title: walmgr
.\" Author:
.\" Generator: DocBook XSL Stylesheets v1.73.2 <http://docbook.sf.net/>
.\" Date: 09/22/2008
.\" Manual:
.\" Source:
.\"
.TH "WALMGR" "1" "09/22/2008" "" ""
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.SH "NAME"
walmgr - tools for managing WAL-based replication for PostgreSQL.
.SH "SYNOPSIS"
.sp
.RS 4
.nf
walmgr\.py <config\.ini> command
.fi
.RE
.SH "DESCRIPTION"
It is both admin and worker script for PostgreSQL PITR replication\.
.sp
.SH "QUICK START"
.sp
.RS 4
\h'-04' 1.\h'+02'Set up passwordless ssh authentication from master to slave
.sp
.RS 4
.nf
master$ test \-f ~/\.ssh/id_dsa\.pub || ssh\-keygen \-t dsa
master$ cat ~/\.ssh/id_dsa\.pub | ssh slave cat \e>\e> \.ssh/authorized_keys
.fi
.RE
.RE
.sp
.RS 4
\h'-04' 2.\h'+02'Configure paths
.sp
.RS 4
.nf
master$ edit master\.ini
slave$ edit slave\.ini
.fi
.RE
.sp
.RS 4
.nf
Make sure that walmgr\.py executable has same pathname on slave and master\.
.fi
.RE
.RE
.sp
.RS 4
\h'-04' 3.\h'+02'Start archival process and create a base backup
.sp
.RS 4
.nf
master$ \./walmgr\.py master\.ini setup
master$ \./walmgr\.py master\.ini backup
.fi
.RE
.RE
.sp
.RS 4
\h'-04' 4.\h'+02'Prepare postgresql\.conf and pg_hba\.conf on slave and start replay
.sp
.RS 4
.nf
master$ scp $PGDATA/*\.conf slave:
slave$ \./walmgr\.py slave\.ini restore
.fi
.RE
.sp
.RS 4
.nf
For debian based distributions the standard configuration files are located
in /etc/postgresql/x\.x/main directory\. If another scheme is used the postgresql\.conf
and pg_hba\.conf should be copied to slave full_backup directory\. Make sure to
disable archive_command in slave config\.
.fi
.RE
.sp
.RS 4
.nf
\'walmgr\.py restore\' moves data in place, creates recovery\.conf and starts postmaster
in recovery mode\.
.fi
.RE
.RE
.sp
.RS 4
\h'-04' 5.\h'+02'In\-progress WAL segments can be backup by command:
.sp
.RS 4
.nf
master$ \./walmgr\.py master\.ini sync
.fi
.RE
.RE
.sp
.RS 4
\h'-04' 6.\h'+02'If need to stop replay on slave and boot into normal mode, do:
.sp
.RS 4
.nf
slave$ \./walmgr\.py slave\.ini boot
.fi
.RE
.RE
.SH "GENERAL OPTIONS"
Common options to all walmgr\.py commands\.
.PP
\-h, \-\-help
.RS 4
show this help message and exit
.RE
.PP
\-q, \-\-quiet
.RS 4
make program silent
.RE
.PP
\-v, \-\-verbose
.RS 4
make program more verbose
.RE
.PP
\-n, \-\-not\-really
.RS 4
Show what would be done without actually doing anything\.
.RE
.SH "MASTER COMMANDS"
.SS "setup"
Sets up postgres archiving, creates necessary directory structures on slave\.
.sp
.SS "sync"
Synchronizes in\-progress WAL files to slave\.
.sp
.SS "syncdaemon"
Start WAL synchronization in daemon mode\. This will start periodically synching the in\-progress WAL files to slave\.
.sp
loop_delay use_xlog_functions
.sp
.SS "stop"
Deconfigures postgres archiving\.
.sp
.SS "periodic"
Runs periodic command, if configured\. This enables to execute arbitrary commands on interval, useful for synchronizing scripts, config files, crontabs etc\.
.sp
.SS "listbackups"
List backup sets available on slave node\.
.sp
.SS "backup"
Creates a new base backup from master database\. Will purge expired backups and WAL files on slave if keep_backups is specified\. During a backup a lock file is created in slave completed_wals directory\. This is to prevent simultaneous backups and resulting corruption\. If running backup is terminated, the BACKUPLOCK file may have to be removed manually\.
.sp
.SS "restore <set> <dst>"
EXPERIMENTAL\. Attempts to restore the backup from slave to master\.
.sp
.SH "SLAVE COMMANDS"
.SS "boot"
Stop log playback and bring the database up\.
.sp
.SS "pause"
Pauses WAL playback\.
.sp
.SS "continue"
Continues previously paused WAL playback\.
.sp
.SS "listbackups"
Lists available backups\.
.sp
.SS "backup"
EXPERIMENTAL\. Creates a new backup from slave data\. Log replay is paused, slave data directory is backed up to full_backup directory and log replay resumed\. Backups are rotated as needed\. The idea is to move the backup load away from production node\. Usable from postgres 8\.2 and up\.
.sp
.SS "restore [src][dst]"
Restores the specified backup set to target directory\. If specified without arguments the latest backup is \fBmoved\fR to slave data directory (doesn\'t obey retention rules)\. If src backup is specified the backup is copied (instead of moving)\. Alternative destination directory can be specified with dst\.
.sp
.SH "CONFIGURATION"
.SS "Common settings"
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
job_name
.RS
Optional\. Indentifies this script, used in logging\. Keep unique if using central logging\.
.sp
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
logfile
.RS
Where to log\.
.sp
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
use_skylog
.RS
Optional\. If nonzero, skylog\.ini is used for log configuration\.
.sp
.RE
.SS "Master settings"
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
pidfile
.RS
Pid file location for syncdaemon mode (if running with \-d)\. Otherwise not required\.
.sp
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
master_db
.RS
Database to connect to for pg_start_backup() etc\. It is not a good idea to use dbname=template if running syncdaemon in record shipping mode\.
.sp
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
master_data
.RS
Master data directory location\.
.sp
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
master_config
.RS
Master postgresql\.conf file location\. This is where archive_command gets updated\.
.sp
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
slave
.RS
Slave host and base directory\.
.sp
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
completed_wals
.RS
Slave directory where archived WAL files are copied\.
.sp
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
partial_wals
.RS
Slave directory where incomplete WAL files are stored\.
.sp
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
full_backup
.RS
Slave directory where full backups are stored\.
.sp
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
loop_delay
.RS
The frequency of syncdaemon updates\. In record shipping mode only incremental updates are sent, so smaller interval can be used\.
.sp
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
use_xlog_functions
.RS
Use pg_xlog functions for record based shipping (available in 8\.2 and up)\.
.sp
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
compression
.RS
If nonzero, a \-z flag is added to rsync cmdline\. Will reduce network traffic at the cost of extra CPU time\.
.sp
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
periodic_command
.RS
Shell script to be executed at specified time interval\. Can be used for synchronizing scripts, config files etc\.
.sp
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
command_interval
.RS
How ofter to run periodic command script\. In seconds, and only evaluated at log switch times\.
.sp
.RE
.SS "Sample master\.ini"
.sp
.RS 4
.nf
[wal\-master]
logfile = master\.log
pidfile = master\.pid
master_db = dbname=template1
master_data = /var/lib/postgresql/8\.0/main
master_config = /etc/postgresql/8\.0/main/postgresql\.conf
slave = slave:/var/lib/postgresql/walshipping
completed_wals = %(slave)s/logs\.complete
partial_wals = %(slave)s/logs\.partial
full_backup = %(slave)s/data\.master
loop_delay = 10\.0
use_xlog_functions = 1
compression = 1
.fi
.RE
.SS "Slave settings"
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
slave_data
.RS
Postgres data directory for the slave\. This is where the restored backup is copied/moved\.
.sp
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
slave_stop_cmd
.RS
Script to stop postmaster on slave\.
.sp
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
slave_start_cmd
.RS
Script to start postmaster on slave\.
.sp
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
slave
.RS
Base directory for slave files (logs\.comlete, data\.master etc)
.sp
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
completed_wals
.RS
Directory where complete WAL files are stored\. Also miscellaneous control files are created in this directory (BACKUPLOCK, STOP, PAUSE, etc\.)\.
.sp
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
partial_wals
.RS
Directory where partial WAL files are stored\.
.sp
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
full_backup
.RS
Directory where full backups are stored\.
.sp
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
keep_backups
.RS
Number of backups to keep\. Also all WAL files needed to bring earliest
.sp
backup up to date are kept\. The backups are rotated before new backup is started, so at one point there is actually one less backup available\.
.sp
It probably doesn\'t make sense to specify keep_backups if periodic backups are not performed \- the WAL files will pile up quickly\.
.sp
Backups will be named data\.master, data\.master\.0, data\.master\.1 etc\.
.sp
.RE
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
archive_command
.RS
Script to execute before rotating away the oldest backup\. If it fails backups will not be rotated\.
.sp
.RE
.SS "Sample slave\.ini"
.sp
.RS 4
.nf
[wal\-slave]
logfile = slave\.log
slave_data = /var/lib/postgresql/8\.0/main
slave_stop_cmd = /etc/init\.d/postgresql\-8\.0 stop
slave_start_cmd = /etc/init\.d/postgresql\-8\.0 start
slave = /var/lib/postgresql/walshipping
completed_wals = %(slave)s/logs\.complete
partial_wals = %(slave)s/logs\.partial
full_backup = %(slave)s/data\.master
keep_backups = 5
.fi
.RE
|