ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 使用rman进行跨平台数据迁移

使用rman进行跨平台数据迁移

原创 Linux操作系统 作者:linger_52102 时间:2010-11-18 13:42:41 0 删除 编辑

可以是在源库转换也可以是在目标库转换

 


How To Use RMAN CONVERT DATABASE on Source Host for Cross Platform. Migration [ID 413586.1]

  Modified 13-SEP-2010     Type HOWTO     Status PUBLISHED  

In this Document
  
  
  5  end;
  6  /

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.

3) Use DBMS_TDB.CHECK_EXTERNAL to identify any external tables, directories or BFILEs. RMAN cannot automate the transport of such files as mentioned above.
SQL> set serveroutput on
SQL> declare
  2    external boolean;
  3  begin
  4    external := dbms_tdb.check_external;
  5  end;
  6  /
The following directories exist in the database:
SYS.DATA_PUMP_DIR

PL/SQL procedure successfully completed.
If there are no external objects, then this procedure completes with no output. If there are external objects, however, the output will be somewhat similar to above.

4) When the database is ready for transport, the RMAN CONVERT DATABASE command is run (when the source database is READ ONLY), specifying a destination platform. and how to name the output files. RMAN produces the following files needed to move the database to the destination system:

a) A complete copy of the datafiles of the database, ready to be transported
b) A PFILE for use with the new database on the destination platform, containing settings used in the PFILE/SPFILE from the source database.
c) A transport script, which contains SQL statements used to create the new database on the destination platform
C:\>rman target / nocatalog

Recovery Manager: Release 10.2.0.1.0 - Production on Fri Feb 2 17:05:35 2007

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: ORA10G (DBID=3926158280)
using target database control file instead of recovery catalog

RMAN> CONVERT DATABASE NEW DATABASE 'LinDB10g'
2>    TRANSPORT SCRIPT. 'D:\oracle\oradata\dbTransport\transport.sql'
3>    TO PLATFORM. 'Linux IA (32-bit)'
4>    DB_FILE_NAME_CONVERT '+DG_DATA/ora10g/datafile' 'D:\oracle\oradata\dbTransport';

Starting convert at 02-FEB-07
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=90 devtype=DISK

Directory SYS.DATA_PUMP_DIR found in the database

User SYS with SYSDBA and SYSOPER privilege found in password file
channel ORA_DISK_1: starting datafile conversion
input datafile fno=00001 name=+DG_DATA/ora10g/datafile/system.257.609084887
converted datafile=D:\ORACLE\ORADATA\DBTRANSPORT\SYSTEM.257.609084887
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting datafile conversion
input datafile fno=00002 name=+DG_DATA/ora10g/datafile/undotbs1.258.609084933
converted datafile=D:\ORACLE\ORADATA\DBTRANSPORT\UNDOTBS1.258.609084933
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile conversion
input datafile fno=00003 name=+DG_DATA/ora10g/datafile/sysaux.259.609084957
converted datafile=D:\ORACLE\ORADATA\DBTRANSPORT\SYSAUX.259.609084957
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile conversion
input datafile fno=00004 name=+DG_DATA/ora10g/datafile/users.260.609084973
converted datafile=D:\ORACLE\ORADATA\DBTRANSPORT\USERS.260.609084973
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:07
Run SQL script. D:\ORACLE\ORADATA\DBTRANSPORT\TRANSPORT.SQL on the target platform. to create database
Edit init.ora file D:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\INIT_00I92IKQ_1_0.ORA. This PFILE will be used to create
the database on the target platform
To recompile all PL/SQL modules, run utlirp.sql and utlrp.sql on the target platform
To change the internal database identifier, use DBNEWID Utility
Finished backup at 02-FEB-07
Check the output related to the transport script. and the parameter file for the new database at the end above. When CONVERT DATABASE completes, the source database may be opened read-write again.

5) Now copy the above files to the destination host. i.e. the converted datafiles, transport.sql script. and the pfile generated.

6) The PFILE generated by RMAN will have following sections:

a) Parameters that need to be changed for the destination host environment
b) Other parameters which are same as the source database parameters

Edit the PFILE moved on the destination host to change the environment specific parameters.

7) Now edit the TRANSPORT sql script. to reflect the new path for datafiles in the CREATE CONTROLFILE section of the script. Also change all references to the INIT.ORA in the script. to the new path and name of the INIT.ORA modified above.

8) Once the PFILE and TRANSPORT sql scripts are suitably modified invoke SQLPLUS on the destination host after setting the Oracle environment parameters and then run TRANSPORT.sql as:
[oracle@test-br ora10g]$ export ORACLE_HOME=/u01/oracle/product/ora10g
[oracle@test-br ora10g]$ export ORACLE_SID=LinDB10g
[oracle@test-br ora10g]$ export PATH=$ORACLE_HOME/bin:$PATH
[oracle@test-br ora10g]$ cd /u01/oracle/oradata/LinDB10g
[oracle@test-br LinDB10g]$ sqlplus "/ as sysdba"

SQL*Plus: Release 10.2.0.1.0 - Production on Sat Feb 3 01:55:46 2007

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> @TRANSPORT.SQL
ORACLE instance started.

Total System Global Area  201326592 bytes
Fixed Size                  1218484 bytes
Variable Size              67110988 bytes
Database Buffers          125829120 bytes
Redo Buffers                7168000 bytes

Control file created.


Database altered.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Your database has been created successfully!
* There are many things to think about for the new database. Here
* is a checklist to help you stay on track:
* 1. You may want to redefine the location of the directory objects.
* 2. You may want to change the internal database identifier (DBID)
*    or the global database name for this database. Use the
*    NEWDBID Utility (nid).
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Database closed.
Database dismounted.
ORACLE instance shut down.
ORACLE instance started.

Total System Global Area  201326592 bytes
Fixed Size                  1218484 bytes
Variable Size              67110988 bytes
Database Buffers          125829120 bytes
Redo Buffers                7168000 bytes
Database mounted.
Database opened.

...
...
...

SQL> select COUNT(*) "ERRORS DURING RECOMPILATION" from utl_recomp_errors;

ERRORS DURING RECOMPILATION
---------------------------
                          0

SQL>
SQL>
SQL> Rem =====================================================================
SQL> Rem Run component validation procedure
SQL> Rem =====================================================================
SQL>
SQL> SET serveroutput on
SQL> EXECUTE dbms_registry_sys.validate_components;

PL/SQL procedure successfully completed.

SQL> SET serveroutput off
SQL>
SQL>
SQL> Rem ===========================================================================
SQL> Rem END utlrp.sql
SQL> Rem ===========================================================================
SQL> set feedback 6;
SQL>
SQL> select name, open_mode from v$database;

NAME      OPEN_MODE
--------- ----------
LINDB10G  READ WRITE
When the transport script. finishes, the creation of the new database is complete.

References

NOTE:243304.1 - 10g : Transportable Tablespaces Across Different Platforms
NOTE:414878.1 - Cross-Platform. Migration on Destination Host Using Rman Convert Database
Oracle® Database Backup and Recovery Advanced User's Guide 10g Release 2 (10.2)

Show Related Information Related


Products
  • Oracle Database Products > Oracle Database > Oracle Database > Oracle Server - Enterprise Edition
Keywords
V$TRANSPORTABLE_PLATFORM; TRANSPORTABLE; DATABASE MIGRATION; MIGRATION

Important Note: this feedback is anonymously visible to other customers until processed by Oracle Support.

Cancel

 


Cross-Platform. Migration on Destination Host Using Rman Convert Database [ID 414878.1]

  Modified 09-JUN-2010     Type HOWTO     Status PUBLISHED  

In this Document
  Goal
  Solution
  References


Applies to:

Oracle Server - Enterprise Edition - Version: 10.2.0.2 and later   [Release: 10.2 and later ]
Information in this document applies to any platform.

Goal

Performing Cross platform. database migration using Rman Convert Database feature in 10g Release 2 on the Destination Host
The below example demonstrates migration from Windows 32-bit to Linux 32-bit:

Note the following restrictions exist with Cross-Platform. Transportable Database:

1) The principal restriction on cross-platform. transportable database is that the source and destination platform. must share the same endian format.
2) Redo log files and control files from the source database are not transported. New control files and redo log files are created for the new database during the transport process, and an  Open Resetogs is performed once the new database is created. Similarly, tempfiles belonging to locally managed temporary tablespaces are not transported. The temporary tablespace will be re-created on the target platform. when the transport script. is run.
3) BFiles, External tables and directories, Password files are not transported.
4) The Source and the target database version must be equal / greater than 10.2.0. version

Solution

SOLUTION

1)
Check that the source and destination platform. belong to same ENDIAN format in the view V$TRANSPORTABLE_PLATFORM. We will try to transport a database from Windows (32-bit) to Linux (32-bit). As seen below both belong to Little endian format:

SQL> select PLATFORM_NAME, ENDIAN_FORMAT from V$TRANSPORTABLE_PLATFORM;

PLATFORM_NAME ENDIAN_FORMAT
---------------------------------------- --------------
Solaris[tm] OE (32-bit) Big
Solaris[tm] OE (64-bit) Big
Microsoft Windows IA (32-bit) Little
Linux IA (32-bit) Little
AIX-Based Systems (64-bit) Big
HP-UX (64-bit) Big
HP Tru64 UNIX Little
HP-UX IA (64-bit) Big
Linux IA (64-bit) Little
HP Open VMS Little
Microsoft Windows IA (64-bit) Little
IBM zSeries Based Linux Big
Linux 64-bit for AMD Little
Apple Mac OS Big
Microsoft Windows 64-bit for AMD Little
Solaris Operating System (x86) Little
IBM Power Based Linux Big

17 rows selected.
2) Open the database in read only mode


SQL> alter database open read only;

Database altered.

3) Use DBMS_TDB.CHECK_DB to check whether the database can be transported to a desired destination platform, and whether the current state of the database (such as incorrect compatibility settings, in-doubt or active transactions) permits transport. Make sure your database is open in READ ONLY mode before you call DBMS_TDB.CHECK_DB. Since we need to transport to Linux we will call the procedure with following arguments:

SQL> set serveroutput on
SQL> declare
2 db_ready boolean;
3 begin
4 db_ready := dbms_tdb.check_db('Linux IA (32-bit)');
5 end;
6 /

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.

4)
Use DBMS_TDB.CHECK_EXTERNAL to identify any external tables, directories or BFILEs. RMAN cannot automate the transport of such files as mentioned above.

SQL> set serveroutput on
SQL> declare
2 external boolean;
3 begin
4 external := dbms_tdb.check_external;
5 end;
6 /
The following directories exist in the database:
SYS.DATA_PUMP_DIR

PL/SQL procedure successfully completed.
If there are no external objects, then this procedure completes with no output. If there are external objects, however, the output will be somewhat similar to above.

5) Now once the database is ready for transport , make sure as to where you are going to convert the datafiles.You may choose to convert the datafiles of the database being transported on the destination platform. instead of the source platform. Reasons for doing this include:

+ Avoiding any performance overhead on the source host due to the conversion process.
+ Distributing a database from one source system to multiple recipients on several different platforms.

6) Run the RMAN CONVERT DATABASE command on the source platform. specifying the ON TARGET PLATFORM. argument. When used in this manner, the command syntax is as follows:

RMAN> CONVERT DATABASE ON TARGET PLATFORM
2> CONVERT SCRIPT. 'C:\convertscript.rman'
3> TRANSPORT SCRIPT. 'C:\transportscript.sql'
4> new database 'win10g'
5> FORMAT 'C:\%U';

Starting convert at 12-FEB-07
using channel ORA_DISK_1

Directory SYS.DATA_PUMP_DIR found in the database

User SYS with SYSDBA and SYSOPER privilege found in password file
channel ORA_DISK_1: starting to check datafiles
input datafile fno=00001 name=D:\ORACLE\ORADATA\ORA10G\DATA\SYSTEM.DBF
channel ORA_DISK_1: datafile checking complete, elapsed time: 00:00:00
channel ORA_DISK_1: starting to check datafiles
input datafile fno=00002 name=D:\ORACLE\ORADATA\ORA10G\DATA\UNDOTBS1.DBF
channel ORA_DISK_1: datafile checking complete, elapsed time: 00:00:00
channel ORA_DISK_1: starting to check datafiles
input datafile fno=00003 name=D:\ORACLE\ORADATA\ORA10G\DATA\SYSAUX.DBF
channel ORA_DISK_1: datafile checking complete, elapsed time: 00:00:00
channel ORA_DISK_1: starting to check datafiles
input datafile fno=00004 name=D:\ORACLE\ORADATA\ORA10G\DATA\USERS.DBF
channel ORA_DISK_1: datafile checking complete, elapsed time: 00:00:00
Run SQL script. C:\TRANSPORTSCRIPT.SQL on the target platform. to create database
Edit init.ora file C:\INIT_00I9SC77_1_0.ORA. This PFILE will be used to create the database on the target platform
Run RMAN script. C:\CONVERTSCRIPT.RMAN on target platform. to convert datafiles
To recompile all PL/SQL modules, run utlirp.sql and utlrp.sql on the target platform
To change the internal database identifier, use DBNEWID Utility
Finished backup at 12-FEB-07

The  CONVERT DATABASE ON TARGET PLATFORM. produces a transport script. 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 pfile will be generated in location specified by the Format command.

CONVERT DATABASE ON TARGET PLATFORM. also generates a convert script. containing RMAN CONVERT DATAFILE commands for each of the datafiles of the database being transported. The source datafiles must be copied unconverted to some temporary location at the destination, and then the convert script. must be run at the destination to actually convert the datafiles to a format usable by the destination host.

Note that CONVERT DATABASE ON TARGET PLATFORM. does not produce converted datafile copies.

If the filesystem containing the datafiles of the source database is accessible from the destination system using the same path names, then you can use the convert script. on the destination host without any changes. The CONVERT DATAFILE commands in the script. produce datafile copies in the locations specified by FORMAT, converted for use with the new database. (Once the convert script. has been run, the source database can be opened for read-write access again.)

Otherwise, while the datafiles are still read-only, copy them to a temporary location. (As soon as copies of the datafiles are made, the source database can be opened read-write again.) If necessary, move the copies of the datafiles to a temporary location on the destination host, and then update each CONVERT DATAFILE command in the convert script. to use the temporary location of each datafile as input and the FORMAT parameter of each CONVERT command to specify the desired final location of the datafiles of the transported database.

7)
Now copy the following files to the destination machine manually :

+ Datafiles
+ Transport.sql
+ Convertscript.rman
+ Pfile generated by the convert database command.
8) Edit the PFILE moved on the destination host to change the environment specific parameters.

9)
Create a dummy Controlfile

sqlplus "/ as sysdba"

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Feb 12 20:10:52 2007

Copyright (c) 1982, 2005, Oracle. All rights reserved.

Connected to an idle instance.

SQL> startup nomount;
ORACLE instance started.

Total System Global Area 201326592 bytes
Fixed Size 1218484 bytes
Variable Size 67110988 bytes
Database Buffers 125829120 bytes
Redo Buffers 7168000 bytes
SQL>
SQL> CREATE CONTROLFILE REUSE SET DATABASE "WIN10G" RESETLOGS ARCHIVELOG
2 MAXLOGFILES 16
3 MAXLOGMEMBERS 3
4 MAXDATAFILES 100
5 MAXINSTANCES 8
6 MAXLOGHISTORY 292
7 LOGFILE
8 GROUP 4 '/u01/oracle/oradata/win10g/redo01.log' SIZE 10M,
9 GROUP 5 '/u01/oracle/oradata/win10g/redo02.log' SIZE 10M,
10 GROUP 6 '/u01/oracle/oradata/win10g/redo03.log' SIZE 10M
11 DATAFILE
12 '/u01/oracle/oradata/win10g/SYSTEM.DBF',
13 '/u01/oracle/oradata/win10g/SYSAUX.DBF',
14 '/u01/oracle/oradata/win10g/UNDOTBS1.DBF',
15 '/u01/oracle/oradata/win10g/USERS.DBF'
16 CHARACTER SET WE8MSWIN1252
17 ;

Control file created.
10) Now edit the file Convertscript.rman and make necessary changes with respect to the filesystem and the file names.Now once the changes are done run the script. from rman prompt

[oracle@test-br win10g]$ rman target / nocatalog @CONVERTSCRIPT.RMAN

Recovery Manager: Release 10.2.0.1.0 - Production on Mon Feb 12 20:24:18 2007

Copyright (c) 1982, 2005, Oracle. All rights reserved.

connected to target database: WIN10G (DBID=3926158280, not open)
using target database control file instead of recovery catalog

RMAN> RUN {
2>
3> CONVERT DATAFILE '/u01/oracle/oradata/win10g/SYSTEM.DBF'
4> FROM PLATFORM. 'Microsoft Windows IA (32-bit)'
5> FORMAT '/u01/oracle/oradata/win10g/data/SYSTEM.DBF';
6>
7>
8> CONVERT DATAFILE '/u01/oracle/oradata/win10g/SYSAUX.DBF'
9> FROM PLATFORM. 'Microsoft Windows IA (32-bit)'
10> FORMAT '/u01/oracle/oradata/win10g/data/SYSAUX.DBF';
11>
12>
13> CONVERT DATAFILE '/u01/oracle/oradata/win10g/UNDOTBS1.DBF'
14> FROM PLATFORM. 'Microsoft Windows IA (32-bit)'
15> FORMAT '/u01/oracle/oradata/win10g/data/UNDOTBS1.DBF';
16>
17>
18> CONVERT DATAFILE '/u01/oracle/oradata/win10g/USERS.DBF'
19> FROM PLATFORM. 'Microsoft Windows IA (32-bit)'
20> FORMAT '/u01/oracle/oradata/win10g/data/USERS.DBF';
21>
22>
23> }
24>
25>
Starting backup at 12-FEB-07
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=97 devtype=DISK
channel ORA_DISK_1: starting datafile conversion
input filename=/u01/oracle/oradata/win10g/SYSTEM.DBF
converted datafile=/u01/oracle/oradata/win10g/data/SYSTEM.DBF
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:16
Finished backup at 12-FEB-07

Starting backup at 12-FEB-07
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile conversion
input filename=/u01/oracle/oradata/win10g/SYSAUX.DBF
converted datafile=/u01/oracle/oradata/win10g/data/SYSAUX.DBF
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:09
Finished backup at 12-FEB-07

Starting backup at 12-FEB-07
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile conversion
input filename=/u01/oracle/oradata/win10g/UNDOTBS1.DBF
converted datafile=/u01/oracle/oradata/win10g/data/UNDOTBS1.DBF
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:08
Finished backup at 12-FEB-07

Starting backup at 12-FEB-07
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile conversion
input filename=/u01/oracle/oradata/win10g/USERS.DBF
converted datafile=/u01/oracle/oradata/win10g/data/USERS.DBF
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:04
Finished backup at 12-FEB-07

Recovery Manager complete.

10) Now shutdown the database and delete the dummy controlfile.

11) Now edit the TRANSPORT sql script. to reflect the new path for datafiles and redolog files in the CREATE CONTROLFILE section of the script. Also change all references to the INIT.ORA in the script. to the new path and name of the INIT.ORA modified above.

12) Once the PFILE and TRANSPORT sql scripts are suitably modified invoke SQLPLUS on the destination host after setting the Oracle environment parameters and then run TRANSPORT.sql as:

[oracle@test-br ora10g]$ export ORACLE_HOME=/u01/oracle/product/ora10g
[oracle@test-br ora10g]$ export ORACLE_SID=win10g
[oracle@test-br ora10g]$ export PATH=$ORACLE_HOME/bin:$PATH
[oracle@test-br LinDB10g]$ sqlplus "/ as sysdba"

SQL*Plus: Release 10.2.0.1.0 - Production on Sat Feb 3 01:55:46 2007

Copyright (c) 1982, 2005, Oracle. All rights reserved.

Connected to an idle instance.

SQL> @TRANSPORTSCRIPT.SQL
ORACLE instance started.

Total System Global Area 201326592 bytes
Fixed Size 1218484 bytes
Variable Size 67110988 bytes
Database Buffers 125829120 bytes
Redo Buffers 7168000 bytes

Control file created.


Database altered.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Your database has been created successfully!
* There are many things to think about for the new database. Here
* is a checklist to help you stay on track:
* 1. You may want to redefine the location of the directory objects.
* 2. You may want to change the internal database identifier (DBID)
* or the global database name for this database. Use the
* NEWDBID Utility (nid).
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Database closed.
Database dismounted.
ORACLE instance shut down.
ORACLE instance started.

Total System Global Area 201326592 bytes
Fixed Size 1218484 bytes
Variable Size 67110988 bytes
Database Buffers 125829120 bytes
Redo Buffers 7168000 bytes
Database mounted.
Database opened.
...
...

When the transport script. finishes, the creation of the new database is complete.


References

Oracle® Database Backup and Recovery Advanced User's Guide 10g Release 2 (10.2)

Show Related Information Related


Products
  • Oracle Database Products > Oracle Database > Oracle Database > Oracle Server - Enterprise Edition
Keywords
V$TRANSPORTABLE_PLATFORM; RECOVERY MANAGER; CONVERT DATABASE; TRANSPORTABLE DATABASE; DATABASE MIGRATION; MIGRATION

Back to topBack to top

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/15779287/viewspace-678416/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: 修改dbid
请登录后发表评论 登录
全部评论

注册时间:2009-10-03

  • 博文量
    50
  • 访问量
    219665