This document should get you up and running with a replicated PostgreSQL database in just a few steps. We'll gloss over many details in the interest of getting you up and running as quickly as possible. To make things simple, this document will use the sample cluster configuration found in the "bruce/sample" directory of the distribution. The example uses a single PostgreSQL installation with 4 databases.
bruce_config - This database contains the cluster configuration metadata. This includes cluster names and identifiers, master database uri's and descriptive names, slave database uri's and descriptive names, and regular expression patterns to determine which tables are replicated.bruce_master - The master database. All modifications to replicated tables are made to this database and subsequently replicated to each slave.bruce_slave_1 - A slave database. All modifications to the master database are replicated here.bruce_slave_2 - A slave database. All modifications to the master database are replicated here.The master and each slave have a replication_test schema and a replication_test.replicate_this table that we will replicate across the cluster.
Note: This demonstration makes the assumption that all replicated clusters in the schema contain identical data.
The steps in this guide are loosely followed in test/src/com/netblue/bruce/SetupClusterFromExistingDbAcceptanceTest.java
tar xvzf bruce-0.1a.tgzcd release/binchmod 755 *.shcd $BRUCE/samplevi config.xml (change db urls to point to your databases for each node)cd $BRUCE/bin./admin.sh -data ../sample/config.xml -initnodeschema -initsnapshots MASTER -loadschema -operation CLEAN_INSERT -url jdbc:postgresql://localhost:5432/bruce_config?user=bruce -pass bruce-data ../sample/config.xml tells us what data file to load. the sample file contains 1 master and 2 slaves with replication patterns to recognize the replication_test.* tables.
-initnodeschema tells us to install the replication schema on each node, along with the triggers for each replicated table. If the schema is already installed, then only the replication triggers are installed for each replicated table. For master nodes, if there is no data in the snapshotlog table (as in this case) a snapshot of the db is taken.
-initsnapshots MASTER tells us to set the slave snapshot status to the last snapshot in the master database. Since the -initnodeschema option initializes this for us, we'll use that.
-loadschema tells us to install the replication node topology schema on the configuration database. This is only really useful the first time you run the admin tool for a given configuration database.
-operation CLEAN_INSERT tells us to drop everything from the node topology configuration database before inserting these new nodes
-url is the URL for the configuration database
-pass is the password for the configuration database