SlideShare a Scribd company logo
1 of 114
Advanced WAL File Management
                 With OmniPITR

                 Robert Treat, JDCon 2011 #pgeast


                           / Presentation



Thursday, March 31, 2011
Who Am I?

         • Robert
Treat
               • OmniTI
                       • Database
Management
and
Consulting
                       • We’re
Hiring!
               • Postgres
                       • Major
Contributor,
Web,
Advocacy,
Random
               • xzilla.net
                       • @robtreat2


Thursday, March 31, 2011
Who Am I?

         • Robert
Treat
               • OmniTI
                       • Database
Management
and
Consulting
                       • We’re
Hiring!
               • Postgres
                       • Major
Contributor,
Web,
Advocacy,
Random
               • xzilla.net
                       • @robtreat2


Thursday, March 31, 2011
What is PITR?




Thursday, March 31, 2011
What is PITR?



                      •Postgres emits WAL files




Thursday, March 31, 2011
Digression




Thursday, March 31, 2011
Digression




                      •WAL Logs?

                      •Write Ahead Log Logs?

                      •OTOH, they are stored in pg_xlog...




Thursday, March 31, 2011
What is PITR?




Thursday, March 31, 2011
What is PITR?



                      •Postgres emits WAL files




Thursday, March 31, 2011
What is PITR?



                      •Postgres emits WAL files

                      •Send the WAL file to another server




Thursday, March 31, 2011
What is PITR?



                      •Postgres emits WAL files

                      •Send the WAL file to another server

                      •The other server can replay the WAL




Thursday, March 31, 2011
What is PITR?




                              Use combination of
                              data files and WAL
                           to make more postgrezes

Thursday, March 31, 2011
What is PITR?



                      •Postgres emits WAL files




                              Use combination of
                              data files and WAL
                           to make more postgrezes

Thursday, March 31, 2011
What is PITR?



                      •Postgres emits WAL files

                      •Send the WAL file to another server




                              Use combination of
                              data files and WAL
                           to make more postgrezes

Thursday, March 31, 2011
What is PITR?



                      •Postgres emits WAL files

                      •Send the WAL file to another server

                      •The other server can replay the WAL


                              Use combination of
                              data files and WAL
                           to make more postgrezes

Thursday, March 31, 2011
A Brief History of PITR




Thursday, March 31, 2011
A Brief History of PITR



                      •8.1 (really)




Thursday, March 31, 2011
A Brief History of PITR



                      •8.1 (really)

                      •8.2 (warm standby)




Thursday, March 31, 2011
A Brief History of PITR



                      •8.1 (really)

                      •8.2 (warm standby)

                      •9.0 (hot standby)




Thursday, March 31, 2011
A Brief History of PITR



                      •8.1 (really)

                      •8.2 (warm standby)

                      •9.0 (hot standby)

                      •9.0 (streaming replication)



Thursday, March 31, 2011
Ghetto Style




                                         archive_command =
                           'rsync %p sdb2:/data/pgsql/sdb1/84/walarchive/% f'




Thursday, March 31, 2011
Ghetto Style



                      •Simple, Better Than You’d Think




                                         archive_command =
                           'rsync %p sdb2:/data/pgsql/sdb1/84/walarchive/% f'




Thursday, March 31, 2011
Early Version Of A PITR Script


       archive_command = ‘cp -i %p /data/pgsql/82_walarchives/%f </dev/null’




Thursday, March 31, 2011
Early Version Of A PITR Script
                      •Kind of Hacky
       archive_command = ‘cp -i %p /data/pgsql/82_walarchives/%f </dev/null’




Thursday, March 31, 2011
Early Version Of A PITR Script


       archive_command = ‘cp -i %p /data/pgsql/82_walarchives/%f </dev/null’

         opendir(DIR, ".");
         my @wals2move = grep {
                    -f $_ &&
                    (stat(_))[9] + $AGE < time() &&
                      (
                          # 000000010000007200000031
                          ( /^[0-9A-F]{24}$/ && (stat(_))[7] == $WALSIZE ) ||
                          # 000000010000007200000031.0012C968.backup
                          ( /^[0-9A-F]{24}.[0-9A-F]{8}.backup$/ )
                      ) &&
                    ( $mtime{$_} = (stat(_))[9] ) # Always true (for later)
              } readdir(DIR);
         closedir(DIR);




Thursday, March 31, 2011
Early Version Of A PITR Script
                      •Kind of Hacky
       archive_command = ‘cp -i %p /data/pgsql/82_walarchives/%f </dev/null’

         opendir(DIR, ".");
         my @wals2move = grep {
                    -f $_ &&
                    (stat(_))[9] + $AGE < time() &&
                      (
                          # 000000010000007200000031
                          ( /^[0-9A-F]{24}$/ && (stat(_))[7] == $WALSIZE ) ||
                          # 000000010000007200000031.0012C968.backup
                          ( /^[0-9A-F]{24}.[0-9A-F]{8}.backup$/ )
                      ) &&
                    ( $mtime{$_} = (stat(_))[9] ) # Always true (for later)
              } readdir(DIR);
         closedir(DIR);




Thursday, March 31, 2011
Early Version Of A PITR Script


       archive_command = ‘cp -i %p /data/pgsql/82_walarchives/%f </dev/null’

      @wals2move = sort { $mtime{$a} <=> $mtime{$b} } @wals2move;
      if($TARGET) {
        foreach (@wals2move) {
          if($NOOP) {
            print "$RSYNC -essh --rsync-path=$REMOTE_RSYNC -a $_
      $TARGET/$_n";
            print "mv $_ $_.slavedn";
          } else {
            if(system("$RSYNC -essh --rsync-path=$REMOTE_RSYNC -a $_
      $TARGET/$_") != 0) {
              print STDERR "Error moving wal to target: $?n";
              last;
            }
            if(!rename("$_", "$_.slaved")) {
              print STDERR "Error renaming $_ to $_.slavedn";
              last;
            }
          }
        }
      }




Thursday, March 31, 2011
Early Version Of A PITR Script
                      •Kind of Hacky
       archive_command = ‘cp -i %p /data/pgsql/82_walarchives/%f </dev/null’

      @wals2move = sort { $mtime{$a} <=> $mtime{$b} } @wals2move;
      if($TARGET) {
        foreach (@wals2move) {
          if($NOOP) {
            print "$RSYNC -essh --rsync-path=$REMOTE_RSYNC -a $_
      $TARGET/$_n";
            print "mv $_ $_.slavedn";
          } else {
            if(system("$RSYNC -essh --rsync-path=$REMOTE_RSYNC -a $_
      $TARGET/$_") != 0) {
              print STDERR "Error moving wal to target: $?n";
              last;
            }
            if(!rename("$_", "$_.slaved")) {
              print STDERR "Error renaming $_ to $_.slavedn";
              last;
            }
          }
        }
      }




Thursday, March 31, 2011
Customizations




Thursday, March 31, 2011
Customizations



                      •Multiple Destinations




Thursday, March 31, 2011
Customizations



                      •Multiple Destinations

                      •WAL File Delay




Thursday, March 31, 2011
Customizations



                      •Multiple Destinations

                      •WAL File Delay

                      •Archive Storage (gzip & friends)




Thursday, March 31, 2011
Customizations



                      •Multiple Destinations

                      •WAL File Delay

                      •Archive Storage (gzip & friends)

                      •Better Backups



Thursday, March 31, 2011
ENTER: OmniPITR




Thursday, March 31, 2011
ENTER: OmniPITR



                      •Consolidate various scripts




Thursday, March 31, 2011
ENTER: OmniPITR



                      •Consolidate various scripts

                      •Deploy across ‘Nixes




Thursday, March 31, 2011
ENTER: OmniPITR



                      •Consolidate various scripts

                      •Deploy across ‘Nixes

                      •Reusable




Thursday, March 31, 2011
ENTER: OmniPITR



                      •Consolidate various scripts

                      •Deploy across ‘Nixes

                      •Reusable

                      •Complete Solution



Thursday, March 31, 2011
OmniPITR-Archive




Thursday, March 31, 2011
OmniPITR-Archive


                      •Lots of options




Thursday, March 31, 2011
OmniPITR-Archive


                      •Lots of options

                           •compression




Thursday, March 31, 2011
OmniPITR-Archive


                      •Lots of options

                           •compression

                           •custom log file




Thursday, March 31, 2011
OmniPITR-Archive


                      •Lots of options

                           •compression

                           •custom log file

                           •special paths




Thursday, March 31, 2011
OmniPITR-Archive


                      •Lots of options

                           •compression

                           •custom log file

                           •special paths

                           •multiple destinations


Thursday, March 31, 2011
OmniPITR-Archive Example

                                     archive_command =
                            '/opt/OMNIpitr/bin/omnipitr-archive
                       -l "/var/log/omnipitr/omnipitr-^Y-^m-^d.log"
                               -s /var/lib/pgsql/omnipitr/state/
                                          -t /var/tmp/
                          -dr gzip=db4:/mnt/db/prod/walarchive/
                           -dr db4:/mnt/db/prod/db4-walarchive/
                          -db /var/lib/pgsql/omnipitr/backup.xlogs
                                              "%p"'




Thursday, March 31, 2011
OmniPITR-Archive Example

                                     archive_command =
                            '/opt/OMNIpitr/bin/omnipitr-archive
                       -l "/var/log/omnipitr/omnipitr-^Y-^m-^d.log"
                               -s /var/lib/pgsql/omnipitr/state/
                                          -t /var/tmp/
                          -dr gzip=db4:/mnt/db/prod/walarchive/
                           -dr db4:/mnt/db/prod/db4-walarchive/
                          -db /var/lib/pgsql/omnipitr/backup.xlogs
                                              "%p"'

                                 Location of OmniPITR

Thursday, March 31, 2011
OmniPITR-Archive Example

                                     archive_command =
                            '/opt/OMNIpitr/bin/omnipitr-archive
                       -l "/var/log/omnipitr/omnipitr-^Y-^m-^d.log"
                               -s /var/lib/pgsql/omnipitr/state/
                                          -t /var/tmp/
                          -dr gzip=db4:/mnt/db/prod/walarchive/
                           -dr db4:/mnt/db/prod/db4-walarchive/
                          -db /var/lib/pgsql/omnipitr/backup.xlogs
                                              "%p"'

                            Custom Log File Name/Location

Thursday, March 31, 2011
OmniPITR-Archive Example

                                     archive_command =
                            '/opt/OMNIpitr/bin/omnipitr-archive
                       -l "/var/log/omnipitr/omnipitr-^Y-^m-^d.log"
                               -s /var/lib/pgsql/omnipitr/state/
                                          -t /var/tmp/
                          -dr gzip=db4:/mnt/db/prod/walarchive/
                           -dr db4:/mnt/db/prod/db4-walarchive/
                          -db /var/lib/pgsql/omnipitr/backup.xlogs
                                              "%p"'

        state-directory to handle errors when sending wal to
                         multiple destinations

Thursday, March 31, 2011
OmniPITR-Archive Example

                                     archive_command =
                            '/opt/OMNIpitr/bin/omnipitr-archive
                       -l "/var/log/omnipitr/omnipitr-^Y-^m-^d.log"
                               -s /var/lib/pgsql/omnipitr/state/
                                          -t /var/tmp/
                          -dr gzip=db4:/mnt/db/prod/walarchive/
                           -dr db4:/mnt/db/prod/db4-walarchive/
                          -db /var/lib/pgsql/omnipitr/backup.xlogs
                                              "%p"'

                              Where To Create Temp Files

Thursday, March 31, 2011
OmniPITR-Archive Example

                                     archive_command =
                            '/opt/OMNIpitr/bin/omnipitr-archive
                       -l "/var/log/omnipitr/omnipitr-^Y-^m-^d.log"
                               -s /var/lib/pgsql/omnipitr/state/
                                          -t /var/tmp/
                          -dr gzip=dbx:/mnt/db/prod/walstorage/
                           -dr db4:/mnt/db/prod/db4-walarchive/
                          -db /var/lib/pgsql/omnipitr/backup.xlogs
                                              "%p"'

                 send to remote server (dbx) compressed (gzip)

Thursday, March 31, 2011
OmniPITR-Archive Example

                                     archive_command =
                            '/opt/OMNIpitr/bin/omnipitr-archive
                       -l "/var/log/omnipitr/omnipitr-^Y-^m-^d.log"
                               -s /var/lib/pgsql/omnipitr/state/
                                          -t /var/tmp/
                          -dr gzip=db4:/mnt/db/prod/walarchive/
                           -dr db4:/mnt/db/prod/db4-walarchive/
                          -db /var/lib/pgsql/omnipitr/backup.xlogs
                                              "%p"'

                      send to remote server (db4) uncompressed

Thursday, March 31, 2011
OmniPITR-Archive Example

                                     archive_command =
                            '/opt/OMNIpitr/bin/omnipitr-archive
                       -l "/var/log/omnipitr/omnipitr-^Y-^m-^d.log"
                               -s /var/lib/pgsql/omnipitr/state/
                                          -t /var/tmp/
                          -dr gzip=db4:/mnt/db/prod/walarchive/
                           -dr db4:/mnt/db/prod/db4-walarchive/
                          -db /var/lib/pgsql/omnipitr/backup.xlogs
                                              "%p"'

                   Where to store xlogs when building a backup

Thursday, March 31, 2011
OmniPITR-Archive Example

                                     archive_command =
                            '/opt/OMNIpitr/bin/omnipitr-archive
                       -l "/var/log/omnipitr/omnipitr-^Y-^m-^d.log"
                               -s /var/lib/pgsql/omnipitr/state/
                                          -t /var/tmp/
                          -dr gzip=db4:/mnt/db/prod/walarchive/
                           -dr db4:/mnt/db/prod/db4-walarchive/
                          -db /var/lib/pgsql/omnipitr/backup.xlogs
                                              "%p"'

                                     The xlog file :-)

Thursday, March 31, 2011
OmniPITR-Restore




Thursday, March 31, 2011
OmniPITR-Restore


                      •Lots of options (though not as many)




Thursday, March 31, 2011
OmniPITR-Restore


                      •Lots of options (though not as many)

                           •compressed files?




Thursday, March 31, 2011
OmniPITR-Restore


                      •Lots of options (though not as many)

                           •compressed files?

                           •custom log file




Thursday, March 31, 2011
OmniPITR-Restore


                      •Lots of options (though not as many)

                           •compressed files?

                           •custom log file

                           •special paths




Thursday, March 31, 2011
OmniPITR-Restore Example

                               restore_command = '
                       /opt/OMNIpitr/bin/omnipitr-restore
              -l /var/lib/pgsql/data/pg_log/omnipitr-^Y-^m-^d.log
                           -s /var/lib/pgsql/wal_archive/
                        -p /var/lib/pgsql/wal_archives.pause
                                          -v
                                          -r
                                        %f %p'


                           location of omnipitr-restore program

Thursday, March 31, 2011
OmniPITR-Restore Example

                               restore_command = '
                       /opt/OMNIpitr/bin/omnipitr-restore
              -l /var/lib/pgsql/data/pg_log/omnipitr-^Y-^m-^d.log
                           -s /var/lib/pgsql/wal_archive/
                        -p /var/lib/pgsql/wal_archives.pause
                                          -v
                                          -r
                                        %f %p'


                               custom log file format

Thursday, March 31, 2011
OmniPITR-Restore Example

                               restore_command = '
                       /opt/OMNIpitr/bin/omnipitr-restore
              -l /var/lib/pgsql/data/pg_log/omnipitr-^Y-^m-^d.log
                           -s /var/lib/pgsql/wal_archive/
                        -p /var/lib/pgsql/wal_archives.pause
                                          -v
                                          -r
                                        %f %p'


                           Source of WAL Files to Use For Restore

Thursday, March 31, 2011
OmniPITR-Restore Example

                               restore_command = '
                       /opt/OMNIpitr/bin/omnipitr-restore
              -l /var/lib/pgsql/data/pg_log/omnipitr-^Y-^m-^d.log
                           -s /var/lib/pgsql/wal_archive/
                        -p /var/lib/pgsql/wal_archives.pause
                                          -v
                                          -r
                                        %f %p'


                           pause xlog removal if this file exists
                                      (foreshadow: used for making backups)




Thursday, March 31, 2011
OmniPITR-Restore Example

                               restore_command = '
                       /opt/OMNIpitr/bin/omnipitr-restore
              -l /var/lib/pgsql/data/pg_log/omnipitr-^Y-^m-^d.log
                           -s /var/lib/pgsql/wal_archive/
                        -p /var/lib/pgsql/wal_archives.pause
                                          -v
                                          -r
                                        %f %p'


                                     verbose

Thursday, March 31, 2011
OmniPITR-Restore Example

                               restore_command = '
                       /opt/OMNIpitr/bin/omnipitr-restore
              -l /var/lib/pgsql/data/pg_log/omnipitr-^Y-^m-^d.log
                           -s /var/lib/pgsql/wal_archive/
                        -p /var/lib/pgsql/wal_archives.pause
                                          -v
                                          -r
                                        %f %p'


           Remove Xlogs Files Which Are No Longer Needed

Thursday, March 31, 2011
OmniPITR-Restore Example

                               restore_command = '
                       /opt/OMNIpitr/bin/omnipitr-restore
              -l /var/lib/pgsql/data/pg_log/omnipitr-^Y-^m-^d.log
                           -s /var/lib/pgsql/wal_archive/
                        -p /var/lib/pgsql/wal_archives.pause
                                          -v
                                          -r
                                        %f %p'

               standard macros for “basename of segment” and
                         “destination of recovery”

Thursday, March 31, 2011
OmniPITR-Master-Backup




Thursday, March 31, 2011
OmniPITR-Master-Backup



                      •Goal




Thursday, March 31, 2011
OmniPITR-Master-Backup



                      •Goal

                           •simple “tarball” for backup




Thursday, March 31, 2011
OmniPITR-Master-Backup



                      •Goal

                           •simple “tarball” for backup

                             •one for $PGDATA and xlogs




Thursday, March 31, 2011
OmniPITR-Master-Backup



                      •Goal

                           •simple “tarball” for backup

                             •one for $PGDATA and xlogs

                             •simple to blow open and use



Thursday, March 31, 2011
OmniPITR-Master-Backup Example

                       /opt/OMNIpitr/bin/omnipitr-backup-master
                                                -v
                       -l "/var/log/omnipitr/omnipitr-^Y-^m-^d.log"
                           -x /var/lib/pgsql/omnipitr/backup.xlogs
                            -dr gzip=db4:/mnt/db/prod/backups/
                                          -t /var/tmp/
                                  -pp /usr/pgsql-9.0/bin/psql
                                      -D /pg_data/90data


                           location of OmniPITR-backup-master

Thursday, March 31, 2011
OmniPITR-Master-Backup Example

                       /opt/OMNIpitr/bin/omnipitr-backup-master
                                                -v
                       -l "/var/log/omnipitr/omnipitr-^Y-^m-^d.log"
                           -x /var/lib/pgsql/omnipitr/backup.xlogs
                            -dr gzip=db4:/mnt/db/prod/backups/
                                          -t /var/tmp/
                                  -pp /usr/pgsql-9.0/bin/psql
                                      -D /pg_data/90data


                                        verbose

Thursday, March 31, 2011
OmniPITR-Master-Backup Example

                       /opt/OMNIpitr/bin/omnipitr-backup-master
                                                -v
                       -l "/var/log/omnipitr/omnipitr-^Y-^m-^d.log"
                           -x /var/lib/pgsql/omnipitr/backup.xlogs
                            -dr gzip=db4:/mnt/db/prod/backups/
                                          -t /var/tmp/
                                  -pp /usr/pgsql-9.0/bin/psql
                                      -D /pg_data/90data


                                     custom log file

Thursday, March 31, 2011
OmniPITR-Master-Backup Example

                       /opt/OMNIpitr/bin/omnipitr-backup-master
                                                -v
                       -l "/var/log/omnipitr/omnipitr-^Y-^m-^d.log"
                           -x /var/lib/pgsql/omnipitr/backup.xlogs
                            -dr gzip=db4:/mnt/db/prod/backups/
                                          -t /var/tmp/
                                  -pp /usr/pgsql-9.0/bin/psql
                                      -D /pg_data/90data


                directory to store xlogs during backup creation

Thursday, March 31, 2011
OmniPITR-Master-Backup Example

                       /opt/OMNIpitr/bin/omnipitr-backup-master
                                                -v
                       -l "/var/log/omnipitr/omnipitr-^Y-^m-^d.log"
                           -x /var/lib/pgsql/omnipitr/backup.xlogs
                            -dr gzip=db4:/mnt/db/prod/backups/
                                          -t /var/tmp/
                                  -pp /usr/pgsql-9.0/bin/psql
                                      -D /pg_data/90data


                  copy backup file to remote server, compressed

Thursday, March 31, 2011
OmniPITR-Master-Backup Example

                       /opt/OMNIpitr/bin/omnipitr-backup-master
                                                -v
                       -l "/var/log/omnipitr/omnipitr-^Y-^m-^d.log"
                           -x /var/lib/pgsql/omnipitr/backup.xlogs
                            -dr gzip=db4:/mnt/db/prod/backups/
                                          -t /var/tmp/
                                  -pp /usr/pgsql-9.0/bin/psql
                                      -D /pg_data/90data


                       location for temporary files whilst working

Thursday, March 31, 2011
OmniPITR-Master-Backup Example

                       /opt/OMNIpitr/bin/omnipitr-backup-master
                                                -v
                       -l "/var/log/omnipitr/omnipitr-^Y-^m-^d.log"
                           -x /var/lib/pgsql/omnipitr/backup.xlogs
                            -dr gzip=db4:/mnt/db/prod/backups/
                                          -t /var/tmp/
                                  -pp /usr/pgsql-9.0/bin/psql
                                      -D /pg_data/90data


                                      path to psql

Thursday, March 31, 2011
OmniPITR-Master-Backup Example

                       /opt/OMNIpitr/bin/omnipitr-backup-master
                                                -v
                       -l "/var/log/omnipitr/omnipitr-^Y-^m-^d.log"
                           -x /var/lib/pgsql/omnipitr/backup.xlogs
                            -dr gzip=db4:/mnt/db/prod/backups/
                                          -t /var/tmp/
                                  -pp /usr/pgsql-9.0/bin/psql
                                      -D /pg_data/90data


                                       $PGDATA

Thursday, March 31, 2011
Programmers Say:




                           “I love it when people use
                           my software to do cool
                           things that I didn’t expect”




Thursday, March 31, 2011
Treat’s Maxim?




                             “Try not to let the way
                           software was designed get
                             in the way of how you
                                 want to use it”




Thursday, March 31, 2011
OmniPITR-Slave-Backup




Thursday, March 31, 2011
OmniPITR-Slave-Backup

                      •On MySQL, you could dump on slave
                       for a long time




Thursday, March 31, 2011
OmniPITR-Slave-Backup

                      •On MySQL, you could dump on slave
                       for a long time

                      •On ZFS, we use snapshots to make
                       slaves on the backups




Thursday, March 31, 2011
OmniPITR-Slave-Backup

                      •On MySQL, you could dump on slave
                       for a long time

                      •On ZFS, we use snapshots to make
                       slaves on the backups

                      •While “we” prefer to use Postgres,
                       some of us prefer to use Linux




Thursday, March 31, 2011
OmniPITR-Slave-Backup

                      •On MySQL, you could dump on slave
                       for a long time

                      •On ZFS, we use snapshots to make
                       slaves on the backups

                      •While “we” prefer to use Postgres,
                       some of us prefer to use Linux

                      •But, you still don’t want to pay the
                       price for backups on master

Thursday, March 31, 2011
OmniPITR-Slave-Backup Example

             /opt/OMNIpitr/bin/omnipitr-backup-slave
                                    -v
   -l "/var/log/omnipitr/omnipitr-slave-backup-^Y-^m-^d.log"
                   -s /mnt/db/prod/db4-walarchive
              -p /var/lib/pgsql/omnipitr/pause.removal
                          -D /pg_data/90data/
                              -t /var/tmp/
                            -gp /usr/bin/pigz
                   -dl gzip=/mnt/db/prod/backups/
               -pp /usr/pgsql-9.0/bin/pg_controldata

                           Location of omni-pitr-slave command

Thursday, March 31, 2011
OmniPITR-Slave-Backup Example

             /opt/OMNIpitr/bin/omnipitr-backup-slave
                                    -v
   -l "/var/log/omnipitr/omnipitr-slave-backup-^Y-^m-^d.log"
                   -s /mnt/db/prod/db4-walarchive
              -p /var/lib/pgsql/omnipitr/pause.removal
                          -D /pg_data/90data/
                              -t /var/tmp/
                            -gp /usr/bin/pigz
                   -dl gzip=/mnt/db/prod/backups/
               -pp /usr/pgsql-9.0/bin/pg_controldata

                              verbose

Thursday, March 31, 2011
OmniPITR-Slave-Backup Example

             /opt/OMNIpitr/bin/omnipitr-backup-slave
                                    -v
   -l "/var/log/omnipitr/omnipitr-slave-backup-^Y-^m-^d.log"
                   -s /mnt/db/prod/db4-walarchive
              -p /var/lib/pgsql/omnipitr/pause.removal
                          -D /pg_data/90data/
                              -t /var/tmp/
                            -gp /usr/bin/pigz
                   -dl gzip=/mnt/db/prod/backups/
               -pp /usr/pgsql-9.0/bin/pg_controldata

                           custom log location / format

Thursday, March 31, 2011
OmniPITR-Slave-Backup Example

             /opt/OMNIpitr/bin/omnipitr-backup-slave
                                    -v
   -l "/var/log/omnipitr/omnipitr-slave-backup-^Y-^m-^d.log"
                   -s /mnt/db/prod/db4-walarchive
              -p /var/lib/pgsql/omnipitr/pause.removal
                          -D /pg_data/90data/
                              -t /var/tmp/
                            -gp /usr/bin/pigz
                   -dl gzip=/mnt/db/prod/backups/
               -pp /usr/pgsql-9.0/bin/pg_controldata

                           source of wal files

Thursday, March 31, 2011
OmniPITR-Slave-Backup Example

             /opt/OMNIpitr/bin/omnipitr-backup-slave
                                    -v
   -l "/var/log/omnipitr/omnipitr-slave-backup-^Y-^m-^d.log"
                   -s /mnt/db/prod/db4-walarchive
              -p /var/lib/pgsql/omnipitr/pause.removal
                          -D /pg_data/90data/
                              -t /var/tmp/
                            -gp /usr/bin/pigz
                   -dl gzip=/mnt/db/prod/backups/
               -pp /usr/pgsql-9.0/bin/pg_controldata
              file to pause removal of xlogs no longer needed for
                       restore but still needed by backup

Thursday, March 31, 2011
OmniPITR-Slave-Backup Example

             /opt/OMNIpitr/bin/omnipitr-backup-slave
                                    -v
   -l "/var/log/omnipitr/omnipitr-slave-backup-^Y-^m-^d.log"
                   -s /mnt/db/prod/db4-walarchive
              -p /var/lib/pgsql/omnipitr/pause.removal
                          -D /pg_data/90data/
                              -t /var/tmp/
                            -gp /usr/bin/pigz
                   -dl gzip=/mnt/db/prod/backups/
               -pp /usr/pgsql-9.0/bin/pg_controldata

                             $PGDATA

Thursday, March 31, 2011
OmniPITR-Slave-Backup Example

             /opt/OMNIpitr/bin/omnipitr-backup-slave
                                    -v
   -l "/var/log/omnipitr/omnipitr-slave-backup-^Y-^m-^d.log"
                   -s /mnt/db/prod/db4-walarchive
              -p /var/lib/pgsql/omnipitr/pause.removal
                          -D /pg_data/90data/
                              -t /var/tmp/
                            -gp /usr/bin/pigz
                   -dl gzip=/mnt/db/prod/backups/
               -pp /usr/pgsql-9.0/bin/pg_controldata

                           location for temp files whilst working

Thursday, March 31, 2011
OmniPITR-Slave-Backup Example

             /opt/OMNIpitr/bin/omnipitr-backup-slave
                                    -v
   -l "/var/log/omnipitr/omnipitr-slave-backup-^Y-^m-^d.log"
                   -s /mnt/db/prod/db4-walarchive
              -p /var/lib/pgsql/omnipitr/pause.removal
                          -D /pg_data/90data/
                              -t /var/tmp/
                            -gp /usr/bin/pigz
                   -dl gzip=/mnt/db/prod/backups/
               -pp /usr/pgsql-9.0/bin/pg_controldata

                           location of our “gzip”

Thursday, March 31, 2011
OmniPITR-Slave-Backup Example

             /opt/OMNIpitr/bin/omnipitr-backup-slave
                                    -v
   -l "/var/log/omnipitr/omnipitr-slave-backup-^Y-^m-^d.log"
                   -s /mnt/db/prod/db4-walarchive
              -p /var/lib/pgsql/omnipitr/pause.removal
                          -D /pg_data/90data/
                              -t /var/tmp/
                            -gp /usr/bin/pigz
                   -dl gzip=/mnt/db/prod/backups/
               -pp /usr/pgsql-9.0/bin/pg_controldata

                           local storage, compressed

Thursday, March 31, 2011
OmniPITR-Slave-Backup Example

             /opt/OMNIpitr/bin/omnipitr-backup-slave
                                    -v
   -l "/var/log/omnipitr/omnipitr-slave-backup-^Y-^m-^d.log"
                   -s /mnt/db/prod/db4-walarchive
              -p /var/lib/pgsql/omnipitr/pause.removal
                          -D /pg_data/90data/
                              -t /var/tmp/
                            -gp /usr/bin/pigz
                   -dl gzip=/mnt/db/prod/backups/
               -pp /usr/pgsql-9.0/bin/pg_controldata

                           path to pg_controldata

Thursday, March 31, 2011
Production Use?




Thursday, March 31, 2011
Production Use?

                      •Versions 8.2, 8.3, 8.4, 9.0




Thursday, March 31, 2011
Production Use?

                      •Versions 8.2, 8.3, 8.4, 9.0

                      •Linux, Solaris




Thursday, March 31, 2011
Production Use?

                      •Versions 8.2, 8.3, 8.4, 9.0

                      •Linux, Solaris

                      •TB+ Databases, with multiple
                       tablespaces




Thursday, March 31, 2011
Production Use?

                      •Versions 8.2, 8.3, 8.4, 9.0

                      •Linux, Solaris

                      •TB+ Databases, with multiple
                       tablespaces

                      •Thousands of txn/sec




Thursday, March 31, 2011
Production Use?

                      •Versions 8.2, 8.3, 8.4, 9.0

                      •Linux, Solaris

                      •TB+ Databases, with multiple
                       tablespaces

                      •Thousands of txn/sec

                      •Cross Datacenter


Thursday, March 31, 2011
Where’s The Code?




                           https://labs.omniti.com/labs/pgtreats

          svn co https://labs.omniti.com/pgtreats/trunk/omnipitr/


Thursday, March 31, 2011
Where’s The Code?

                      •Currently in “PGTreats” Repo




                           https://labs.omniti.com/labs/pgtreats

          svn co https://labs.omniti.com/pgtreats/trunk/omnipitr/


Thursday, March 31, 2011
Where’s The Code?

                      •Currently in “PGTreats” Repo

                      •Available Via SVN Pull




                           https://labs.omniti.com/labs/pgtreats

          svn co https://labs.omniti.com/pgtreats/trunk/omnipitr/


Thursday, March 31, 2011
Where’s The Code?

                      •Currently in “PGTreats” Repo

                      •Available Via SVN Pull

                      •“BSD” Licensed


                           https://labs.omniti.com/labs/pgtreats

          svn co https://labs.omniti.com/pgtreats/trunk/omnipitr/


Thursday, March 31, 2011
TODO




Thursday, March 31, 2011
TODO

                      •Better Monitoring




Thursday, March 31, 2011
TODO

                      •Better Monitoring

                      •Parallel Multi-Destination




Thursday, March 31, 2011
TODO

                      •Better Monitoring

                      •Parallel Multi-Destination

                      •Multiple-Source Restores




Thursday, March 31, 2011
BUGS

                           Failover of a streaming replication
                           based slave created from a slave
                           based backup file against a stream
                           replication based slave doesn’t
                           work




Thursday, March 31, 2011
BUGS

                           Failover of a streaming replication
                           based slave created from a slave
                           based backup file against a stream
                           replication based slave doesn’t
                           work, sometimes,




Thursday, March 31, 2011
BUGS

                           Failover of a streaming replication
                           based slave created from a slave
                           based backup file against a stream
                           replication based slave doesn’t
                           work, sometimes, when under load




Thursday, March 31, 2011
BUGS

                           Failover of a streaming replication
                           based slave created from a slave
                           based backup file against a stream
                           replication based slave doesn’t
                           work, sometimes, when under load


                               We think it’s a flaw in Postgres,
                                 but hard to say for sure



Thursday, March 31, 2011
THE END




                                 Thanks!
                              pgeast, pgus


                                   Slides
                              http://www.xzilla.net/




Thursday, March 31, 2011

More Related Content

Viewers also liked

Database Scalability Patterns
Database Scalability PatternsDatabase Scalability Patterns
Database Scalability PatternsRobert Treat
 
A Guide To PostgreSQL 9.0
A Guide To PostgreSQL 9.0A Guide To PostgreSQL 9.0
A Guide To PostgreSQL 9.0Robert Treat
 
What Ops Can Learn From Design
What Ops Can Learn From DesignWhat Ops Can Learn From Design
What Ops Can Learn From DesignRobert Treat
 
Postgres 9.4 First Look
Postgres 9.4 First LookPostgres 9.4 First Look
Postgres 9.4 First LookRobert Treat
 
Less Alarming Alerts - SRECon 2016
Less Alarming Alerts - SRECon 2016 Less Alarming Alerts - SRECon 2016
Less Alarming Alerts - SRECon 2016 Robert Treat
 
plProxy, pgBouncer, pgBalancer
plProxy, pgBouncer, pgBalancerplProxy, pgBouncer, pgBalancer
plProxy, pgBouncer, pgBalancerelliando dias
 
Managing Databases In A DevOps Environment
Managing Databases In A DevOps EnvironmentManaging Databases In A DevOps Environment
Managing Databases In A DevOps EnvironmentRobert Treat
 
Managing Databases In A DevOps Environment 2016
Managing Databases In A DevOps Environment 2016Managing Databases In A DevOps Environment 2016
Managing Databases In A DevOps Environment 2016Robert Treat
 
Out of the box replication in postgres 9.4
Out of the box replication in postgres 9.4Out of the box replication in postgres 9.4
Out of the box replication in postgres 9.4Denish Patel
 
Best Practices for a Complete Postgres Enterprise Architecture Setup
Best Practices for a Complete Postgres Enterprise Architecture SetupBest Practices for a Complete Postgres Enterprise Architecture Setup
Best Practices for a Complete Postgres Enterprise Architecture SetupEDB
 
Managing PostgreSQL with PgCenter
Managing PostgreSQL with PgCenterManaging PostgreSQL with PgCenter
Managing PostgreSQL with PgCenterAlexey Lesovsky
 
The Magic of Tuning in PostgreSQL
The Magic of Tuning in PostgreSQLThe Magic of Tuning in PostgreSQL
The Magic of Tuning in PostgreSQLAshnikbiz
 
PostgreSQL performance improvements in 9.5 and 9.6
PostgreSQL performance improvements in 9.5 and 9.6PostgreSQL performance improvements in 9.5 and 9.6
PostgreSQL performance improvements in 9.5 and 9.6Tomas Vondra
 
PostgreSQL Administration for System Administrators
PostgreSQL Administration for System AdministratorsPostgreSQL Administration for System Administrators
PostgreSQL Administration for System AdministratorsCommand Prompt., Inc
 
PostgreSQL 9.6 Performance-Scalability Improvements
PostgreSQL 9.6 Performance-Scalability ImprovementsPostgreSQL 9.6 Performance-Scalability Improvements
PostgreSQL 9.6 Performance-Scalability ImprovementsPGConf APAC
 
PostgreSQL Performance Tables Partitioning vs. Aggregated Data Tables
PostgreSQL Performance Tables Partitioning vs. Aggregated Data TablesPostgreSQL Performance Tables Partitioning vs. Aggregated Data Tables
PostgreSQL Performance Tables Partitioning vs. Aggregated Data TablesSperasoft
 
Mastering PostgreSQL Administration
Mastering PostgreSQL AdministrationMastering PostgreSQL Administration
Mastering PostgreSQL AdministrationEDB
 
Best Practices for Becoming an Exceptional Postgres DBA
Best Practices for Becoming an Exceptional Postgres DBA Best Practices for Becoming an Exceptional Postgres DBA
Best Practices for Becoming an Exceptional Postgres DBA EDB
 
Postgres in Production - Best Practices 2014
Postgres in Production - Best Practices 2014Postgres in Production - Best Practices 2014
Postgres in Production - Best Practices 2014EDB
 

Viewers also liked (20)

Database Scalability Patterns
Database Scalability PatternsDatabase Scalability Patterns
Database Scalability Patterns
 
A Guide To PostgreSQL 9.0
A Guide To PostgreSQL 9.0A Guide To PostgreSQL 9.0
A Guide To PostgreSQL 9.0
 
What Ops Can Learn From Design
What Ops Can Learn From DesignWhat Ops Can Learn From Design
What Ops Can Learn From Design
 
Postgres 9.4 First Look
Postgres 9.4 First LookPostgres 9.4 First Look
Postgres 9.4 First Look
 
Less Alarming Alerts - SRECon 2016
Less Alarming Alerts - SRECon 2016 Less Alarming Alerts - SRECon 2016
Less Alarming Alerts - SRECon 2016
 
plProxy, pgBouncer, pgBalancer
plProxy, pgBouncer, pgBalancerplProxy, pgBouncer, pgBalancer
plProxy, pgBouncer, pgBalancer
 
Managing Databases In A DevOps Environment
Managing Databases In A DevOps EnvironmentManaging Databases In A DevOps Environment
Managing Databases In A DevOps Environment
 
Managing Databases In A DevOps Environment 2016
Managing Databases In A DevOps Environment 2016Managing Databases In A DevOps Environment 2016
Managing Databases In A DevOps Environment 2016
 
Pro Postgres 9
Pro Postgres 9Pro Postgres 9
Pro Postgres 9
 
Out of the box replication in postgres 9.4
Out of the box replication in postgres 9.4Out of the box replication in postgres 9.4
Out of the box replication in postgres 9.4
 
Best Practices for a Complete Postgres Enterprise Architecture Setup
Best Practices for a Complete Postgres Enterprise Architecture SetupBest Practices for a Complete Postgres Enterprise Architecture Setup
Best Practices for a Complete Postgres Enterprise Architecture Setup
 
Managing PostgreSQL with PgCenter
Managing PostgreSQL with PgCenterManaging PostgreSQL with PgCenter
Managing PostgreSQL with PgCenter
 
The Magic of Tuning in PostgreSQL
The Magic of Tuning in PostgreSQLThe Magic of Tuning in PostgreSQL
The Magic of Tuning in PostgreSQL
 
PostgreSQL performance improvements in 9.5 and 9.6
PostgreSQL performance improvements in 9.5 and 9.6PostgreSQL performance improvements in 9.5 and 9.6
PostgreSQL performance improvements in 9.5 and 9.6
 
PostgreSQL Administration for System Administrators
PostgreSQL Administration for System AdministratorsPostgreSQL Administration for System Administrators
PostgreSQL Administration for System Administrators
 
PostgreSQL 9.6 Performance-Scalability Improvements
PostgreSQL 9.6 Performance-Scalability ImprovementsPostgreSQL 9.6 Performance-Scalability Improvements
PostgreSQL 9.6 Performance-Scalability Improvements
 
PostgreSQL Performance Tables Partitioning vs. Aggregated Data Tables
PostgreSQL Performance Tables Partitioning vs. Aggregated Data TablesPostgreSQL Performance Tables Partitioning vs. Aggregated Data Tables
PostgreSQL Performance Tables Partitioning vs. Aggregated Data Tables
 
Mastering PostgreSQL Administration
Mastering PostgreSQL AdministrationMastering PostgreSQL Administration
Mastering PostgreSQL Administration
 
Best Practices for Becoming an Exceptional Postgres DBA
Best Practices for Becoming an Exceptional Postgres DBA Best Practices for Becoming an Exceptional Postgres DBA
Best Practices for Becoming an Exceptional Postgres DBA
 
Postgres in Production - Best Practices 2014
Postgres in Production - Best Practices 2014Postgres in Production - Best Practices 2014
Postgres in Production - Best Practices 2014
 

Similar to Advanced WAL File Management With OmniPITR

Cassandra 1.0 and the future of big data (Cassandra Tokyo 2011)
Cassandra 1.0 and the future of big data (Cassandra Tokyo 2011)Cassandra 1.0 and the future of big data (Cassandra Tokyo 2011)
Cassandra 1.0 and the future of big data (Cassandra Tokyo 2011)jbellis
 
How I stopped worrying about and loved DumpRenderTree
How I stopped worrying about and loved DumpRenderTreeHow I stopped worrying about and loved DumpRenderTree
How I stopped worrying about and loved DumpRenderTreeHajime Morrita
 
PostgreSQL: The Time-Series Database You (Actually) Want
PostgreSQL: The Time-Series Database You (Actually) WantPostgreSQL: The Time-Series Database You (Actually) Want
PostgreSQL: The Time-Series Database You (Actually) WantChristoph Engelbert
 
Microservices and Teraflops: Effortlessly Scaling Data Science with PyWren wi...
Microservices and Teraflops: Effortlessly Scaling Data Science with PyWren wi...Microservices and Teraflops: Effortlessly Scaling Data Science with PyWren wi...
Microservices and Teraflops: Effortlessly Scaling Data Science with PyWren wi...Databricks
 
Computer 10 Quarter 3 Lesson .ppt
Computer 10 Quarter 3 Lesson .pptComputer 10 Quarter 3 Lesson .ppt
Computer 10 Quarter 3 Lesson .pptRedenOriola
 
Brisk: more powerful Hadoop powered by Cassandra
Brisk: more powerful Hadoop powered by CassandraBrisk: more powerful Hadoop powered by Cassandra
Brisk: more powerful Hadoop powered by Cassandrajbellis
 
잘 알려지지 않은 Php 코드 활용하기
잘 알려지지 않은 Php 코드 활용하기잘 알려지지 않은 Php 코드 활용하기
잘 알려지지 않은 Php 코드 활용하기형우 안
 
international PHP2011_ilia alshanetsky_Hidden Features of PHP
international PHP2011_ilia alshanetsky_Hidden Features of PHPinternational PHP2011_ilia alshanetsky_Hidden Features of PHP
international PHP2011_ilia alshanetsky_Hidden Features of PHPsmueller_sandsmedia
 
A importância dos dados em sua arquitetura... uma visão muito além do SQL Ser...
A importância dos dados em sua arquitetura... uma visão muito além do SQL Ser...A importância dos dados em sua arquitetura... uma visão muito além do SQL Ser...
A importância dos dados em sua arquitetura... uma visão muito além do SQL Ser...Alexandre Porcelli
 
Node js techtalksto
Node js techtalkstoNode js techtalksto
Node js techtalkstoJason Diller
 
Text Manipulation with/without Parsec
Text Manipulation with/without ParsecText Manipulation with/without Parsec
Text Manipulation with/without Parsecujihisa
 
Basics in algorithms and data structure
Basics in algorithms and data structure Basics in algorithms and data structure
Basics in algorithms and data structure Eman magdy
 
Python 3.6 Features 20161207
Python 3.6 Features 20161207Python 3.6 Features 20161207
Python 3.6 Features 20161207Jay Coskey
 
OpenStack: A python based IaaS provider
OpenStack: A python based IaaS providerOpenStack: A python based IaaS provider
OpenStack: A python based IaaS providerFlavio Percoco Premoli
 
useR! 2012 Talk
useR! 2012 TalkuseR! 2012 Talk
useR! 2012 Talkrtelmore
 
What the Bleep is Big Data? A Holistic View of Data and Algorithms
What the Bleep is Big Data? A Holistic View of Data and AlgorithmsWhat the Bleep is Big Data? A Holistic View of Data and Algorithms
What the Bleep is Big Data? A Holistic View of Data and AlgorithmsAlice Zheng
 

Similar to Advanced WAL File Management With OmniPITR (20)

Cassandra 1.0 and the future of big data (Cassandra Tokyo 2011)
Cassandra 1.0 and the future of big data (Cassandra Tokyo 2011)Cassandra 1.0 and the future of big data (Cassandra Tokyo 2011)
Cassandra 1.0 and the future of big data (Cassandra Tokyo 2011)
 
When?, Why? and What? of MongoDB
When?, Why? and What? of MongoDBWhen?, Why? and What? of MongoDB
When?, Why? and What? of MongoDB
 
How I stopped worrying about and loved DumpRenderTree
How I stopped worrying about and loved DumpRenderTreeHow I stopped worrying about and loved DumpRenderTree
How I stopped worrying about and loved DumpRenderTree
 
PostgreSQL: The Time-Series Database You (Actually) Want
PostgreSQL: The Time-Series Database You (Actually) WantPostgreSQL: The Time-Series Database You (Actually) Want
PostgreSQL: The Time-Series Database You (Actually) Want
 
MySQL 优化
MySQL 优化MySQL 优化
MySQL 优化
 
Microservices and Teraflops: Effortlessly Scaling Data Science with PyWren wi...
Microservices and Teraflops: Effortlessly Scaling Data Science with PyWren wi...Microservices and Teraflops: Effortlessly Scaling Data Science with PyWren wi...
Microservices and Teraflops: Effortlessly Scaling Data Science with PyWren wi...
 
Computer 10 Quarter 3 Lesson .ppt
Computer 10 Quarter 3 Lesson .pptComputer 10 Quarter 3 Lesson .ppt
Computer 10 Quarter 3 Lesson .ppt
 
Brisk: more powerful Hadoop powered by Cassandra
Brisk: more powerful Hadoop powered by CassandraBrisk: more powerful Hadoop powered by Cassandra
Brisk: more powerful Hadoop powered by Cassandra
 
잘 알려지지 않은 Php 코드 활용하기
잘 알려지지 않은 Php 코드 활용하기잘 알려지지 않은 Php 코드 활용하기
잘 알려지지 않은 Php 코드 활용하기
 
international PHP2011_ilia alshanetsky_Hidden Features of PHP
international PHP2011_ilia alshanetsky_Hidden Features of PHPinternational PHP2011_ilia alshanetsky_Hidden Features of PHP
international PHP2011_ilia alshanetsky_Hidden Features of PHP
 
A importância dos dados em sua arquitetura... uma visão muito além do SQL Ser...
A importância dos dados em sua arquitetura... uma visão muito além do SQL Ser...A importância dos dados em sua arquitetura... uma visão muito além do SQL Ser...
A importância dos dados em sua arquitetura... uma visão muito além do SQL Ser...
 
Node js techtalksto
Node js techtalkstoNode js techtalksto
Node js techtalksto
 
Text Manipulation with/without Parsec
Text Manipulation with/without ParsecText Manipulation with/without Parsec
Text Manipulation with/without Parsec
 
Basics in algorithms and data structure
Basics in algorithms and data structure Basics in algorithms and data structure
Basics in algorithms and data structure
 
Velocity 2015-final
Velocity 2015-finalVelocity 2015-final
Velocity 2015-final
 
RunDeck
RunDeckRunDeck
RunDeck
 
Python 3.6 Features 20161207
Python 3.6 Features 20161207Python 3.6 Features 20161207
Python 3.6 Features 20161207
 
OpenStack: A python based IaaS provider
OpenStack: A python based IaaS providerOpenStack: A python based IaaS provider
OpenStack: A python based IaaS provider
 
useR! 2012 Talk
useR! 2012 TalkuseR! 2012 Talk
useR! 2012 Talk
 
What the Bleep is Big Data? A Holistic View of Data and Algorithms
What the Bleep is Big Data? A Holistic View of Data and AlgorithmsWhat the Bleep is Big Data? A Holistic View of Data and Algorithms
What the Bleep is Big Data? A Holistic View of Data and Algorithms
 

More from Robert Treat

Advanced Int->Bigint Conversions
Advanced Int->Bigint ConversionsAdvanced Int->Bigint Conversions
Advanced Int->Bigint ConversionsRobert Treat
 
Explaining Explain
Explaining ExplainExplaining Explain
Explaining ExplainRobert Treat
 
the-lost-art-of-plpgsql
the-lost-art-of-plpgsqlthe-lost-art-of-plpgsql
the-lost-art-of-plpgsqlRobert Treat
 
Managing Chaos In Production: Testing vs Monitoring
Managing Chaos In Production: Testing vs MonitoringManaging Chaos In Production: Testing vs Monitoring
Managing Chaos In Production: Testing vs MonitoringRobert Treat
 
Less Alarming Alerts!
Less Alarming Alerts!Less Alarming Alerts!
Less Alarming Alerts!Robert Treat
 
Past, Present, and Pachyderm - All Things Open - 2013
Past, Present, and Pachyderm - All Things Open - 2013Past, Present, and Pachyderm - All Things Open - 2013
Past, Present, and Pachyderm - All Things Open - 2013Robert Treat
 
Big Bad "Upgraded" Postgres
Big Bad "Upgraded" PostgresBig Bad "Upgraded" Postgres
Big Bad "Upgraded" PostgresRobert Treat
 
Scaling with Postgres (Highload++ 2010)
Scaling with Postgres (Highload++ 2010)Scaling with Postgres (Highload++ 2010)
Scaling with Postgres (Highload++ 2010)Robert Treat
 
Intro to Postgres 9 Tutorial
Intro to Postgres 9 TutorialIntro to Postgres 9 Tutorial
Intro to Postgres 9 TutorialRobert Treat
 
Intro to Postgres 8.4 Tutorial
Intro to Postgres 8.4 TutorialIntro to Postgres 8.4 Tutorial
Intro to Postgres 8.4 TutorialRobert Treat
 
The Essential postgresql.conf
The Essential postgresql.confThe Essential postgresql.conf
The Essential postgresql.confRobert Treat
 
PostgreSQL Partitioning, PGCon 2007
PostgreSQL Partitioning, PGCon 2007PostgreSQL Partitioning, PGCon 2007
PostgreSQL Partitioning, PGCon 2007Robert Treat
 
Pro PostgreSQL, OSCon 2008
Pro PostgreSQL, OSCon 2008Pro PostgreSQL, OSCon 2008
Pro PostgreSQL, OSCon 2008Robert Treat
 
Database Anti Patterns
Database Anti PatternsDatabase Anti Patterns
Database Anti PatternsRobert Treat
 

More from Robert Treat (16)

Advanced Int->Bigint Conversions
Advanced Int->Bigint ConversionsAdvanced Int->Bigint Conversions
Advanced Int->Bigint Conversions
 
Explaining Explain
Explaining ExplainExplaining Explain
Explaining Explain
 
the-lost-art-of-plpgsql
the-lost-art-of-plpgsqlthe-lost-art-of-plpgsql
the-lost-art-of-plpgsql
 
Managing Chaos In Production: Testing vs Monitoring
Managing Chaos In Production: Testing vs MonitoringManaging Chaos In Production: Testing vs Monitoring
Managing Chaos In Production: Testing vs Monitoring
 
Less Alarming Alerts!
Less Alarming Alerts!Less Alarming Alerts!
Less Alarming Alerts!
 
Past, Present, and Pachyderm - All Things Open - 2013
Past, Present, and Pachyderm - All Things Open - 2013Past, Present, and Pachyderm - All Things Open - 2013
Past, Present, and Pachyderm - All Things Open - 2013
 
Big Bad "Upgraded" Postgres
Big Bad "Upgraded" PostgresBig Bad "Upgraded" Postgres
Big Bad "Upgraded" Postgres
 
Scaling with Postgres (Highload++ 2010)
Scaling with Postgres (Highload++ 2010)Scaling with Postgres (Highload++ 2010)
Scaling with Postgres (Highload++ 2010)
 
Intro to Postgres 9 Tutorial
Intro to Postgres 9 TutorialIntro to Postgres 9 Tutorial
Intro to Postgres 9 Tutorial
 
Check Please!
Check Please!Check Please!
Check Please!
 
Intro to Postgres 8.4 Tutorial
Intro to Postgres 8.4 TutorialIntro to Postgres 8.4 Tutorial
Intro to Postgres 8.4 Tutorial
 
The Essential postgresql.conf
The Essential postgresql.confThe Essential postgresql.conf
The Essential postgresql.conf
 
PostgreSQL Partitioning, PGCon 2007
PostgreSQL Partitioning, PGCon 2007PostgreSQL Partitioning, PGCon 2007
PostgreSQL Partitioning, PGCon 2007
 
Pro PostgreSQL, OSCon 2008
Pro PostgreSQL, OSCon 2008Pro PostgreSQL, OSCon 2008
Pro PostgreSQL, OSCon 2008
 
Database Anti Patterns
Database Anti PatternsDatabase Anti Patterns
Database Anti Patterns
 
Pro PostgreSQL
Pro PostgreSQLPro PostgreSQL
Pro PostgreSQL
 

Recently uploaded

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 

Recently uploaded (20)

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 

Advanced WAL File Management With OmniPITR

  • 1. Advanced WAL File Management With OmniPITR Robert Treat, JDCon 2011 #pgeast / Presentation Thursday, March 31, 2011
  • 2. Who Am I? • Robert
Treat • OmniTI • Database
Management
and
Consulting • We’re
Hiring! • Postgres • Major
Contributor,
Web,
Advocacy,
Random • xzilla.net • @robtreat2 Thursday, March 31, 2011
  • 3. Who Am I? • Robert
Treat • OmniTI • Database
Management
and
Consulting • We’re
Hiring! • Postgres • Major
Contributor,
Web,
Advocacy,
Random • xzilla.net • @robtreat2 Thursday, March 31, 2011
  • 4. What is PITR? Thursday, March 31, 2011
  • 5. What is PITR? •Postgres emits WAL files Thursday, March 31, 2011
  • 7. Digression •WAL Logs? •Write Ahead Log Logs? •OTOH, they are stored in pg_xlog... Thursday, March 31, 2011
  • 8. What is PITR? Thursday, March 31, 2011
  • 9. What is PITR? •Postgres emits WAL files Thursday, March 31, 2011
  • 10. What is PITR? •Postgres emits WAL files •Send the WAL file to another server Thursday, March 31, 2011
  • 11. What is PITR? •Postgres emits WAL files •Send the WAL file to another server •The other server can replay the WAL Thursday, March 31, 2011
  • 12. What is PITR? Use combination of data files and WAL to make more postgrezes Thursday, March 31, 2011
  • 13. What is PITR? •Postgres emits WAL files Use combination of data files and WAL to make more postgrezes Thursday, March 31, 2011
  • 14. What is PITR? •Postgres emits WAL files •Send the WAL file to another server Use combination of data files and WAL to make more postgrezes Thursday, March 31, 2011
  • 15. What is PITR? •Postgres emits WAL files •Send the WAL file to another server •The other server can replay the WAL Use combination of data files and WAL to make more postgrezes Thursday, March 31, 2011
  • 16. A Brief History of PITR Thursday, March 31, 2011
  • 17. A Brief History of PITR •8.1 (really) Thursday, March 31, 2011
  • 18. A Brief History of PITR •8.1 (really) •8.2 (warm standby) Thursday, March 31, 2011
  • 19. A Brief History of PITR •8.1 (really) •8.2 (warm standby) •9.0 (hot standby) Thursday, March 31, 2011
  • 20. A Brief History of PITR •8.1 (really) •8.2 (warm standby) •9.0 (hot standby) •9.0 (streaming replication) Thursday, March 31, 2011
  • 21. Ghetto Style archive_command = 'rsync %p sdb2:/data/pgsql/sdb1/84/walarchive/% f' Thursday, March 31, 2011
  • 22. Ghetto Style •Simple, Better Than You’d Think archive_command = 'rsync %p sdb2:/data/pgsql/sdb1/84/walarchive/% f' Thursday, March 31, 2011
  • 23. Early Version Of A PITR Script archive_command = ‘cp -i %p /data/pgsql/82_walarchives/%f </dev/null’ Thursday, March 31, 2011
  • 24. Early Version Of A PITR Script •Kind of Hacky archive_command = ‘cp -i %p /data/pgsql/82_walarchives/%f </dev/null’ Thursday, March 31, 2011
  • 25. Early Version Of A PITR Script archive_command = ‘cp -i %p /data/pgsql/82_walarchives/%f </dev/null’ opendir(DIR, "."); my @wals2move = grep { -f $_ && (stat(_))[9] + $AGE < time() && ( # 000000010000007200000031 ( /^[0-9A-F]{24}$/ && (stat(_))[7] == $WALSIZE ) || # 000000010000007200000031.0012C968.backup ( /^[0-9A-F]{24}.[0-9A-F]{8}.backup$/ ) ) && ( $mtime{$_} = (stat(_))[9] ) # Always true (for later) } readdir(DIR); closedir(DIR); Thursday, March 31, 2011
  • 26. Early Version Of A PITR Script •Kind of Hacky archive_command = ‘cp -i %p /data/pgsql/82_walarchives/%f </dev/null’ opendir(DIR, "."); my @wals2move = grep { -f $_ && (stat(_))[9] + $AGE < time() && ( # 000000010000007200000031 ( /^[0-9A-F]{24}$/ && (stat(_))[7] == $WALSIZE ) || # 000000010000007200000031.0012C968.backup ( /^[0-9A-F]{24}.[0-9A-F]{8}.backup$/ ) ) && ( $mtime{$_} = (stat(_))[9] ) # Always true (for later) } readdir(DIR); closedir(DIR); Thursday, March 31, 2011
  • 27. Early Version Of A PITR Script archive_command = ‘cp -i %p /data/pgsql/82_walarchives/%f </dev/null’ @wals2move = sort { $mtime{$a} <=> $mtime{$b} } @wals2move; if($TARGET) { foreach (@wals2move) { if($NOOP) { print "$RSYNC -essh --rsync-path=$REMOTE_RSYNC -a $_ $TARGET/$_n"; print "mv $_ $_.slavedn"; } else { if(system("$RSYNC -essh --rsync-path=$REMOTE_RSYNC -a $_ $TARGET/$_") != 0) { print STDERR "Error moving wal to target: $?n"; last; } if(!rename("$_", "$_.slaved")) { print STDERR "Error renaming $_ to $_.slavedn"; last; } } } } Thursday, March 31, 2011
  • 28. Early Version Of A PITR Script •Kind of Hacky archive_command = ‘cp -i %p /data/pgsql/82_walarchives/%f </dev/null’ @wals2move = sort { $mtime{$a} <=> $mtime{$b} } @wals2move; if($TARGET) { foreach (@wals2move) { if($NOOP) { print "$RSYNC -essh --rsync-path=$REMOTE_RSYNC -a $_ $TARGET/$_n"; print "mv $_ $_.slavedn"; } else { if(system("$RSYNC -essh --rsync-path=$REMOTE_RSYNC -a $_ $TARGET/$_") != 0) { print STDERR "Error moving wal to target: $?n"; last; } if(!rename("$_", "$_.slaved")) { print STDERR "Error renaming $_ to $_.slavedn"; last; } } } } Thursday, March 31, 2011
  • 30. Customizations •Multiple Destinations Thursday, March 31, 2011
  • 31. Customizations •Multiple Destinations •WAL File Delay Thursday, March 31, 2011
  • 32. Customizations •Multiple Destinations •WAL File Delay •Archive Storage (gzip & friends) Thursday, March 31, 2011
  • 33. Customizations •Multiple Destinations •WAL File Delay •Archive Storage (gzip & friends) •Better Backups Thursday, March 31, 2011
  • 35. ENTER: OmniPITR •Consolidate various scripts Thursday, March 31, 2011
  • 36. ENTER: OmniPITR •Consolidate various scripts •Deploy across ‘Nixes Thursday, March 31, 2011
  • 37. ENTER: OmniPITR •Consolidate various scripts •Deploy across ‘Nixes •Reusable Thursday, March 31, 2011
  • 38. ENTER: OmniPITR •Consolidate various scripts •Deploy across ‘Nixes •Reusable •Complete Solution Thursday, March 31, 2011
  • 40. OmniPITR-Archive •Lots of options Thursday, March 31, 2011
  • 41. OmniPITR-Archive •Lots of options •compression Thursday, March 31, 2011
  • 42. OmniPITR-Archive •Lots of options •compression •custom log file Thursday, March 31, 2011
  • 43. OmniPITR-Archive •Lots of options •compression •custom log file •special paths Thursday, March 31, 2011
  • 44. OmniPITR-Archive •Lots of options •compression •custom log file •special paths •multiple destinations Thursday, March 31, 2011
  • 45. OmniPITR-Archive Example archive_command = '/opt/OMNIpitr/bin/omnipitr-archive -l "/var/log/omnipitr/omnipitr-^Y-^m-^d.log" -s /var/lib/pgsql/omnipitr/state/ -t /var/tmp/ -dr gzip=db4:/mnt/db/prod/walarchive/ -dr db4:/mnt/db/prod/db4-walarchive/ -db /var/lib/pgsql/omnipitr/backup.xlogs "%p"' Thursday, March 31, 2011
  • 46. OmniPITR-Archive Example archive_command = '/opt/OMNIpitr/bin/omnipitr-archive -l "/var/log/omnipitr/omnipitr-^Y-^m-^d.log" -s /var/lib/pgsql/omnipitr/state/ -t /var/tmp/ -dr gzip=db4:/mnt/db/prod/walarchive/ -dr db4:/mnt/db/prod/db4-walarchive/ -db /var/lib/pgsql/omnipitr/backup.xlogs "%p"' Location of OmniPITR Thursday, March 31, 2011
  • 47. OmniPITR-Archive Example archive_command = '/opt/OMNIpitr/bin/omnipitr-archive -l "/var/log/omnipitr/omnipitr-^Y-^m-^d.log" -s /var/lib/pgsql/omnipitr/state/ -t /var/tmp/ -dr gzip=db4:/mnt/db/prod/walarchive/ -dr db4:/mnt/db/prod/db4-walarchive/ -db /var/lib/pgsql/omnipitr/backup.xlogs "%p"' Custom Log File Name/Location Thursday, March 31, 2011
  • 48. OmniPITR-Archive Example archive_command = '/opt/OMNIpitr/bin/omnipitr-archive -l "/var/log/omnipitr/omnipitr-^Y-^m-^d.log" -s /var/lib/pgsql/omnipitr/state/ -t /var/tmp/ -dr gzip=db4:/mnt/db/prod/walarchive/ -dr db4:/mnt/db/prod/db4-walarchive/ -db /var/lib/pgsql/omnipitr/backup.xlogs "%p"' state-directory to handle errors when sending wal to multiple destinations Thursday, March 31, 2011
  • 49. OmniPITR-Archive Example archive_command = '/opt/OMNIpitr/bin/omnipitr-archive -l "/var/log/omnipitr/omnipitr-^Y-^m-^d.log" -s /var/lib/pgsql/omnipitr/state/ -t /var/tmp/ -dr gzip=db4:/mnt/db/prod/walarchive/ -dr db4:/mnt/db/prod/db4-walarchive/ -db /var/lib/pgsql/omnipitr/backup.xlogs "%p"' Where To Create Temp Files Thursday, March 31, 2011
  • 50. OmniPITR-Archive Example archive_command = '/opt/OMNIpitr/bin/omnipitr-archive -l "/var/log/omnipitr/omnipitr-^Y-^m-^d.log" -s /var/lib/pgsql/omnipitr/state/ -t /var/tmp/ -dr gzip=dbx:/mnt/db/prod/walstorage/ -dr db4:/mnt/db/prod/db4-walarchive/ -db /var/lib/pgsql/omnipitr/backup.xlogs "%p"' send to remote server (dbx) compressed (gzip) Thursday, March 31, 2011
  • 51. OmniPITR-Archive Example archive_command = '/opt/OMNIpitr/bin/omnipitr-archive -l "/var/log/omnipitr/omnipitr-^Y-^m-^d.log" -s /var/lib/pgsql/omnipitr/state/ -t /var/tmp/ -dr gzip=db4:/mnt/db/prod/walarchive/ -dr db4:/mnt/db/prod/db4-walarchive/ -db /var/lib/pgsql/omnipitr/backup.xlogs "%p"' send to remote server (db4) uncompressed Thursday, March 31, 2011
  • 52. OmniPITR-Archive Example archive_command = '/opt/OMNIpitr/bin/omnipitr-archive -l "/var/log/omnipitr/omnipitr-^Y-^m-^d.log" -s /var/lib/pgsql/omnipitr/state/ -t /var/tmp/ -dr gzip=db4:/mnt/db/prod/walarchive/ -dr db4:/mnt/db/prod/db4-walarchive/ -db /var/lib/pgsql/omnipitr/backup.xlogs "%p"' Where to store xlogs when building a backup Thursday, March 31, 2011
  • 53. OmniPITR-Archive Example archive_command = '/opt/OMNIpitr/bin/omnipitr-archive -l "/var/log/omnipitr/omnipitr-^Y-^m-^d.log" -s /var/lib/pgsql/omnipitr/state/ -t /var/tmp/ -dr gzip=db4:/mnt/db/prod/walarchive/ -dr db4:/mnt/db/prod/db4-walarchive/ -db /var/lib/pgsql/omnipitr/backup.xlogs "%p"' The xlog file :-) Thursday, March 31, 2011
  • 55. OmniPITR-Restore •Lots of options (though not as many) Thursday, March 31, 2011
  • 56. OmniPITR-Restore •Lots of options (though not as many) •compressed files? Thursday, March 31, 2011
  • 57. OmniPITR-Restore •Lots of options (though not as many) •compressed files? •custom log file Thursday, March 31, 2011
  • 58. OmniPITR-Restore •Lots of options (though not as many) •compressed files? •custom log file •special paths Thursday, March 31, 2011
  • 59. OmniPITR-Restore Example restore_command = ' /opt/OMNIpitr/bin/omnipitr-restore -l /var/lib/pgsql/data/pg_log/omnipitr-^Y-^m-^d.log -s /var/lib/pgsql/wal_archive/ -p /var/lib/pgsql/wal_archives.pause -v -r %f %p' location of omnipitr-restore program Thursday, March 31, 2011
  • 60. OmniPITR-Restore Example restore_command = ' /opt/OMNIpitr/bin/omnipitr-restore -l /var/lib/pgsql/data/pg_log/omnipitr-^Y-^m-^d.log -s /var/lib/pgsql/wal_archive/ -p /var/lib/pgsql/wal_archives.pause -v -r %f %p' custom log file format Thursday, March 31, 2011
  • 61. OmniPITR-Restore Example restore_command = ' /opt/OMNIpitr/bin/omnipitr-restore -l /var/lib/pgsql/data/pg_log/omnipitr-^Y-^m-^d.log -s /var/lib/pgsql/wal_archive/ -p /var/lib/pgsql/wal_archives.pause -v -r %f %p' Source of WAL Files to Use For Restore Thursday, March 31, 2011
  • 62. OmniPITR-Restore Example restore_command = ' /opt/OMNIpitr/bin/omnipitr-restore -l /var/lib/pgsql/data/pg_log/omnipitr-^Y-^m-^d.log -s /var/lib/pgsql/wal_archive/ -p /var/lib/pgsql/wal_archives.pause -v -r %f %p' pause xlog removal if this file exists (foreshadow: used for making backups) Thursday, March 31, 2011
  • 63. OmniPITR-Restore Example restore_command = ' /opt/OMNIpitr/bin/omnipitr-restore -l /var/lib/pgsql/data/pg_log/omnipitr-^Y-^m-^d.log -s /var/lib/pgsql/wal_archive/ -p /var/lib/pgsql/wal_archives.pause -v -r %f %p' verbose Thursday, March 31, 2011
  • 64. OmniPITR-Restore Example restore_command = ' /opt/OMNIpitr/bin/omnipitr-restore -l /var/lib/pgsql/data/pg_log/omnipitr-^Y-^m-^d.log -s /var/lib/pgsql/wal_archive/ -p /var/lib/pgsql/wal_archives.pause -v -r %f %p' Remove Xlogs Files Which Are No Longer Needed Thursday, March 31, 2011
  • 65. OmniPITR-Restore Example restore_command = ' /opt/OMNIpitr/bin/omnipitr-restore -l /var/lib/pgsql/data/pg_log/omnipitr-^Y-^m-^d.log -s /var/lib/pgsql/wal_archive/ -p /var/lib/pgsql/wal_archives.pause -v -r %f %p' standard macros for “basename of segment” and “destination of recovery” Thursday, March 31, 2011
  • 67. OmniPITR-Master-Backup •Goal Thursday, March 31, 2011
  • 68. OmniPITR-Master-Backup •Goal •simple “tarball” for backup Thursday, March 31, 2011
  • 69. OmniPITR-Master-Backup •Goal •simple “tarball” for backup •one for $PGDATA and xlogs Thursday, March 31, 2011
  • 70. OmniPITR-Master-Backup •Goal •simple “tarball” for backup •one for $PGDATA and xlogs •simple to blow open and use Thursday, March 31, 2011
  • 71. OmniPITR-Master-Backup Example /opt/OMNIpitr/bin/omnipitr-backup-master -v -l "/var/log/omnipitr/omnipitr-^Y-^m-^d.log" -x /var/lib/pgsql/omnipitr/backup.xlogs -dr gzip=db4:/mnt/db/prod/backups/ -t /var/tmp/ -pp /usr/pgsql-9.0/bin/psql -D /pg_data/90data location of OmniPITR-backup-master Thursday, March 31, 2011
  • 72. OmniPITR-Master-Backup Example /opt/OMNIpitr/bin/omnipitr-backup-master -v -l "/var/log/omnipitr/omnipitr-^Y-^m-^d.log" -x /var/lib/pgsql/omnipitr/backup.xlogs -dr gzip=db4:/mnt/db/prod/backups/ -t /var/tmp/ -pp /usr/pgsql-9.0/bin/psql -D /pg_data/90data verbose Thursday, March 31, 2011
  • 73. OmniPITR-Master-Backup Example /opt/OMNIpitr/bin/omnipitr-backup-master -v -l "/var/log/omnipitr/omnipitr-^Y-^m-^d.log" -x /var/lib/pgsql/omnipitr/backup.xlogs -dr gzip=db4:/mnt/db/prod/backups/ -t /var/tmp/ -pp /usr/pgsql-9.0/bin/psql -D /pg_data/90data custom log file Thursday, March 31, 2011
  • 74. OmniPITR-Master-Backup Example /opt/OMNIpitr/bin/omnipitr-backup-master -v -l "/var/log/omnipitr/omnipitr-^Y-^m-^d.log" -x /var/lib/pgsql/omnipitr/backup.xlogs -dr gzip=db4:/mnt/db/prod/backups/ -t /var/tmp/ -pp /usr/pgsql-9.0/bin/psql -D /pg_data/90data directory to store xlogs during backup creation Thursday, March 31, 2011
  • 75. OmniPITR-Master-Backup Example /opt/OMNIpitr/bin/omnipitr-backup-master -v -l "/var/log/omnipitr/omnipitr-^Y-^m-^d.log" -x /var/lib/pgsql/omnipitr/backup.xlogs -dr gzip=db4:/mnt/db/prod/backups/ -t /var/tmp/ -pp /usr/pgsql-9.0/bin/psql -D /pg_data/90data copy backup file to remote server, compressed Thursday, March 31, 2011
  • 76. OmniPITR-Master-Backup Example /opt/OMNIpitr/bin/omnipitr-backup-master -v -l "/var/log/omnipitr/omnipitr-^Y-^m-^d.log" -x /var/lib/pgsql/omnipitr/backup.xlogs -dr gzip=db4:/mnt/db/prod/backups/ -t /var/tmp/ -pp /usr/pgsql-9.0/bin/psql -D /pg_data/90data location for temporary files whilst working Thursday, March 31, 2011
  • 77. OmniPITR-Master-Backup Example /opt/OMNIpitr/bin/omnipitr-backup-master -v -l "/var/log/omnipitr/omnipitr-^Y-^m-^d.log" -x /var/lib/pgsql/omnipitr/backup.xlogs -dr gzip=db4:/mnt/db/prod/backups/ -t /var/tmp/ -pp /usr/pgsql-9.0/bin/psql -D /pg_data/90data path to psql Thursday, March 31, 2011
  • 78. OmniPITR-Master-Backup Example /opt/OMNIpitr/bin/omnipitr-backup-master -v -l "/var/log/omnipitr/omnipitr-^Y-^m-^d.log" -x /var/lib/pgsql/omnipitr/backup.xlogs -dr gzip=db4:/mnt/db/prod/backups/ -t /var/tmp/ -pp /usr/pgsql-9.0/bin/psql -D /pg_data/90data $PGDATA Thursday, March 31, 2011
  • 79. Programmers Say: “I love it when people use my software to do cool things that I didn’t expect” Thursday, March 31, 2011
  • 80. Treat’s Maxim? “Try not to let the way software was designed get in the way of how you want to use it” Thursday, March 31, 2011
  • 82. OmniPITR-Slave-Backup •On MySQL, you could dump on slave for a long time Thursday, March 31, 2011
  • 83. OmniPITR-Slave-Backup •On MySQL, you could dump on slave for a long time •On ZFS, we use snapshots to make slaves on the backups Thursday, March 31, 2011
  • 84. OmniPITR-Slave-Backup •On MySQL, you could dump on slave for a long time •On ZFS, we use snapshots to make slaves on the backups •While “we” prefer to use Postgres, some of us prefer to use Linux Thursday, March 31, 2011
  • 85. OmniPITR-Slave-Backup •On MySQL, you could dump on slave for a long time •On ZFS, we use snapshots to make slaves on the backups •While “we” prefer to use Postgres, some of us prefer to use Linux •But, you still don’t want to pay the price for backups on master Thursday, March 31, 2011
  • 86. OmniPITR-Slave-Backup Example /opt/OMNIpitr/bin/omnipitr-backup-slave -v -l "/var/log/omnipitr/omnipitr-slave-backup-^Y-^m-^d.log" -s /mnt/db/prod/db4-walarchive -p /var/lib/pgsql/omnipitr/pause.removal -D /pg_data/90data/ -t /var/tmp/ -gp /usr/bin/pigz -dl gzip=/mnt/db/prod/backups/ -pp /usr/pgsql-9.0/bin/pg_controldata Location of omni-pitr-slave command Thursday, March 31, 2011
  • 87. OmniPITR-Slave-Backup Example /opt/OMNIpitr/bin/omnipitr-backup-slave -v -l "/var/log/omnipitr/omnipitr-slave-backup-^Y-^m-^d.log" -s /mnt/db/prod/db4-walarchive -p /var/lib/pgsql/omnipitr/pause.removal -D /pg_data/90data/ -t /var/tmp/ -gp /usr/bin/pigz -dl gzip=/mnt/db/prod/backups/ -pp /usr/pgsql-9.0/bin/pg_controldata verbose Thursday, March 31, 2011
  • 88. OmniPITR-Slave-Backup Example /opt/OMNIpitr/bin/omnipitr-backup-slave -v -l "/var/log/omnipitr/omnipitr-slave-backup-^Y-^m-^d.log" -s /mnt/db/prod/db4-walarchive -p /var/lib/pgsql/omnipitr/pause.removal -D /pg_data/90data/ -t /var/tmp/ -gp /usr/bin/pigz -dl gzip=/mnt/db/prod/backups/ -pp /usr/pgsql-9.0/bin/pg_controldata custom log location / format Thursday, March 31, 2011
  • 89. OmniPITR-Slave-Backup Example /opt/OMNIpitr/bin/omnipitr-backup-slave -v -l "/var/log/omnipitr/omnipitr-slave-backup-^Y-^m-^d.log" -s /mnt/db/prod/db4-walarchive -p /var/lib/pgsql/omnipitr/pause.removal -D /pg_data/90data/ -t /var/tmp/ -gp /usr/bin/pigz -dl gzip=/mnt/db/prod/backups/ -pp /usr/pgsql-9.0/bin/pg_controldata source of wal files Thursday, March 31, 2011
  • 90. OmniPITR-Slave-Backup Example /opt/OMNIpitr/bin/omnipitr-backup-slave -v -l "/var/log/omnipitr/omnipitr-slave-backup-^Y-^m-^d.log" -s /mnt/db/prod/db4-walarchive -p /var/lib/pgsql/omnipitr/pause.removal -D /pg_data/90data/ -t /var/tmp/ -gp /usr/bin/pigz -dl gzip=/mnt/db/prod/backups/ -pp /usr/pgsql-9.0/bin/pg_controldata file to pause removal of xlogs no longer needed for restore but still needed by backup Thursday, March 31, 2011
  • 91. OmniPITR-Slave-Backup Example /opt/OMNIpitr/bin/omnipitr-backup-slave -v -l "/var/log/omnipitr/omnipitr-slave-backup-^Y-^m-^d.log" -s /mnt/db/prod/db4-walarchive -p /var/lib/pgsql/omnipitr/pause.removal -D /pg_data/90data/ -t /var/tmp/ -gp /usr/bin/pigz -dl gzip=/mnt/db/prod/backups/ -pp /usr/pgsql-9.0/bin/pg_controldata $PGDATA Thursday, March 31, 2011
  • 92. OmniPITR-Slave-Backup Example /opt/OMNIpitr/bin/omnipitr-backup-slave -v -l "/var/log/omnipitr/omnipitr-slave-backup-^Y-^m-^d.log" -s /mnt/db/prod/db4-walarchive -p /var/lib/pgsql/omnipitr/pause.removal -D /pg_data/90data/ -t /var/tmp/ -gp /usr/bin/pigz -dl gzip=/mnt/db/prod/backups/ -pp /usr/pgsql-9.0/bin/pg_controldata location for temp files whilst working Thursday, March 31, 2011
  • 93. OmniPITR-Slave-Backup Example /opt/OMNIpitr/bin/omnipitr-backup-slave -v -l "/var/log/omnipitr/omnipitr-slave-backup-^Y-^m-^d.log" -s /mnt/db/prod/db4-walarchive -p /var/lib/pgsql/omnipitr/pause.removal -D /pg_data/90data/ -t /var/tmp/ -gp /usr/bin/pigz -dl gzip=/mnt/db/prod/backups/ -pp /usr/pgsql-9.0/bin/pg_controldata location of our “gzip” Thursday, March 31, 2011
  • 94. OmniPITR-Slave-Backup Example /opt/OMNIpitr/bin/omnipitr-backup-slave -v -l "/var/log/omnipitr/omnipitr-slave-backup-^Y-^m-^d.log" -s /mnt/db/prod/db4-walarchive -p /var/lib/pgsql/omnipitr/pause.removal -D /pg_data/90data/ -t /var/tmp/ -gp /usr/bin/pigz -dl gzip=/mnt/db/prod/backups/ -pp /usr/pgsql-9.0/bin/pg_controldata local storage, compressed Thursday, March 31, 2011
  • 95. OmniPITR-Slave-Backup Example /opt/OMNIpitr/bin/omnipitr-backup-slave -v -l "/var/log/omnipitr/omnipitr-slave-backup-^Y-^m-^d.log" -s /mnt/db/prod/db4-walarchive -p /var/lib/pgsql/omnipitr/pause.removal -D /pg_data/90data/ -t /var/tmp/ -gp /usr/bin/pigz -dl gzip=/mnt/db/prod/backups/ -pp /usr/pgsql-9.0/bin/pg_controldata path to pg_controldata Thursday, March 31, 2011
  • 97. Production Use? •Versions 8.2, 8.3, 8.4, 9.0 Thursday, March 31, 2011
  • 98. Production Use? •Versions 8.2, 8.3, 8.4, 9.0 •Linux, Solaris Thursday, March 31, 2011
  • 99. Production Use? •Versions 8.2, 8.3, 8.4, 9.0 •Linux, Solaris •TB+ Databases, with multiple tablespaces Thursday, March 31, 2011
  • 100. Production Use? •Versions 8.2, 8.3, 8.4, 9.0 •Linux, Solaris •TB+ Databases, with multiple tablespaces •Thousands of txn/sec Thursday, March 31, 2011
  • 101. Production Use? •Versions 8.2, 8.3, 8.4, 9.0 •Linux, Solaris •TB+ Databases, with multiple tablespaces •Thousands of txn/sec •Cross Datacenter Thursday, March 31, 2011
  • 102. Where’s The Code? https://labs.omniti.com/labs/pgtreats svn co https://labs.omniti.com/pgtreats/trunk/omnipitr/ Thursday, March 31, 2011
  • 103. Where’s The Code? •Currently in “PGTreats” Repo https://labs.omniti.com/labs/pgtreats svn co https://labs.omniti.com/pgtreats/trunk/omnipitr/ Thursday, March 31, 2011
  • 104. Where’s The Code? •Currently in “PGTreats” Repo •Available Via SVN Pull https://labs.omniti.com/labs/pgtreats svn co https://labs.omniti.com/pgtreats/trunk/omnipitr/ Thursday, March 31, 2011
  • 105. Where’s The Code? •Currently in “PGTreats” Repo •Available Via SVN Pull •“BSD” Licensed https://labs.omniti.com/labs/pgtreats svn co https://labs.omniti.com/pgtreats/trunk/omnipitr/ Thursday, March 31, 2011
  • 107. TODO •Better Monitoring Thursday, March 31, 2011
  • 108. TODO •Better Monitoring •Parallel Multi-Destination Thursday, March 31, 2011
  • 109. TODO •Better Monitoring •Parallel Multi-Destination •Multiple-Source Restores Thursday, March 31, 2011
  • 110. BUGS Failover of a streaming replication based slave created from a slave based backup file against a stream replication based slave doesn’t work Thursday, March 31, 2011
  • 111. BUGS Failover of a streaming replication based slave created from a slave based backup file against a stream replication based slave doesn’t work, sometimes, Thursday, March 31, 2011
  • 112. BUGS Failover of a streaming replication based slave created from a slave based backup file against a stream replication based slave doesn’t work, sometimes, when under load Thursday, March 31, 2011
  • 113. BUGS Failover of a streaming replication based slave created from a slave based backup file against a stream replication based slave doesn’t work, sometimes, when under load We think it’s a flaw in Postgres, but hard to say for sure Thursday, March 31, 2011
  • 114. THE END Thanks! pgeast, pgus Slides http://www.xzilla.net/ Thursday, March 31, 2011