• Non ci sono risultati.

Adding Shared Objects to an Existing Single-Source Environment

Adding Shared Objects to an Existing Single-Source Environment

You add existing database objects to an existing single-source environment by adding the necessary rules to the appropriate capture processes, propagations, and apply processes. Before creating or altering capture or propagation rules in a running

Streams environment, make sure any propagations or apply processes that will receive LCRs as a result of the new or altered rules are configured to handle these LCRs. That is, the propagations or apply processes should exist, and each one should be

associated with rule sets that handle the LCRs appropriately. If these propagations and apply processes are not configured properly to handle these LCRs, then LCRs can be lost.

For example, suppose you want to add a table to a Streams environment that already captures, propagates, and applies changes to other tables. Assume only one capture process will capture changes to this table, and only one apply process will apply changes to this table. In this case, you must add one or more table rules to the following rule sets:

The positive rule set for the apply process that will apply changes to the table

The positive rule set for each propagation that will propagate changes to the table

The positive rule set for the capture process that will capture changes to the table If you perform administrative steps in the wrong order, you can lose LCRs. For example, if you add the rule to a capture process rule set first, without stopping the capture process, then the propagation will not propagate the changes if it does not have a rule that instructs it to do so, and the changes can be lost.

This example assumes that the shared database objects are read-only at the destination databases. If the shared objects are read/write at the destination databases, then the replication environment will not stay synchronized because Streams is not configured to replicate the changes made to the shared objects at the destination databases.

Figure 8–1 shows the additional configuration steps that must be completed to add shared database objects to a single-source Streams environment.

Adding Shared Objects to an Existing Single-Source Environment

Figure 8–1 Example of Adding Shared Objects to a Single-Source Environment

To avoid losing LCRs, you should complete the configuration in the following order:

1. At each source database where shared objects are being added, specify

supplemental logging for the added shared objects. See "Managing Supplemental Logging in a Streams Replication Environment" on page 9-3 for instructions.

2. Either stop the capture process, one of the propagations, or the apply processes:

Use the STOP_CAPTURE procedure in the DBMS_CAPTURE_ADM package to stop a capture process.

Use the STOP_PROPAGATION procedure in the DBMS_PROPAGATION_ADM package to stop a propagation.

Use the STOP_APPLY procedure in the DBMS_APPLY_ADM package to stop an apply process.

3. Add the relevant rules to the rule sets for the apply processes. To add rules to the rule set for an apply process, you can run one of the following procedures:

DBMS_STREAMS_ADM.ADD_TABLE_RULES

DBMS_STREAMS_ADM.ADD_SUBSET_RULES

See Also: Oracle Streams Concepts and Administration for more information about completing these tasks

Destination Database

Source Database

Existing database

link for propagation

Additional configuration includes:

· Supplemental logging specifications for the added shared objects

· Each additional shared object prepared for instantiation

· Appropriate rules for the added objects included the rule sets for the capture process and for the propagations

Additional configuration includes:

· Instantiation SCN set for each additional shared object

· Appropriate rules for the added objects included in the rule sets for the apply process

· · ·

Additional Destination Databases

Adding Shared Objects to an Existing Single-Source Environment

DBMS_STREAMS_ADM.ADD_SCHEMA_RULES

DBMS_STREAMS_ADM.ADD_GLOBAL_RULES

Excluding the ADD_SUBSET_RULES procedure, these procedures can add rules to the positive or negative rule set for an apply process. The ADD_SUBSET_RULES procedure can add rules only to the positive rule set for an apply process.

4. Add the relevant rules to the rule sets for the propagations. To add rules to the rule set for a propagation, you can run one of the following procedures:

DBMS_STREAMS_ADM.ADD_TABLE_PROPAGATION_RULES

DBMS_STREAMS_ADM.ADD_SUBSET_PROPAGATION_RULES

DBMS_STREAMS_ADM.ADD_SCHEMA_PROPAGATION_RULES

DBMS_STREAMS_ADM.ADD_GLOBAL_PROPAGATION_RULES

Excluding the ADD_SUBSET_PROPAGATION_RULES procedure, these procedures can add rules to the positive or negative rule set for a propagation. The ADD_

SUBSET_PROPAGATION_RULES procedure can add rules only to the positive rule set for a propagation.

5. Add the relevant rules to the rule sets used by the capture process. To add rules to a rule set for an existing capture process, you can run one of the following

procedures and specify the existing capture process:

DBMS_STREAMS_ADM.ADD_TABLE_RULES

DBMS_STREAMS_ADM.ADD_SUBSET_RULES

DBMS_STREAMS_ADM.ADD_SCHEMA_RULES

DBMS_STREAMS_ADM.ADD_GLOBAL_RULES

Excluding the ADD_SUBSET_RULES procedure, these procedures can add rules to the positive or negative rule set for a capture process. The ADD_SUBSET_RULES procedure can add rules only to the positive rule set for a capture process.

When you a procedure in the DBMS_STREAMS_ADM package to add the capture process rules, it automatically runs the PREPARE_TABLE_INSTANTIATION, PREPARE_SCHEMA_INSTANTIATION, or PREPARE_GLOBAL_INSTANTIATION procedure in the DBMS_CAPTURE_ADM package for the specified table, specified schema, or entire database, respectively, if the capture process is a local capture process or a downstream capture process with a database link to the source database.

You must run the appropriate procedure to prepare for instantiation manually if any of the following conditions is true:

You use DBMS_RULE_ADM to create or modify rules in a capture process rule set.

You do not add rules for the added objects to a capture process rule set, because the capture process already captures changes to these objects. In this case, rules for the objects can be added to propagations and apply processes in the environment, but not to the capture process.

You use a downstream capture process with no database link to the source database.

If you must prepare for instantiation manually, then see "Preparing Database Objects for Instantiation at a Source Database" on page 10-1 for instructions.

Adding Shared Objects to an Existing Single-Source Environment

6. At each destination database, either instantiate, or set the instantiation SCN for, each database object you are adding to the Streams environment. If the database objects do not exist at a destination database, then instantiate them using export/import, transportable tablespaces, or RMAN. If the database objects already exist at a destination database, then set the instantiation SCNs for them manually.

To instantiate database objects using export/import, first export them at the source database. Next, import them at the destination database. See "Setting Instantiation SCNs Using Export/Import" on page 10-28 for information. Also, see "Instantiating Objects in a Streams Replication Environment" on page 10-3 for information about instantiating objects using export/import, transportable tablespaces, and RMAN.

If you use the original Export utility, then set the OBJECT_CONSISTENT export parameter to y. Regardless of whether you use Data Pump export or original export, you can specify a more stringent degree of consistency by using an export parameter such as FLASHBACK_SCN or FLASHBACK_TIME.

If you use the original Import utility, then set the STREAMS_INSTANTIATION import parameter to y.

To set the instantiation SCN for a table, schema, or database manually, run the appropriate procedure or procedures in the DBMS_APPLY_ADM package at a destination database:

SET_TABLE_INSTANTIATION_SCN SET_SCHEMA_INSTANTIATION_SCN SET_GLOBAL_INSTANTIATION_SCN

When you run one of these procedures at a destination database, you must ensure that every added object at the destination database is consistent with the source database as of the instantiation SCN.

If you run SET_GLOBAL_INSTANTIATION_SCN at a destination database, then set the recursive parameter for this procedure to true so that the instantiation SCN also is set for each schema at the destination database and for the tables owned by these schemas.

If you run SET_SCHEMA_INSTANTIATION_SCN at a destination database, then set the recursive parameter for this procedure to true so that the instantiation SCN also is set for each table in the schema.

If you set the recursive parameter to true in the SET_GLOBAL_

INSTANTIATION_SCN procedure or the SET_SCHEMA_INSTANTIATION_

SCN procedure, then a database link from the destination database to the source database is required. This database link must have the same name as the global name of the source database and must be accessible to the user who executes the procedure. See "Setting Instantiation SCNs Using the DBMS_

APPLY_ADM Package" on page 10-29 for instructions.

Alternatively, you can perform a metadata export/import to set the instantiation SCNs for existing database objects. If you choose this option, then make sure no rows are imported. Also, make sure every added object at the importing destination database is consistent with the source database that performed the export at the time of the export. If you are sharing DML changes only, then table level export/import is sufficient. If you are sharing DDL changes also, then additional considerations apply. See "Setting