Martin Fandel martin.fandel
Thu May 18 04:01:50 PDT 2006
Huh I'm sorry, i've started the slon-daemons wrong (on the same 
dbstring!). Now it works. 

I forgot that a primary key is avaible on the table and that every pkey 
is only UNIQUE :). I know this is very very basic knowledge. Maybe I'm
a little bit out of it today ;).

Am Donnerstag, den 18.05.2006, 10:54 +0200 schrieb Martin Fandel:
> Hi,
> 
> I have a problem to understand the replication-procedure of existing 
> data.
> 
> I have tried it this way:
> 
> - DB1 is master and has 2k records in the table "transactions"
> - DB2 is a new slave with schema only and has 0 transactions in 
>       the table "transactions"
> - the table "transactions" has already a primary key with a not null 
>   constraint BUT NOT a unique constraint. So I have added a new
>   colum with slony's "table add key" command
> - the new key-column is named "_Slony-I_my_cluster_rowID" and is not  
>   serialized for the 2k records. Only new records will be  
>   serialized.
> 
> How can I replicate the existing data? To replicate the existing 
> record, must I serialize the "_Slony-I_my_cluster_rowID" for all 2k
> records?
> 
> Here is my slony skript:
> 
>         #!/bin/bash
>         
>         CLUSTERNAME=my_cluster
>         MASTERDBNAME=mydb
>         SLAVEDBNAME=mydb
>         MASTERHOST=192.168.1.1
>         SLAVEHOST=192.168.1.2
>         REPLICATIONUSER=postgres
>         
>         case $1 in
>                 create)
>                         createdb -U $REPLICATIONUSER -O postgres -h
>         $MASTERHOST $MASTERDBNAME
>                         createdb -U $REPLICATIONUSER -O postgres -h
>         $SLAVEHOST $SLAVEDBNAME
>                         createlang -U $REPLICATIONUSER -h $MASTERHOST
>         plpgsql $MASTERDBNAME
>                         createlang -U $REPLICATIONUSER -h $SLAVEHOST
>         plpgsql $SLAVEDBNAME
>                         pg_dump -i -s -U $REPLICATIONUSER -h $MASTERHOST
>         $MASTERDBNAME | psql -U $REPLICATIONUSER -h $SLAVEHOST
>         $SLAVEDBNAME
>                 ;;
>                 clusteron)
>                         slonik <<_EOF_
>         cluster name = $CLUSTERNAME;
>         node 1 admin conninfo = 'dbname=$MASTERDBNAME host=$MASTERHOST
>         user=$REPLICATIONUSER';
>         node 2 admin conninfo = 'dbname=$SLAVEDBNAME host=$SLAVEHOST
>         user=$REPLICATIONUSER';
>         init cluster ( id=1, comment = 'Master Node');
>         _EOF_
>                 ;;
>                 createset)      
>                         slonik <<_EOF_
>         cluster name = $CLUSTERNAME;
>         node 1 admin conninfo = 'dbname=$MASTERDBNAME host=$MASTERHOST
>         user=$REPLICATIONUSER';
>         node 2 admin conninfo = 'dbname=$SLAVEDBNAME host=$SLAVEHOST
>         user=$REPLICATIONUSER';
>         table add key (node id = 1, fully qualified name =
>         'public.transactions');
>         create set (id=1, origin=1, comment='All transactions');
>         set add table (set id=1, origin=1, id=1, fully qualified name =
>         'public.transactions', comment = 'transactions table');
>         _EOF_
>                 ;;
>                 createstore)
>                         slonik <<_EOF_
>         cluster name = $CLUSTERNAME;
>         node 1 admin conninfo = 'dbname=$MASTERDBNAME host=$MASTERHOST
>         user=$REPLICATIONUSER';
>         node 2 admin conninfo = 'dbname=$SLAVEDBNAME host=$SLAVEHOST
>         user=$REPLICATIONUSER';
>         store node (id=2, comment = 'Slave node');
>         store path (server = 1, client = 2, conninfo='dbname=
>         $MASTERDBNAME host =$MASTERHOST user=$REPLICATIONUSER');
>         store path (server = 2, client = 1, conninfo='dbname=
>         $SLAVEDBNAME host =$SLAVEHOST user=$REPLICATIONUSER');
>         store listen (origin=1, provider = 1, receiver = 2);
>         store listen (origin=2, provider = 2, receiver = 1);
>         _EOF_
>                 ;;
>                 removeset)
>                         slonik <<_EOF_
>         cluster name = $CLUSTERNAME;
>         node 1 admin conninfo = 'dbname=$MASTERDBNAME host=$MASTERHOST
>         user=$REPLICATIONUSER';
>         node 2 admin conninfo = 'dbname=$SLAVEDBNAME host=$SLAVEHOST
>         user=$REPLICATIONUSER';
>         drop set ( id = 1, origin = 1 );
>         _EOF_
>                 ;;
>                 startslon)
>                         slon $CLUSTERNAME "dbname=$MASTERDBNAME user=
>         $REPLICATIONUSER host=$MASTERHOST"
>                         ssh $MASTERHOST
>                 ;;
>                 replicate)
>                         slonik <<_EOF_
>         cluster name = $CLUSTERNAME;
>         node 1 admin conninfo = 'dbname=$MASTERDBNAME host=$MASTERHOST
>         user=$REPLICATIONUSER';
>         node 2 admin conninfo = 'dbname=$SLAVEDBNAME host=$SLAVEHOST
>         user=$REPLICATIONUSER';
>         subscribe set ( id = 1, provider = 1, receiver = 2, forward =
>         no);
>         _EOF_
>                 ;;
>         esac
> 
> The skript is called this way:
> 
>         slony.sh create
>         slony.sh clusteron
>         slony.sh createset
>         slony.sh createstore
>         slony.sh startslon
>         slony.sh replicate #loop
>         
>         
> Thanks a lot!
> 
> Regards,
> 
> Martin
> 
> _______________________________________________
> Slony1-general mailing list
> Slony1-general at gborg.postgresql.org
> http://gborg.postgresql.org/mailman/listinfo/slony1-general




More information about the Slony1-general mailing list