<一>.Preparing for CONVERT DATABASE: Using the DBMS_TDB Package
DBMS_TDB.CHECK_DB checks whether a database can be transported to a desired destination platform, and whether the current state of the database permits transport.
This example illustrates the use of CHECK_DB on a 32-bit Linux platform. for transporting a database to 32-bit Windows, skipping read-only tablespaces, with a database that is currently open read-write.
SQL> set serveroutput on
SQL> declare
db_ready boolean;
begin
db_ready := dbms_tdb.check_db('Microsoft Windows IA (32-bit)',dbms_tdb.skip_readonly);
end;
/
Database is not open READ ONLY. Please open database READ ONLY and retry.
PL/SQL procedure successfully completed.
If you call DBMS_TDB.CHECK_DB and no messages are displayed indicating conditions preventing transport before the PL/SQL procedure successfully completed message, then your database is ready for transport
DBMS_TDB.CHECK_EXTERNAL must be used to identify any external tables, directories or BFILEs. RMAN cannot automate the transport of such files.
DBMS_TDB.CHECK_EXTERNAL takes no parameters. With SERVEROUTPUT set to ON, the output of DBMS_TDB.CHECK_EXTERNAL lists the external tables, directories and BFILEs of your database.
The following example shows how to call DBMS_TDB.CHECK_EXTERNAL:
SQL> set serveroutput on
SQL> declare
external boolean;
begin
/* value of external is ignored, but with SERVEROUTPUT set to ON
* dbms_tdb.check_external displays report of external objects
* on console */
external := dbms_tdb.check_external;
end;
If there are no external objects, then this procedure completes with no output. If there are external objects, however, the output will be similar to the following example:
The following external tables exist in the database: SH.SALES_TRANSACTIONS_EXT The following directories exist in the database: SYS.DATA_PUMP_DIR, SYS.MEDIA_DIR, SYS.DATA_FILE_DIR, SYS.LOG_FILE_DIR The following BFILEs exist in the database: PM.PRINT_MEDIA PL/SQL procedure successfully completed.
NOTE:the external tables, directories and BFILEs of your database cann't be converted by RMAN automaticlly.
<二>.Using the RMAN CONVERT DATABASE Command
1.Produce two scripts on the source platform.:
we can use "convert database on target platform" to produce two scripts.
example:
CONVERT DATABASE ON TARGET PLATFORM. CONVERT SCRIPT '/tmp/convertdb/convertscript.rman'
TRANSPORT SCRIPT '/tmp/convertdb/transportscript.sql'
new database 'newdb'
FORMAT '/tmp/convertdb/%U'
--->one is "transport script" which containing SQL*Plus commands to create a new database on the destination platform, and a PFILE for the new database containing the same settings as the source database.
---->the other is "convert script" which containing RMAN CONVERT DATAFILE commands for each of the datafiles of the database being transported.
Example:
RUN {
CONVERT DATAFILE '/disk1/oracle/dbs/tbs_01.f'
FROM PLATFORM. 'Linux IA (32-bit)'
FORMAT '/tmp/convertdb/data_D-TV_I-1778429277_TS-SYSTEM_FNO-1_7qgb9u2s';
CONVERT DATAFILE '/disk1/oracle/dbs/tbs_ax1.f'
FROM PLATFORM. 'Linux IA (32-bit)'
FORMAT '/tmp/convertdb/data_D-TV_I-1778429277_TS-SYSAUX_FNO-2_7rgb9u2s';
CONVERT DATAFILE '/disk1/oracle/dbs/tbs_03.f'
FROM PLATFORM. 'Linux IA (32-bit)'
FORMAT '/tmp/convertdb/data_D-TV_I-1778429277_TS-SYSTEM_FNO-17_7sgb9u2s';
.
.
.
CONVERT DATAFILE '/disk1/oracle/dbs/tbs_51.f'
FROM PLATFORM. 'Linux IA (32-bit)'
FORMAT '/tmp/convertdb/data_D-TV_I-1778429277_TS-TBS_5_FNO-15_8egb9u2u';
CONVERT DATAFILE '/disk1/oracle/dbs/tbs_52.f'
FROM PLATFORM. 'Linux IA (32-bit)'
FORMAT '/tmp/convertdb/data_D-TV_I-1778429277_TS-TBS_5_FNO-16_8fgb9u2u';
}
Note that CONVERT DATABASE ON TARGET PLATFORM does not produce converted datafile copies on the source platform.
2.Run the scripts on the destination platform. to make a new database.
---->Tansport the datafiles of the source paltform. ,two scripts and pfile to the destination platform.(NOTE: the source database is on the ready-only mode.)
----->Make the proper directory on the destination platfort for the new database.
----->Change the "convert script" ,and running it to convert the datafile which will be used by the new database on the destination platform.
----->Make any desired changes to the parameter file.
# Please change the values of the following parameters:
control_files = "/tmp/convertdb/cf_D-NEWDBT_id-1778429277_00gb9u2s"
db_recovery_file_dest = "/tmp/convertdb/orcva"
db_recovery_file_dest_size= 10737418240
instance_name = "NEWDBT"
service_names = "NEWDBT.regress.rdbms.dev.us.oracle.com"
plsql_native_library_dir = "/tmp/convertdb/plsqlnld1"
db_name = "NEWDBT"
------>Then run the "transport script" script which contains SQL statements used to create the new database on the destination platform.
-----END------
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/665511/viewspace-366343/ ,如需转载,请注明出处,否则将追究法律责任。