Vivek Khera vivek
Thu Sep 30 16:21:33 PDT 2004
In my playing around and learning the ins and outs of slony, I decided 
to recreate the pgbench "hello world" replication test using the 
altperl scripts.

It was quite trivial.  The two files are included at the end of this 
message.

Things I found out:  the altperl slon_start script doesn't create the 
directories needed for logging.  You must create the subdirectories of 
the log dir: "slony1" and within that "nodeN" for each node 1 .. N 
ahead of time.

Also, the slony.env file should end with "1;" to ensure proper return 
value from the require.  Ditto for any $SLONYSET or $SLONYNODES files 
you use instead via the environment variables.

Then it just becomes a matter of doing this for the full test:


First, set the environment like the README for MASTERHOST, SLAVEHOST, 
etc.

setenv SLONYSET $PWD/slonyset
setenv SLONYNODES $PWD/slonynodes

createdb -U $REPLICATIONUSER -O $PGBENCHUSER -h $MASTERHOST 
$MASTERDBNAME
createdb -U $REPLICATIONUSER -O $PGBENCHUSER -h $SLAVEHOST $SLAVEDBNAME
./pgbench -i -s 1 -U $PGBENCHUSER -h $MASTERHOST $MASTERDBNAME
createlang -U $REPLICATIONUSER -h $MASTERHOST plpgsql $MASTERDBNAME
pg_dump -s -U $REPLICATIONUSER -h $MASTERHOST $MASTERDBNAME | psql -U 
$REPLICATIONUSER -h $SLAVEHOST $SLAVEDBNAME

perl init_cluster.pl
perl slon_start.pl node1
perl slon_start.pl node2

perl create_set.pl set1
perl subscribe_set.pl set1 node2

and then you're replicating.

run pgbench some more and do the compare as in the slony README.

here is slonynodes:

--cut here--
#!/usr/bin/perl

$SETNAME=$ENV{CLUSTERNAME};
$LOGDIR='/tmp';
$SLON_BIN_PATH='/usr/local/bin';

add_node(
          host => $ENV{MASTERHOST},
          dbname => $ENV{MASTERDBNAME},
          user => $ENV{REPLICATIONUSER},
          node => 1,
         );

add_node(
          host => $ENV{SLAVEHOST},
          dbname => $ENV{SLAVEDBNAME},
          user => $ENV{REPLICATIONUSER},
          node => 2,
          parent => 1,
         );

1;
--cut here--


and the slonyset file:

--cut here--
#! /usr/local/bin/perl

$TABLE_ID=1;

@PKEYEDTABLES = qw(
                         accounts
                         branches
                         tellers
                   );

%KEYEDTABLES = ();
@SERIALTABLES = (
                         history
                 );

@SEQUENCES = qw(
                );

1;
--cut here--
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2476 bytes
Desc: not available
Url : http://gborg.postgresql.org/pipermail/slony1-general/attachments/20040930/fdcd4254/smime.bin


More information about the Slony1-general mailing list