E Online Upgrade of an Earlier Database with Oracle Streams
This appendix describes how to perform a database upgrade from one of the following Oracle Database releases with Oracle Streams:
-
Oracle Database 10g Release 1 (10.1)
-
Oracle9i Release 2 (9.2)
The database upgrade operation described in this appendix uses the features of Oracle Streams to achieve little or no database down time.
The following topics describe performing an online database upgrade with Oracle Streams:
See Also:
Online Database Upgrade and Maintenance with Oracle Streams for information about upgrading from Oracle Database 10g Release 2 (10.2) or later and for information about performing other database maintenance operations with Oracle Streams
E.1 Overview of Using Oracle Streams in the Database Upgrade Process
An Oracle database upgrade is the process of transforming an existing, prior release of an Oracle database into the current release. A database upgrade typically requires substantial database down time, but you can perform a database upgrade with little or no down time by using the features of Oracle Streams. To do so, you use Oracle Streams to configure a replication environment with the following databases:
-
Source Database: The original database that is being upgraded.
-
Capture Database: The database where a capture process captures changes made to the source database during the upgrade.
-
Destination Database: The copy of the source database where an apply process applies changes made to the source database during the upgrade process.
Specifically, you can use the following general steps to perform a database upgrade while the database is online:
-
Create an empty destination database.
-
Configure an Oracle Streams replication environment where the original database is the source database and a copy of the database is the destination database for the changes made at the source.
-
Perform the database upgrade on the destination database. During this time the original source database is available online.
-
Use Oracle Streams to apply the changes made at the source database to the destination database.
-
When the destination database has caught up with the changes made at the source database, take the source database offline and make the destination database available for applications and users.
Figure E-1 provides an overview of this process.
Figure E-1 Online Database Upgrade with Oracle Streams
![Description of Figure E-1 follows Description of Figure E-1 follows](img/strms052.gif)
Description of "Figure E-1 Online Database Upgrade with Oracle Streams"
E.1.1 The Capture Database During the Upgrade Process
During the upgrade process, the capture database is the database where the capture process is created. Downstream capture was introduced in Oracle Database 10g Release 1 (10.1). If you are upgrading a database from Oracle Database 10g Release 1, then you have the following options:
-
A local capture process can be created at the source database during the upgrade process.
-
A downstream capture process can be created at the destination database. If the destination database is the capture database, then a propagation from the capture database to the destination database is not needed.
-
A third database can be the capture database. In this case, the third database can be an Oracle Database 10g Release 1 or later database.
However, if you are upgrading a database from Oracle9i Release 2 (9.2) to Oracle Database 11g Release 2 or later, then downstream capture is not supported, and a local capture process must be created at the source database.
A downstream capture process reduces the resources required at the source database during the upgrade process, but a local capture process is easier to configure. Table E-1 describes which database can be the capture database during the upgrade process.
Table E-1 Supported Capture Database During Upgrade
Existing Database Release | Capture Database Can Be Source Database? | Capture Database Can Be Destination Database? | Capture Database Can Be Third Database? |
---|---|---|---|
9.2 |
Yes |
No |
No |
10.1 |
Yes |
Yes |
Yes |
Note:
If you are upgrading from Oracle Database 10g Release 1 (10.1), then, before you begin the upgrade, decide which database will be the capture database.
See Also:
E.1.2 Assumptions for the Database Being Upgraded
The instructions in this appendix assume that all of the following statements are true for the database being upgraded:
-
The database is not part of an existing Oracle Streams environment.
-
The database is not part of an existing logical standby environment.
-
No tables at the database are master tables for materialized views in other databases.
-
No messages are enqueued into user-created queues during the upgrade process.
E.1.3 Considerations for Job Queue Processes and PL/SQL Package Subprograms
If possible, ensure that no job queue processes are created, modified, or deleted during the upgrade process, and that no Oracle-supplied PL/SQL package subprograms are invoked during the upgrade process that modify both user data and dictionary metadata at the same time. The following packages contain subprograms that modify both user data and dictionary metadata at the same time: DBMS_RLS
, DBMS_STATS
, and DBMS_JOB
.
It might be possible to perform such actions on the database if you ensure that the same actions are performed on the source database and destination database in Steps 13 and 14 in "Task 5: Finishing the Upgrade and Removing Oracle Streams". For example, if a PL/SQL procedure gathers statistics on the source database during the upgrade process, then the same PL/SQL procedure should be invoked at the destination database in Step 14.
E.2 Preparing for a Database Upgrade Using Oracle Streams
The following sections describe tasks to complete before starting the database upgrade with Oracle Streams:
E.2.1 Preparing to Upgrade a Database with User-Defined Types
User-defined types include object types, REF
values, varrays, and nested tables. Currently, Oracle Streams capture processes and apply processes do not support user-defined types. This section discusses using Oracle Streams to perform a database upgrade on a database that has user-defined types.
One option is to ensure that no data manipulation language (DML) or data definition language (DDL) changes are made to the tables that contain user-defined types during the database upgrade. In this case, these tables are instantiated at the destination database, and no changes are made to these tables during the entire operation. After the upgrade is complete, make the tables that contain user-defined types read/write at the destination database.
If tables that contain user-defined types must remain open during the upgrade, then use the following general steps to retain changes to these tables during the upgrade:
- Before you begin the upgrade process described in "Performing a Database Upgrade Using Oracle Streams", create one or more logging tables to store row changes to tables at the source database that include user-defined types. Each column in the logging table must use a data type that is supported by Oracle Streams in the source database release.
- Before you begin the upgrade process described in "Performing a Database Upgrade Using Oracle Streams", create a DML trigger at the source database that fires on the tables that contain the user-defined data types. The trigger converts each row change into relational equivalents and logs the modified row in a logging table created in Step 1.
- When the instructions in "Performing a Database Upgrade Using Oracle Streams" say to configure a capture process and propagation, configure the capture process and propagation to capture changes to the logging table and propagate these changes to the destination database. Changes to tables that contain user-defined types must not be captured or propagated.
- When the instructions in "Performing a Database Upgrade Using Oracle Streams" say to configure a an apply process on the destination database, configure the apply process to use a procedure DML handler that processes the changes to the logging tables. The procedure DML handler reconstructs the user-defined types from the relational equivalents and applies the modified changes to the tables that contain user-defined types.
For instructions, go to the My Oracle Support (formerly OracleMetaLink) Web site using a Web browser:
http://support.oracle.com/
Database bulletin 556742.1 describes additional data type support for Oracle Streams.
See Also:
-
Oracle Database PL/SQL Language Reference for more information about creating triggers
E.2.2 Deciding Which Utility to Use for Instantiation
Before you begin the database upgrade, decide whether you want to use the Export/Import utilities (Data Pump or original) or the Recovery Manager (RMAN) utility to instantiate the destination database during the operation. The destination database will replace the existing database that is being upgraded.
Consider the following factors when you make this decision:
-
If you use original Export/Import or Data Pump Export/Import, then you can make the destination database an Oracle Database 11g Release 2 (11.2) or later database at the beginning of the operation. Therefore, you do not need to upgrade the destination database after the instantiation.
If you use Export/Import for instantiation, and Data Pump is supported, then Oracle recommends using Data Pump. Data Pump can perform the instantiation faster than original Export/Import.
-
If you use the RMAN
DUPLICATE
command, then the instantiation might be faster than with Export/Import, especially if the database is large, but the database release must be the same for RMAN instantiation. Therefore, the following conditions must be met:-
If the database is an Oracle9i Release 2 (9.2) database, then the destination database is an Oracle9i Database Release 2 database when it is instantiated.
-
If the database is an Oracle Database 10g Release 1 (10.1) database, then the destination database is an Oracle Database 10g Release 1 database when it is instantiated.
After the instantiation, you must upgrade the destination database.
Also, Oracle recommends that you do not use RMAN for instantiation in an environment where distributed transactions are possible. Doing so might cause in-doubt transactions that must be corrected manually.
-
Table E-2 describes whether each instantiation method is supported based on the release being upgraded, whether the platform at the source and destination databases are different, and whether the character set at the source and destination databases are different. Each instantiation method is supported when the platform and character set are the same at the source and destination databases.
Table E-2 Instantiation Methods for Database Upgrade with Oracle Streams
Instantiation Method | Supported When Upgrading From | Different Platforms Supported? | Different Character Sets Supported? |
---|---|---|---|
Original Export/Import |
9.2 or 10.1 |
Yes |
Yes |
Data Pump Export/Import |
10.1 |
Yes |
Yes |
RMAN |
9.2 or 10.1 |
No |
No |
E.3 Performing a Database Upgrade Using Oracle Streams
This section contains instructions for performing a database upgrade using Oracle Streams. These instructions describe using Oracle Streams to upgrade one of the following Oracle Database releases: Oracle9i Release 2 (9.2) or Oracle Database 10g Release 1 (10.1).
Complete the following tasks to upgrade a database using Oracle Streams:
E.3.1 Task 1: Beginning the Upgrade
Complete the following steps to begin the upgrade using Oracle Streams:
E.3.2 Task 2: Setting Up Oracle Streams Before Instantiation
The specific instructions for setting up Oracle Streams before instantiation depend on which database is the capture database. Follow the instructions in the appropriate section:
See Also:
"Overview of Using Oracle Streams in the Database Upgrade Process" for information about the capture database
E.3.2.1 The Source Database Is the Capture Database
Complete the following steps to set up Oracle Streams before instantiation when the source database is the capture database:
E.3.2.2 The Destination Database Is the Capture Database
The database being upgraded must be an Oracle Database 10g Release 1 (10.1) database to use this option. Complete the following steps to set up Oracle Streams before instantiation when the destination database is the capture database:
-
Configure your network and Oracle Net so that the source database and destination database can communicate with each other. See Oracle Database Net Services Administrator's Guide for more information.
-
Follow the instructions in the appropriate section based on the method you are using for instantiation:
Export/Import
Complete the following steps if you are using export/import for instantiation:
-
In SQL*Plus, connect to the destination database
updb.example.com
as the Oracle Streams administrator.See Oracle Database Administrator's Guide for information about connecting to a database in SQL*Plus.
-
Create an
ANYDATA
queue that will stage changes made to the source database during the upgrade process. For example:BEGIN DBMS_STREAMS_ADM.SET_UP_QUEUE( queue_table => 'strmadmin.destination_queue_table', queue_name => 'strmadmin.destination_queue'); END; /
-
Configure a downstream capture process that will capture all supported changes made to the source database and stage these changes in the queue created in Step 2.b. Ensure that the capture process uses a database link to the source database. The capture process can be a real-time downstream capture process or an archived-log downstream capture process. See Oracle Streams Replication Administrator's Guide for more information. Do not start the capture process.
"Preparing to Upgrade a Database with User-Defined Types" discusses a method for retaining changes to tables that contain user-defined types during the maintenance operation. If you are using this method, then ensure that the capture process does not attempt to capture changes to tables with user-defined types. See the Oracle Streams documentation for the source database for information about excluding database objects from an Oracle Streams configuration with rules.
RMAN
Complete the following steps if you are using RMAN for instantiation:
-
In SQL*Plus, connect to the source database
orcl.example.com
as the Oracle Streams administrator.See Oracle Database Administrator's Guide for information about connecting to a database in SQL*Plus.
-
Perform a build of the data dictionary in the redo log:
SET SERVEROUTPUT ON DECLARE scn NUMBER; BEGIN DBMS_CAPTURE_ADM.BUILD( first_scn => scn); DBMS_OUTPUT.PUT_LINE('First SCN Value = ' || scn); END; / First SCN Value = 1122610
This procedure displays the valid first SCN value for the capture process that will be created at the destination database. Make a note of the SCN value returned because you will use it when you create the capture process at the destination database.
-
Prepare the source database for instantiation:
exec DBMS_CAPTURE_ADM.PREPARE_GLOBAL_INSTANTIATION();
-
-
Proceed to "Task 3: Instantiating the Database".
E.3.2.3 A Third Database Is the Capture Database
To use this option, meet the following requirements:
-
The database being upgraded must be an Oracle Database 10g Release 1 (10.1) database.
-
The third database must be an Oracle Database 10g Release 1 or later database.
This example assumes that the global name of the third database is thrd.example.com
. Complete the following steps to set up Oracle Streams before instantiation when a third database is the capture database:
E.3.3 Task 3: Instantiating the Database
"Deciding Which Utility to Use for Instantiation" discusses different options for instantiating an entire database. Complete the steps in the appropriate section based on the instantiation option you are using:
E.3.3.1 Instantiating the Database Using Export/Import
Complete the following steps to instantiate the destination database using export/import:
E.3.3.2 Instantiating the Database Using RMAN
Complete the following steps to instantiate the destination database using the RMAN DUPLICATE
command:
Note:
These steps provide a general outline for using RMAN to duplicate a database. If you are upgrading an Oracle9i Release 2 database, then see the Oracle9i Recovery Manager User's Guide for detailed information about using RMAN in that release. If you upgrading an Oracle Database 10g Release 1 (10.1) database, then see the Oracle Database Backup and Recovery Advanced User's Guide for that release.
E.3.4 Task 4: Setting Up Oracle Streams After Instantiation
The specific instructions for setting up Oracle Streams after instantiation depend on which database is the capture database. Follow the instructions in the appropriate section:
See Also:
"Overview of Using Oracle Streams in the Database Upgrade Process" for information about the capture database
E.3.4.1 The Source Database Is the Capture Database
Complete the following steps to set up Oracle Streams after instantiation when the source database is the capture database:
E.3.4.2 The Destination Database Is the Capture Database
Complete the following steps to set up Oracle Streams after instantiation when the destination database is the capture database:
-
Complete the following steps if you used RMAN for instantiation. If you used export/import for instantiation, then proceed to Step 2.
-
In SQL*Plus, connect to the destination database as the Oracle Streams administrator. In this example, the destination database is
updb.example.com
.See Oracle Database Administrator's Guide for information about connecting to a database in SQL*Plus.
-
Create an
ANYDATA
queue that will stage changes made to the source database during the upgrade process. For example:BEGIN DBMS_STREAMS_ADM.SET_UP_QUEUE( queue_table => 'strmadmin.destination_queue_table', queue_name => 'strmadmin.destination_queue'); END; /
-
Configure a downstream capture process that will capture all supported changes made to the source database and stage these changes in the queue created in Step 1.b.
Ensure that you set the
first_scn
parameter in theCREATE_CAPTURE
procedure to the value obtained for the data dictionary build in Step 22.b in "The Destination Database Is the Capture Database". In this example, thefirst_scn
parameter should be set to1122610
.The capture process can be a real-time downstream capture process or an archived-log downstream capture process. See Oracle Streams Replication Administrator's Guide for more information. Do not start the capture process.
"Preparing to Upgrade a Database with User-Defined Types" discusses a method for retaining changes to tables that contain user-defined types during the maintenance operation. If you are using this method, then ensure that the capture process does not attempt to capture changes to tables with user-defined types. See the Oracle Streams documentation for the source database for information about excluding database objects from an Oracle Streams configuration with rules.
-
-
Create an apply process that applies all changes in the queue used by the downstream capture process. For example:
BEGIN DBMS_STREAMS_ADM.ADD_GLOBAL_RULES( streams_type => 'apply', streams_name => 'apply_upgrade', queue_name => 'strmadmin.destination_queue', include_dml => TRUE, include_ddl => TRUE, include_tagged_lcr => TRUE, source_database => 'orcl.example.com'); END; /
-
Proceed to "Task 5: Finishing the Upgrade and Removing Oracle Streams".
E.3.5 Task 5: Finishing the Upgrade and Removing Oracle Streams
Complete the following steps to finish the upgrade operation using Oracle Streams and remove Oracle Streams components:
-
Connect to the destination database as the Oracle Streams administrator. In this example, the destination database is
updb.example.com
.See Oracle Database Administrator's Guide for information about connecting to a database in SQL*Plus.
-
Start the apply process. For example:
BEGIN DBMS_APPLY_ADM.START_APPLY( apply_name => 'apply_upgrade'); END; /
-
Connect to the capture database as the Oracle Streams administrator.
-
Start the capture process. For example:
BEGIN DBMS_CAPTURE_ADM.START_CAPTURE( capture_name => 'capture_upgrade'); END; /
This step begins the process of replicating changes that were made to the source database during instantiation of the destination database.
-
While still connected as the Oracle Streams administrator in SQL*Plus to the capture database, monitor the Oracle Streams environment until the apply process at the destination database has applied most of the changes from the source database.
To determine whether the apply process at the destination database has applied most of the changes from the source database, complete the following steps:
-
Query the enqueue message number of the capture process and the message number with the oldest system change number (SCN) for the apply process to see if they are nearly equal.
For example, if the name of the capture process is
capture_upgrade
, and the name of the apply process isapply_upgrade
, then run the following query at the capture database:COLUMN ENQUEUE_MESSAGE_NUMBER HEADING 'Captured SCN' FORMAT 99999999999 COLUMN OLDEST_SCN_NUM HEADING 'Oldest Applied SCN' FORMAT 99999999999 SELECT c.ENQUEUE_MESSAGE_NUMBER, a.OLDEST_SCN_NUM FROM V$STREAMS_CAPTURE c, V$STREAMS_APPLY_READER@updb.example.com a WHERE c.CAPTURE_NAME = 'CAPTURE_UPGRADE' AND a.APPLY_NAME = 'APPLY_UPGRADE';
When the two values returned by this query are nearly equal, most of the changes from the source database have been applied at the destination database, and you can proceed to the next step. At this point in the process, the values returned by this query might never be equal because the source database still allows changes.
If this query returns no results, then ensure that the Oracle Streams clients in the environment are enabled by querying the
STATUS
column in theDBA_CAPTURE
view at the capture database and theDBA_APPLY
view at the destination database. If a propagation is used, you can check the status of the propagation by running the query in "Displaying Information About the Schedules for Propagation Jobs".If an Oracle Streams client is disabled, then try restarting it. If an Oracle Streams client will not restart, then troubleshoot the environment using the information in Identifying Problems in an Oracle Streams Environment.
-
Query the state of the apply process apply servers at the destination database to determine whether they have finished applying changes.
For example, if the name of the apply process is
apply_upgrade
, then run the following query at the capture database:COLUMN STATE HEADING 'Apply Server State' FORMAT A20 SELECT STATE FROM V$STREAMS_APPLY_SERVER@updb.example.com WHERE APPLY_NAME = 'APPLY_UPGRADE';
When the state for all apply servers is
IDLE
, you can proceed to the next step.
-
-
Connect to the destination database as the Oracle Streams administrator. In this example, the destination database is
updb.example.com
. -
Ensure that there are no apply errors by running the following query:
SELECT COUNT(*) FROM DBA_APPLY_ERROR;
If this query returns zero, then proceed to the next step. If this query shows errors in the error queue, then resolve these errors before continuing. See "Managing Apply Errors" for more information.
-
Disconnect all applications and users from the source database.
-
Connect as an administrative user to the source database. In this example, the source database is
orcl.example.com
. -
Restrict access to the database. For example:
ALTER SYSTEM ENABLE RESTRICTED SESSION;
-
Connect as an administrative user in SQL*Plus to the capture database, and repeat the query you ran in Step 55.a. When the two values returned by the query are equal, all of the changes from the source database have been applied at the destination database, and you can proceed to the next step.
-
Connect as the Oracle Streams administrator in SQL*Plus to the destination database, and repeat the query you ran in Step 7. If this query returns zero, then move on to the next step. If this query shows errors in the error queue, then resolve these errors before continuing. See "Managing Apply Errors" for more information.
-
If you performed any actions that created, modified, or deleted job queue processes at the source database during the upgrade process, then perform the same actions at the destination database. See "Considerations for Job Queue Processes and PL/SQL Package Subprograms" for more information.
-
If you invoked any Oracle-supplied PL/SQL package subprograms at the source database during the upgrade process that modified both user data and dictionary metadata at the same time, then invoke the same subprograms at the destination database. See "Considerations for Job Queue Processes and PL/SQL Package Subprograms" for more information.
-
Shut down the source database. This database should not be opened again.
-
Connect to the destination database as an administrative user.
-
Change the global name of the database to match the source database. For example:
ALTER DATABASE RENAME GLOBAL_NAME TO orcl.example.com;
-
At the destination database, enable any jobs that you disabled earlier.
-
Make the destination database available for applications and users. Redirect any applications and users that were connecting to the source database to the destination database. If necessary, reconfigure your network and Oracle Net so that systems that communicated with the source database now communicate with the destination database. See Oracle Database Net Services Administrator's Guide for more information.
-
At the destination database, remove the Oracle Streams components that are no longer needed. Connect as an administrative user to the destination database, and run the following procedure:
Note:
Running this procedure is dangerous. It removes the local Oracle Streams configuration. Ensure that you are ready to remove the Oracle Streams configuration at the destination database before running this procedure.
EXEC DBMS_STREAMS_ADM.REMOVE_STREAMS_CONFIGURATION();
If you no longer need database supplemental logging at the destination database, then run the following statement to drop it:
ALTER DATABASE DROP SUPPLEMENTAL LOG DATA (PRIMARY KEY, UNIQUE, FOREIGN KEY) COLUMNS;
If you no longer need the Oracle Streams administrator at the destination database, then run the following statement:
DROP USER strmadmin CASCADE;
-
If the capture database was a third database, then, at the third database, remove the Oracle Streams components that are no longer needed. Connect as an administrative user to the third database, and run the following procedure:
Note:
Running this procedure is dangerous. It removes the local Oracle Streams configuration. Ensure that you are ready to remove the Oracle Streams configuration at the third database before running this procedure.
EXEC DBMS_STREAMS_ADM.REMOVE_STREAMS_CONFIGURATION();
If you no longer need database supplemental logging at the third database, then run the following statement to drop it:
ALTER DATABASE DROP SUPPLEMENTAL LOG DATA (PRIMARY KEY, UNIQUE, FOREIGN KEY) COLUMNS;
If you no longer need the Oracle Streams administrator at the destination database, then run the following statement:
DROP USER strmadmin CASCADE;
The database upgrade is complete.