Database Reference
In-Depth Information
Replicating a PostGIS database with
streaming replication
Therealityoftheworldisthat,givenenoughtime,everythingwillbreak.Thisincludes
thehardwareandsoftwareofcomputersrunningPostgreSQL.ToprotectdatainPost-
greSQL from corruption or loss, backups are taken using tools such as pg_dump .
However,restoringadatabasebackupcantakeaverylongtimeduringwhichusers
cannot use the database.
Whendowntimemustbekepttoaminimumorisnotacceptable,oneormorestandby
serversareusedtocompensateforthefailedprimaryPostgreSQLserver.Thedata
onthestandbyserveriskeptinsyncwiththeprimaryPostgreSQLserverbystream-
ing data as frequently as possible.
Inaddition,youarestronglydiscouragedfromtryingtomixdifferentPostgreSQLver-
sions. Primary and standby servers must run the same PostgreSQL version.
Getting ready
In this recipe, we will use the streaming replication capability introduced in Post-
greSQL9.0.ThisrecipewilluseoneserverwithtwoparallelPostgreSQLinstallations
insteadofthetypicaltwoormoreservers,eachwithonePostgreSQLinstallation.We
will use two new database clusters in order to keep things simple.
How to do it...
Use the following steps to replicate a PostGIS database:
1. Createdirectoriesfortheprimaryandstandbydatabaseclustersbyexecuting
the following commands:
> mkdir C:\postgis_cookbook\db
> mkdir C:\postgis_cookbook\db\primary
> mkdir C:\postgis_cookbook\db\standby
> mkdir
C:\postgis_cookbook\db\primary\archive
Search WWH ::




Custom Search