[Bucardo-general] Replication problems? data overwritten?

Michelle Sullivan michelle at sorbs.net
Mon Aug 26 14:13:57 UTC 2013


eric machine wrote:
> Hi Michelle,
>
> Thanks for the kind opinion.
>
> I tried below here.
>
> bucardo install
> bucardo add database dbbranch1 host=192.168.56.12 dbname=branch1
> bucardo add database dbbranch2 host=192.168.56.13 dbname=branch2
> bucardo add database dbbranch3 host=192.168.56.14 dbname=branch3
> bucardo add database dbhq host=192.168.56.11 dbname=dbhq
> bucardo add all tables db=dbhq -T nopktable herd=therd
> bucardo add dbgroup tgroup dbbranch1:source dbbranch2:source
> dbbranch3:source dbhq:target
> bucardo add sync foobar herd=therd dbs=tgroup ping=false autokick=0
> checktime=300
> bucardo validate foobar
> bucardo start
> bucardo kick foobar
> bucardo status
> bucardo update sync foobar autokick=1
> bucardo reload config
>
> a) It works. But weird? I insert couple of records after entering the
> above commands. How come the first 1 - 2 minutes, show records not
> found. After that, it will show good status. Any idea why?

Because the status is only set after the first successful sync...

>
> b) I have set dbhq as the only target. But how come when I insert data
> into dbbranch2, the data get replicated into both dbbranch1 and dbhq?
> Any idea why?

I'm not running 5 yet - but from my understanding your config would
indicate multimaster between dbbranch1, dbbranch2 and dbbranch3 with the
dbhq being a slave.
>
> c) to get my data replication working, I manually go to each dbs above
> and set sequence id as follows.
>
> hq:
> ALTER SEQUENCE $schema start with 1 maxvalue 999999999;
>
> dbbranch1:-
> ALTER SEQUENCE $schema start with 1000000000 maxvalue 1999999999;
> SELECT setval('$schema'::regclass, (select last_value from $schema) +
> 1000000000);
>
> dbbranch2:-
> ALTER SEQUENCE $schema start with 2000000000 maxvalue 2999999999;
> SELECT setval('$schema'::regclass, (select last_value from $schema) +
> 2000000000);
>
> dbbranch3:-
> ALTER SEQUENCE $schema start with 3000000000 maxvalue 3999999999;
> SELECT setval('$schema'::regclass, (select last_value from $schema) +
> 3000000000);
>
> Note: my assumption is i doubt each database will ever hit sequence of
> 1 billion records. Plus the sequence maxvalue is bigint. I assume this
> works right?
>
> Is this the best practice? odd and even only work for 2 databases. Now
> I have 4 databases.

You could also do:

ALTER SEQUENCE $schema start with 1 INCREMENT BY 10;
ALTER SEQUENCE $schema start with 2 INCREMENT BY 10;
ALTER SEQUENCE $schema start with 3 INCREMENT BY 10;
ALTER SEQUENCE $schema start with 4 INCREMENT BY 10;
ALTER SEQUENCE $schema start with 5 INCREMENT BY 10;
ALTER SEQUENCE $schema start with 6 INCREMENT BY 10;
ALTER SEQUENCE $schema start with 7 INCREMENT BY 10;
ALTER SEQUENCE $schema start with 8 INCREMENT BY 10;
ALTER SEQUENCE $schema start with 9 INCREMENT BY 10;
ALTER SEQUENCE $schema start with 10 INCREMENT BY 10;

.. if you had 10 DBs and/or wanted to expand to 10 DBs...  Your
'increment by' sets the number of possible DBs in your config.



>
> d) For autokick, how come I can't set this at the first time?
>
> bucardo add sync foobar herd=therd dbs=tgroup ping=false autokick=1
> checktime=300  // this won't work? if I do "bucardo status all", it
> will show autokick = no
>
Try 'yes' or 'on'... otherwise it's a question for Greg/David to answer
(I'm not a developer of Bucardo.)
> but once I do the "bucardo update sync foobar autokick=1", then it
> will set autokick = 1. That's weird.
>
> e) for production use, should i run a .sh script for the above commands?

If its tested and you're sure it's working... I don't know your setup,
only this synopsis so can't guarantee it will work or not...

Regards,

-- 
Michelle Sullivan
http://www.mhix.org/



More information about the Bucardo-general mailing list