Database Reference
In-Depth Information
hoo'
trigger_file = 'failover.now'
7. If you find that the slave can't play back WALs fast enough, you can specify a location
for caching. In that case, add to the recovery.conf file a line such as the following,
which varies depending on the OS:
On Linux/Unix
restore_command = 'cp %p ../archive/%f'
On Windows
restore_command = 'copy %p ..\\archive\\%f'
In this example, the archive folder is where we're caching.
Initiating the Replication Process
It's a good idea to start up the postgres service on all the slaves before starting it on the
master. Otherwise, the master might start writing data or altering the database before
the slaves can capture and replicate the changes. When you start up each slave server,
you'll get an error in logs saying that it can't connect to the master. Ignore the message.
Once the slaves have started, start up the postgres service on the master.
You should now be able to connect to both servers. Any changes you make on the master,
even structural changes such as installing extensions or creating tables, should trickle
down to the slaves. You should also be able to query the slaves.
When and if the time comes to liberate a chosen slave, create a blank file called fail
over.now in the data folder of the slave. PostgreSQL will then complete playback of WAL
and rename the recovery.conf file to recover.done . At that point, your slave will be un‐
shackled from the master and continue life on its own with all the data from the last
WAL. Once the slave has tasted freedom, there's no going back. In order to make it a
slave again, you'll need to go through the whole process from the beginning.
Foreign Data Wrappers
Foreign data wrappers (FDWs) are an extensible, standard-complaint method for your
PostgreSQL server to query other data sources: other PostgreSQL servers, and many
types of non-PostgreSQL data sources. FDW was first introduced in PostgreSQL 9.1. At
the center of the concept is a foreign table , a table that you can query like one in your
PostgreSQL database but that resides in another data source, perhaps even on another
physical server. Once you put in the effort to establish foreign tables, they persist in your
database and you're forever free from having to worry about the intricate protocols of
communicating with alien data sources. You can find a catalog of FDWs for PostgreSQL
at PGXN FDW and PGXN Foreign Data Wrapper . You can also find examples of usage
in PostgreSQL Wiki FDW .
Search WWH ::




Custom Search