Adding new tables
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 | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Ensure that the appropriate privileges are given to the Dbvisit Replicate owner on both the source and target. The privileges are:
Section | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
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.
Loading data before table is added to replication
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 process is resumed (which would cause replication conflicts on the source server). It is necessary to label the data for the 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:
...
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:
Panel | ||
---|---|---|
| ||
dbvrep> choose show dbvrep> pause apply
|
2. Prepare the new table
Dbvisit Replicate will give the SCN of where the table will be replicated from.
Panel | ||
---|---|---|
| ||
dbvrep>dbvrep> choose showis a APPLY is a APPLY.dbvrep> dbvrep> prepare table SCHEMA_RECREATE.schema_recreate_tblrunning mine running mine [SCHEMA_RECREATE.schema_recreate_tbl]: [Table (un)prepared (4 internal records).]dbvrep> dbvrep> choose replication MINE1dbvrep> dbvrep>show choose show choosedbvrep> dbvrep> choose showis a APPLY is a APPLY.dbvrep> dbvrep> prepare table SCHEMA_RECREATE.schema_recreate_tblrunning mine running mine [SCHEMA_RECREATE.schema_recreate_tbl]: [Table (un)prepared (4 internal records).]dbvrep> dbvrep> |
3. Synchronize data
Use the SCN from step 2 to load the historical data (Example use datapump with flashback_scn=xxx)
Panel | ||
---|---|---|
| ||
dbvrep>dbvrep> show apply_database |
Panel | ||
---|---|---|
| ||
SET TRANSACTION NAME 'DBREPL_DB_UNITSRC_XID_UNITSRC';insert into insert into SCHEMA_RECREATE.schema_recreate_tbl (id, member)select id select id, member from SCHEMA_RECREATE.schema_recreate_tbl@unittrgas of scn 43298074; as of scn 43298074; |
Panel | ||
---|---|---|
| ||
SET TRANSACTION NAME 'DBREPL_DB_UNITTRG_XID_UNITTRG';insert into insert into SCHEMA_RECREATE.schema_recreate_tbl (id, member)select id select id, member from SCHEMA_RECREATE.schema_recreate_tbl@unitsrcas of scn 43348595 as of scn 43348595; |
4. Resume the replication
Panel | ||
---|---|---|
| ||
dbvrep>dbvrep> choose replication MINEdbvrep> dbvrep> resume applyApply requested Apply requested to resume.dbvrep> dbvrep> choose replication MINE1dbvrep> dbvrep> resume apply1Apply requested Apply requested to resume. |
Note that the table needs to exist on the target side before the apply process can be resumed. Using a datapump in step 3 is a good choice, since the import creates table automatically if it does not exist.
...
Removing tables & schemas