Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Once the 2-way replication has been configured and is running, new objects can be added to the replication. 
New tables can be replicated with the command:

Section
Column
width5%

 

Column
width95%
Panel No Format
bgColorCCC
dbvrep>
dbvrep> PREPARE 
TABLE 
TABLE schema.table_name

 

Ensure that the appropriate privileges are given to the Dbvisit Replicate owner on both the source and target. The privileges are:

Section
Column
width5%

 

Column
width95%
panel No Format
bgColorCCC
SQL> grant select, update, insert, delete to dbvrep;

 

If a DDL replication was enabled during the Setup Wizard (Step 2 - Replication pairs), the Dbvisit Replicate owner on the target database already has SELECT/INSERT/UPDATE/DELETE ANY privileges. No other grants should be necessary.

...

When a new table is added to the replication, it is usually necessary to ensure that the historical data is in the target table before the replication starts.
For 2-way replication this process is slightly more complicated. One cannot simply take a source data as of given SCN and move it to the target server, as these data would be replicated back to the source as soon as the apply APPLY process is resumed (which would cause replication conflicts on the source server). It is necessary to label the data for the apply APPLY process to recognize it and ignore it.
To ensure data is synchronized correctly and there is no gap between loading the historical data and starting the replication, follow these steps:

Note

In the following example we are using a 2-way configuration described by this table:

 

UNITSRC UNITTRG
MINE>>>APPLY
APPLY1<<<MINE1


1. Pause the

...

APPLY processes

It is necessary to pause the

...

APPLY process for both replication directions. To do so choose one replication, pause the first

...

APPLY process and then choose the second replication a pause the second

...

APPLY process:

Panelnoformat
bgColorCCC
dbvrep>dbvrep> choose show
Process MINE chosen, it is a MINE.
Process APPLY chosen, it is a APPLY. 
 dbvrep> dbvrep> pause apply
Apply requested to pause. dbvrep> dbvrep> choose replication mine1
Process type MINE set to: mine1.
Process type APPLY set to: APPLY1.dbvrep> dbvrep> choose show
Process mine1 chosen, it is a MINE.
Process APPLY1 chosen, it is a APPLY.dbvrep> dbvrep> pause apply1
Apply requested to pause. dbvrep> dbvrep> list status
MINE IS running. Currently at plog 10441 and SCN 43299785 (03/14/2013 11:50:59).
APPLY is PAUSED. Currently at plog 10441 and SCN 43299607 (01/01/1988 00:00:00).
MINE1 IS running. Currently at plog 3298 and SCN 43252417 (03/14/2013 11:50:59).
APPLY1 is PAUSED. Currently at plog 3298 and SCN 43252398 (03/14/2013 11:50:49).


2. Prepare the new table

The new table has to be prepared on both sides. For each database, Dbvisit Replicate will give the SCN of where the table will be replicated from. 
To prepare the table choose the first replication, run the PREPARE TABLE command, then choose the second replication and run the PREPARE TABLE command again: 

Panelnoformat
bgColorCCC
dbvrep>dbvrep> choose show
Process MINE chosen, it is a MINE.
Process APPLY chosen, it is is a APPLY.
dbvrep> APPLY. dbvrep> prepare table SCHEMA_RECREATE.schema_recreate_tbl
Connecting to running apply [SCHEMA_RECREATE.schema_recreate_tbl]: [Apply table removed (0 metadata record(s)). Apply table added (1 metadata record(s)).]
Connecting to running running mine  [SCHEMA_RECREATE.schema_recreate_tbl]: [Table (un)prepared (4 internal records).]
Table SCHEMA_RECREATE.schema_recreate_tbl instantiated at SCN 43348595
Panelnoformat
bgColorCCC
dbvrep>dbvrep> choose replication MINE1
Process type MINE set to: MINE1.
Process type APPLY set to: APPLY1.
dbvrep> dbvrep> choose show
Process MINE1 chosen, it is a MINE.
Process APPLY1 chosen, it is is a APPLY.
dbvrep> APPLY. dbvrep> prepare table SCHEMA_RECREATE.schema_recreate_tbl
Connecting to running apply [SCHEMA_RECREATE.schema_recreate_tbl]: [Apply table removed (0 metadata record(s)). Apply table added (1 metadata record(s)).]
Connecting to running running mine  [SCHEMA_RECREATE.schema_recreate_tbl]: [Table (un)prepared (4 internal records).]
Table SCHEMA_RECREATE.schema_recreate_tbl instantiated at SCN 43298074

3. Synchronize data

Use the

...

SCNs from step 2 to load the historical data

...

 

...

.
For 2-way replication you cannot simply move the historical data from the database A to B and vice versa, because Dbvisit Replicate would try to replicate this data back as soon as the APPLY processes are resumed. This would cause the data corruption and replication conflicts, as the data is already in both databases. 

To synchronize the data properly, use the named Oracle transaction. Dbvisit Replicate engine will recognize the name of the transaction and will not replicate any change done by such transaction.

Run the following command to obtain an APPLY database name:

No Format
bgColorCCC
dbvrep>dbvrep> show apply_database
APPLY1.APPLY_DATABASE = UNITSRC
APPLY.APPLY_DATABASE = UNITTRG
APPLY1.APPLY_DATABASE_DBID = 433515465
*.APPLY_DATABASE =
APPLY.APPLY_DATABASE_DBID = 742136697
*.APPLY_DATABASE_DBID =

 

 

 

...

To move the data from the database UNITTRG to the database UNITSRC set the transaction name to DBREPL_DB_UNITSRC_XID_xxx, where "xxx" is APPLY1.APPLY_DATABASE value obtained earlier. 

Use the database link to select the data from the UNITTRG database using the SCN given by the PREPARE TABLE command. Notice the MINUS clause to omit a data common to both tables.

On UNITSRC database run:

No Format
bgColorCCC
SET TRANSACTION NAME 'DBREPL_DB_UNITSRC_XID_UNITSRC';
insert into into SCHEMA_RECREATE.schema_recreate_tbl (id, member)
select id SELECT id, member from FROM SCHEMA_RECREATE.schema_recreate_tbl@unittrg
as of scn 43298074;

 

 

panel

      AS OF SCN 43298074
    MINUS SELECT id, member     
            FROM SCHEMA_RECREATE.schema_recreate_tbl;
COMMIT;

To move the data from UNITSRC to UNITTRG repeat the previous steps using the APPLY.APPLY_DATABASE value for the transaction name, the database link to UNITSRC and the SCN given by PREPARE TABLE.

On UNITTRG database run:

No Format
bgColorCCC
SET TRANSACTION NAME 'DBREPL_DB_UNITTRG_XID_UNITTRG';
insert into into SCHEMA_RECREATE.schema_recreate_tbl (id, member)
select id SELECT id, member from FROM SCHEMA_RECREATE.schema_recreate_tbl@unitsrc
as of scn 43348595 AS OF SCN 43348595 MINUS SELECT id, member FROM SCHEMA_RECREATE.schema_recreate_tbl; COMMIT;

4. Resume the replication

 

 

...

Resume both the APPLY and APPLY1 processes:

No Format
bgColorCCC
dbvrep>dbvrep> choose replication MINE
Process type MINE set to: MINE.
Process type APPLY set to: APPLY.
dbvrep> dbvrep> resume apply
Apply requested requested to resume.dbvrep> dbvrep> choose replication MINE1
Process type MINE set to: MINE1.
Process type APPLY set to: APPLY1.
dbvrep> dbvrep> resume apply1
Apply requested requested to resume.

...

Adding new schemas

To add a new schema to the 2-way replication, use the following command:

No Format
borderColorggg
dbvrep> PREPARE SCHEMA schema_name

Note that

...

Adding new schemas

...

for every table within the schema you have to synchronize the data as described above. These are the steps to follow:

Pause the APPLY processes for both replication directions .

Run the PREPARE SCHEMA command for both replications.

Synchronize the data for all tables (using transaction names as shown above)

Resume both APPLY processes

Removing tables & schemas

To manually remove a table from the replication, use the UNPREPARE TABLE command for both directions:

No Format
borderColorggg
dbvrep> choose show
Process MINE1 chosen, it is a MINE.
Process apply1 chosen, it is a APPLY.

dbvrep> unprepare table SCHEMA_RECREATE.schema_recreate_tbl
Connecting to running mine [SCHEMA_RECREATE.SCHEMA_RECREATE_TBL]: [Table (un)prepared (4 internal records).]
Connecting to running apply:[Apply table removed (1 metadata record(s)). Apply table added (0 metadata record(s)).]
Table SCHEMA_RECREATE.schema_recreate_tbl processed.
dbvrep> choose replication MINE
Process type MINE set to: MINE.
Process type APPLY set to: APPLY.
dbvrep> unprepare table SCHEMA_RECREATE.schema_recreate_tbl
Connecting to running mine [SCHEMA_RECREATE.SCHEMA_RECREATE_TBL]: [Table (un)prepared (4 internal records).]
Connecting to running apply:[Apply table removed (1 metadata record(s)). Apply table added (0 metadata record(s)).]
Table SCHEMA_RECREATE.schema_recreate_tbl processed.

Use UNPREPARE SCHEMA command to manually remove the whole schema.