Chapter 6. Replication

In this chapter, we will learn several methods to copy entire databases or individual tables. We will cover the following recipes in this chapter:

  • Deciding what to copy
  • Securing the WAL stream
  • Setting up a hot standby
  • Upgrading to asynchronous replication
  • Bulletproofing with synchronous replication
  • Faking replication with pg_receivexlog
  • Setting up Slony
  • Copying a few tables with Slony
  • Setting up Bucardo
  • Copying a few tables with Bucardo
  • Setting up Londiste
  • Copying a few tables with Londiste

Introduction

One element that is absolutely required for any highly available PostgreSQL installation is replication. It does not matter if we have a SAN that provides disk redundancy, nor is DRBD or other block-level replication sufficient to protect our investment. Duplicating and backing up data is always a good practice, but when it comes to availability, we need online copies of the database.

Similarly, if other departments need data that resides in our OLTP database, how can we provide it safely? In ideal circumstances, we can supply a copy of the necessary tables. This way, we don't strain the primary database with ad hoc report-based queries. A new DBA might try to accomplish this by building a synchronization library or performing scheduled extracts and copies into a remote database. However, there are easier ways!

PostgreSQL gives us methods to build and maintain a fully online copy of our primary database. Furthermore, there are existing utilities to duplicate tables when we don't need a copy of the whole database. In this chapter, we will utilize PostgreSQL replication as well as third-party table-synchronization tools. Building the best stack requires familiarity with the tools available.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.99.152