This sample does the following actions:
* sets up the databases
- - creates a database 'l3simple_db1', which will be master
+ - creates a database 'l3simple', on host which will be master
- populates this with pgbench schema and data
- adds primary and foreign keys to make the db more realistic
- - makes a copy of the database ('l3simple_db2') to be used as slave
+ - makes a copy of the database on another node to be used as slave
* sets up replication from the master to slave database
- - creates the root node on 'l3simple_db1'
- - creates a leaf node on 'l3simple_db2'
- - starts the ticker daemon
+ - creates the root node on the master node
+ - creates a leaf node on the slave node
+ - starts the ticker daemon on the master node
- adds all tables to replication set on both databases
- waits for the replication to complete
Run the following SQL:
----
-CREATE DATABASE l3simple_db1;
+CREATE DATABASE l3simple;
----
=== Set up pgbench schema ===
Run command :
----
-/usr/lib/postgresql/9.1/bin/pgbench -i -s 2 -F 80 l3simple_db1
+pgbench -i -s 2 -F 80 l3simple
----
=== And add primary and foreign keys needed for replication ===
then load it into database:
----
-psql l3simple_db1 -f /tmp/prepare_pgbenchdb_for_londiste.sql
+psql l3simple -f /tmp/prepare_pgbenchdb_for_londiste.sql
----
pg_dump -s l3simple_db1 | psql l3simple_db2
----
-Create configuration file st3simple/st3_l3simple_db1.ini
+Create configuration file st3simple/st3_l3simple_primary.ini
----
[londiste3]
----
+REMINDER: open trust to the leaf host in pg_hba.conf, or add a user to auth as and include in the connstring
+
Create Londiste root node:
----
-londiste3 st3simple/st3_l3simple_db1.ini create-root node1 dbname=l3simple_db1
+londiste3 st3simple/st3_l3simple_primary.ini create-root node1 "dbname=l3simple host=10.199.59.194"
----
Run worker daemon for root node:
----
-londiste3 -d st3simple/st3_l3simple_db1.ini worker
+londiste3 -d st3simple/st3_l3simple_primary.ini worker
----
-Create configuration file st3simple/st3_l3simple_db2.ini
+Create configuration file st3simple/st3_l3simple_leaf.ini
for worker daemon on target node:
----
[londiste3]
-job_name = st3_l3simple_db2
-db = dbname=l3simple_db2
+job_name = st3_l3simple_leaf
+db = dbname=l3simple
queue_name = replika
-logfile = st3simple/log/st3_l3simple_db2.log
-pidfile = st3simple/pid/st3_l3simple_db2.pid
+logfile = st3simple/log/st3_l3simple_leaf.log
+pidfile = st3simple/pid/st3_l3simple_leaf.pid
----
Initialize node in target database:
----
-londiste3 st3simple/st3_l3simple_db2.ini create-leaf node2 dbname=l3simple_db2 --provider=dbname=l3simple_db1
+londiste3 st3simple/st3_l3simple_leaf.ini create-leaf node2 dbname=l3simple --provider="dbname=l3simple host=10.199.59.194"
----
Launch worker daemon for target database:
----
-londiste3 -d st3simple/st3_l3simple_db2.ini worker
+londiste3 -d st3simple/st3_l3simple_leaf.ini worker
----
Create config file `st3simple/pgqd.ini` for PgQ ticker daemon:
run the following command in background:
----
-/usr/lib/postgresql/9.1/bin/pgbench -T 120 -c 5 l3simple_db1 -f /tmp/throttled.pgbench
+pgbench -T 120 -c 5 l3simple -f /tmp/throttled.pgbench
----
The /tmp/throttled.pgbench contains the standard pgbench workload, except that
Run command :
----
-londiste3 st3simple/st3_l3simple_db1.ini add-table --all
-londiste3 st3simple/st3_l3simple_db2.ini add-table --all
+londiste3 st3simple/st3_l3simple_primary.ini add-table --all
+londiste3 st3simple/st3_l3simple_leaf.ini add-table --all
----
database connections generating database traffic for 10 seconds:
----
-/usr/lib/postgresql/9.1/bin/pgbench -T 10 -c 5 l3simple_db2
+pgbench -T 10 -c 5 l3simple
----
After this is done, you can check that the tables on both sides have the same data:
----
-londiste3 st3simple/st3_l3simple_db2.ini compare
+londiste3 st3simple/st3_l3simple_leaf.ini compare
----
Compare command will establish the same logical point in time on provider and
== Done ==
The setup of simple 2 node cluster is done.
+