Sun.betty alanxzq
Tue Jul 12 04:25:24 PDT 2005
very very Thanks for answer of Christopher Browne . about merge I happen new question and error . If anybody know,Please help me.

>>Sun.betty wrote:
>> Q2: there have a set 1 use setCluster.sh script create.
>>
>> #!/bin/sh
>> CLUSTERNAME=test1
>> MASTERDBNAME=test
>> MASTERPORT=8432
>> SLAVEDBNAME=test
>> SLAVEPORT=8432
>> MASTERHOST=10.10.10.67
>> SLAVEHOST=10.10.10.36
>> REPLICATIONUSER=master
>> PGBENCHUSER=master
>> export CLUSTERNAME MASTERDBNAME MASTERPORT SLAVEDBNAME SLAVEPORT
>> MASTERHOST SLAVEHOST REPLICATIONUSER PGBENCHUSER
>>
>> slonik <<_EOF_
>> cluster name = $CLUSTERNAME;
>>
>> node 1 admin conninfo = 'dbname=$MASTERDBNAME host=$MASTERHOST
>> user=$REPLICATIONUSER';
>> node 2 admin conninfo = 'dbname=$SLAVEDBNAME host=$SLAVEHOST
>> user=$PGBENCHUSER';
>>
>> init cluster ( id=1, comment = 'Master Node');
>>
>> table add key (node id = 1, fully qualified name = 'public.history');
>>
>> create set (id=1, origin=1, comment='All pgbench tables');
>> set add table (set id=1, origin=1, id=1, fully qualified name =
>> 'public.accounts', comment='accounts table');
>> set add table (set id=1, origin=1, id=2, fully qualified name =
>> 'public.branches', comment='branches table');
>> set add table (set id=1, origin=1, id=3, fully qualified name =
>> 'public.tellers', comment='tellers table');
>> set add table (set id=1, origin=1, id=4, fully qualified name =
>> 'public.history', comment='history table', key = serial);
>>
>> 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=$PGBENCHUSER');
>> store listen (origin=1, provider = 1, receiver =2);
>> store listen (origin=2, provider = 2, receiver =1);
>> _EOF_
>>
>> now , want to add a new table to this cluster and set .
>>
>> create table tb_test3 (
>> INFO_ID NUMERIC(6) not null,
>> TO_NAME VARCHAR(256) null,
>> constraint PK_TB_TEST3 primary key (INFO_ID)
>> );
>>
>> I read the document , carry out step maybe like this:
>>
>> step 1 : create table at database test. (at master (node 1))
>>
>> step 2 : pg_dump -U master -h 10.10.10.67 -p 8432 -t tb_test3 test |
>> psql -s -U master -h 10.10.10.36 -p 8432 test
>>
>> (at slave (node 2) keep on master and slave table schema same.)
>>
>> step 3: use script : addSet.sh
>>
>> #!/bin/sh
>>
>> CLUSTERNAME=test1
>> MASTERDBNAME=test
>> MASTERPORT=8432
>> SLAVEDBNAME=test
>> SLAVEPORT=8432
>> MASTERHOST=10.10.10.67
>> SLAVEHOST=10.10.10.36
>> REPLICATIONUSER=master
>> PGBENCHUSER=master
>> export CLUSTERNAME MASTERDBNAME MASTERPORT SLAVEDBNAME SLAVEPORT
>> MASTERHOST SLAVEHOST REPLICATIONUSER PGBENCHUSER
>> slonik <<_EOF_
>> cluster name = $CLUSTERNAME;
>> node 1 admin conninfo = 'dbname=$MASTERDBNAME host=$MASTERHOST
>> user=$REPLICATIONUSER';
>> node 2 admin conninfo = 'dbname=$SLAVEDBNAME host=$SLAVEHOST
>> user=$PGBENCHUSER';
>> create set (id=5, origin=1, comment='add tb_test3 tables');
>> set add table (set id=5, origin=1, id=7, fully qualified name =
>> 'public.tb_test3', comment='tb_test3 table');
>> _EOF_
 
>> step 4: use script merge.sh merge set 1 and set 5 merge to set 1
>>
>> #!/bin/sh
>>
>> CLUSTERNAME=test1
>> MASTERDBNAME=test
>> MASTERPORT=8432
>> SLAVEDBNAME=test
>> SLAVEPORT=8432
>> MASTERHOST=10.10.10.67
>> SLAVEHOST=10.10.10.36
>> REPLICATIONUSER=master
>> PGBENCHUSER=master
>> export CLUSTERNAME MASTERDBNAME MASTERPORT SLAVEDBNAME SLAVEPORT
>> MASTERHOST SLAVEHOST REPLICATIONUSER PGBENCHUSER
>> slonik <<_EOF_
>> cluster name = $CLUSTERNAME;
>> node 1 admin conninfo = 'dbname=$MASTERDBNAME host=$MASTERHOST
>> user=$REPLICATIONUSER';
>> node 2 admin conninfo = 'dbname=$SLAVEDBNAME host=$SLAVEHOST
>> user=$PGBENCHUSER';
>> MERGE SET ( ID = 1,
>> ADD ID = 5,
>> ORIGIN = 1 );
>> _EOF_
>Christopher Browne  answer  for :
>
>It seems reasonably clear in the documentation.
>
>For MERGE SET...
>
>ID = ival indicates the set to contain the union of the two separate sets.
>
>If you plan to merge sets 1 and 2 together to get a new set 1, then "ID = 1"
>
>ADD ID = ival indicates the unique id of the set whose objects should be
>transferred. That would be set #2.
>
>ORIGIN is the current origin node for both sets; that appears to be node #1.
>

My new quesion :
I modify merge.sh 
MERGE SET ( ID = 1 , ADD ID = 5, ORIGIN = 1 );
purpose is : merge set 1 add set 5 to set 1 .

but exex merge.sh show errors:
bash-2.03$ ./merge.sh
<stdin>:4: PGRES_FATAL_ERROR select "_test1".mergeSet(1, 5);  - ERROR:  Slony-I: subscriber lists of set 1 and 5 are different

look system table :
test=# select * from _test1.sl_set         ; 
 set_id | set_origin | set_locked |     set_comment     
--------+------------+------------+---------------------
      1 |          1 |            | All pgbench tables
      2 |          1 |            | All pgbench tables
      3 |          1 |            | All pgbench tables
      4 |          1 |            | All pgbench tables
      5 |          1 |            | add tb_test3 tables
(5 rows)

test=# select * from _test1.sl_table       ;
 tab_id | tab_reloid | tab_relname | tab_nspname | tab_set |           tab_idxname            | tab_altered |  tab_comment   
--------+------------+-------------+-------------+---------+----------------------------------+-------------+----------------
      1 |     319045 | accounts    | public      |       1 | accounts_pkey                    | t           | accounts table
      2 |     319037 | branches    | public      |       1 | branches_pkey                    | t           | branches table
      3 |     319041 | tellers     | public      |       1 | tellers_pkey                     | t           | tellers table
      4 |     419364 | history     | public      |       1 | history__Slony-I_test1_rowID_key | t           | history table
      5 |     547522 | tb_test1    | public      |       2 | pk_tb_test1                      | t           | tb_test1 table
      6 |     548223 | tb_test2    | public      |       4 | pk_tb_test2                      | t           | tb_test2 table
      7 |     580442 | tb_test3    | public      |       5 | pk_tb_test3                      | t           | tb_test3 table
(7 rows)

what reason lead show this error ? if you know please,give some tip for me .Thanks very much !

		
---------------------------------
DO YOU YAHOO!?
  ????G??????????????????? 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gborg.postgresql.org/pipermail/slony1-general/attachments/20050712/6d57e03c/attachment.html


More information about the Slony1-general mailing list