利用RMAN Convert database特性進行跨平臺遷移資料

shilei1發表於2012-11-13
轉載學習
在Oracle10g中,不僅可以利用跨平臺傳輸表空間的新特性在異構平臺資料庫之間遷移資料,在特定條件下,還可以利用Convert database特性進行整個資料庫跨平臺的遷移。
如果要在10G中進行全庫跨平臺的遷移,那麼只能在低位和低位或者高位和高位平臺之間進行遷移,無法進行高位與低位平臺的遷移。大家可以參考V$TRANSPORTABLE_PLATFORM中的資訊以決定是否能夠遷移。
SQL> select * from V$TRANSPORTABLE_PLATFORM. order by 3;
PLATFORM_ID PLATFORM_NAME ENDIAN_FORMAT
----------- ---------------------------------------- --------------
4 HP-UX IA (64-bit) Big
1 Solaris[tm] OE (32-bit) Big
16 Apple Mac OS Big
3 HP-UX (64-bit) Big
9 IBM zSeries Based Linux Big
6 AIX-Based Systems (64-bit) Big
2 Solaris[tm] OE (64-bit) Big
18 IBM Power Based Linux Big
17 Solaris Operating System (x86) Little
12 Microsoft Windows 64-bit for AMD Little
13 Linux 64-bit for AMD Little
8 Microsoft Windows IA (64-bit) Little
15 HP Open VMS Little
5 HP Tru64 UNIX Little
10 Linux IA (32-bit) Little
7 Microsoft Windows IA (32-bit) Little
11 Linux IA (64-bit) Little、
Convert database具體如下特性:

1、 只能傳輸資料表空間的資料檔案。臨時表空間將不會被傳輸,如果臨時表空間是本地管理的話,那麼傳輸資料庫完成後將會自動在目標資料庫建立臨時表空間。
2、 假如源主資料庫使用PFILE,那麼PFILE也會被傳輸。如果源資料庫使用的是SPFILE,那麼將會自動產生一個PFILE進行傳輸,並在目標資料庫生成SPFILE。
3、 控制檔案和聯機日誌檔案將不會被傳輸。在目標資料庫open resetlogs的過程中,將會自動建立控制檔案和聯機日誌檔案。
4、 BFILE、外部表和directory將不會被傳輸。RMAN檢查的時候將會把這些物件列出,使用者可以手工建立這些物件。
5、 密碼檔案將不會被傳輸,使用者必須在目標資料庫手工建立密碼檔案。
傳輸資料庫的第一步是將源資料庫置於READ ONLY模式:
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 1610612736 bytes
Fixed Size 1262044 bytes
Variable Size 385879588 bytes
Database Buffers 1207959552 bytes
Redo Buffers 15511552 bytes
Database mounted.
SQL> alter database open read only;
Database altered.
第二步利用dbms_tdb包檢查資料庫能否被傳輸以及列出外部表和DIRECTORY等無法傳輸的物件資訊(測試案例採用Linux遷移至Windows平臺):
SQL> set serveroutput on
SQL> declare
2 db_ready boolean;
3 begin
4 /* db_ready is ignored, but with SERVEROUTPUT set to ON any
5 * conditions preventing transport will be output to console */
6 db_ready := dbms_tdb.check_db('Microsoft Windows IA (32-bit)',
7 dbms_tdb.skip_none);
8 end;
9 /
PL/SQL procedure successfully completed.
SQL> declare
2 external boolean;
3 begin
4 /* value of external is ignored, but with SERVEROUTPUT set to ON
5 * dbms_tdb.check_external displays report of external objects
6 * on console */
7 external := dbms_tdb.check_external;
8 end;
9
10 /
The following external tables exist in the database:
SH.SALES_TRANSACTIONS_EXT
The following directories exist in the database:
SYS.DATA_PUMP_DIR, SYS.SUBDIR, SYS.XMLDIR, SYS.MEDIA_DIR, SYS.LOG_FILE_DIR,
SYS.DATA_FILE_DIR, SYS.WORK_DIR, SYS.ADMIN_DIR
The following BFILEs exist in the database:
PM.PRINT_MEDIA
PL/SQL procedure successfully completed.
環境檢查完畢後就可以利用RMAN的convert database命令在源資料庫進行轉換(convert database也可以在目標資料庫進行,具體可以參考文件):
SQL> host rman target /
Recovery Manager: Release 10.2.0.3.0 - Production on Thu Jun 28 15:23:16 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: DBTEST (DBID=1018019231)
RMAN> CONVERT DATABASE NEW DATABASE 'newdb'
2> transport script. '/home/oracle/liuyun/transportdb.sql'
3> to platform. 'Microsoft Windows IA (32-bit)'
4> db_file_name_convert '/opt/oracle/oradata/dbtest/' '/home/oracle/liuyun/';
Starting convert at 28-JUN-07
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=153 devtype=DISK
External table SH.SALES_TRANSACTIONS_EXT found in the database
Directory SYS.DATA_PUMP_DIR found in the database
Directory SYS.SUBDIR found in the database
Directory SYS.XMLDIR found in the database
Directory SYS.MEDIA_DIR found in the database
Directory SYS.LOG_FILE_DIR found in the database
Directory SYS.DATA_FILE_DIR found in the database
Directory SYS.WORK_DIR found in the database
Directory SYS.ADMIN_DIR found in the database
BFILE PM.PRINT_MEDIA 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=/opt/oracle/oradata/dbtest/system01.dbf
converted datafile=/home/oracle/liuyun/system01.dbf
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:55
channel ORA_DISK_1: starting datafile conversion
input datafile fno=00003 name=/opt/oracle/oradata/dbtest/sysaux01.dbf
converted datafile=/home/oracle/liuyun/sysaux01.dbf
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting datafile conversion
input datafile fno=00005 name=/opt/oracle/oradata/dbtest/example01.dbf
converted datafile=/home/oracle/liuyun/example01.dbf
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile conversion
input datafile fno=00002 name=/opt/oracle/oradata/dbtest/undotbs01.dbf
converted datafile=/home/oracle/liuyun/undotbs01.dbf
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile conversion
input datafile fno=00004 name=/opt/oracle/oradata/dbtest/users01.dbf
converted datafile=/home/oracle/liuyun/users01.dbf
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:01
Run SQL script. /home/oracle/liuyun/transportdb.sql on the target platform. to create database
Edit init.ora file /opt/oracle/product/10.2/dbs/init_00ildsr9_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 28-JUN-07
在這一步中new database表示目標資料庫的名字,transport script指定生成建庫指令碼的位置,to platform表示目標資料庫的平臺,db_file_name_convert指定源資料庫資料檔案所在的位置以及轉換後資料檔案存放的目錄。生成的PFILE為/opt/oracle/product/10.2/dbs/init_00ildsr9_1_0.ora,可以根據目標資料庫的情況編輯,編輯後的內容如下:
newdb.__db_cache_size=12582912
newdb.__java_pool_size=4194304
newdb.__large_pool_size=4194304
newdb.__shared_pool_size=58720256
newdb.__streams_pool_size=0
*.audit_file_dest='D:\oracle\admin\newdb\adump'
*.background_dump_dest='D:\oracle\admin\newdb\bdump'
*.compatible='10.2.0.1.0'
*.control_files='D:\oracle\oradata\newdb\control01.ctl'
*.core_dump_dest='D:\oracle\admin\newdb\cdump'
*.db_block_size=8192
*.db_file_multiblock_read_count=16
*.db_name='newdb'
*.db_recovery_file_dest_size=1
*.db_recovery_file_dest=''
*.dispatchers='(PROTOCOL=TCP) (SERVICE=newdbXDB)'
*.job_queue_processes=10
*.log_archive_dest_1='location=d:\oracle\oradata\newdb\archive'
*.log_archive_dest_2='service=standby'
*.log_archive_dest_state_2='DEFER'
*.nls_language='AMERICAN'
*.nls_territory='UNITED KINGDOM'
*.open_cursors=300
*.pga_aggregate_target=16777216
*.processes=150
*.query_rewrite_integrity='STALE_TOLERATED'
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=80M
*.star_transformation_enabled='FALSE'
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='D:\oracle\admin\newdb\udump'
生成的transportdb.sql內容如下,可以根據目標資料庫的情況更改:
STARTUP NOMOUNT PFILE='/opt/oracle/product/10.2/dbs/init_00ildsr9_1_0.ora'
CREATE CONTROLFILE REUSE SET DATABASE "NEWDB" RESETLOGS NOARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/opt/oracle/product/10.2/dbs/arch_D-NEWDB_id-1018019231_S-47_T-1_A-625156386_00ildsr9' SIZE 50M,
GROUP 2 '/opt/oracle/product/10.2/dbs/arch_D-NEWDB_id-1018019231_S-45_T-1_A-625156386_00ildsr9' SIZE 50M,
GROUP 3 '/opt/oracle/product/10.2/dbs/arch_D-NEWDB_id-1018019231_S-46_T-1_A-625156386_00ildsr9' SIZE 50M
DATAFILE
'/home/oracle/liuyunsystem01.dbf',
'/home/oracle/liuyunundotbs01.dbf',
'/home/oracle/liuyunsysaux01.dbf',
'/home/oracle/liuyunusers01.dbf',
'/home/oracle/liuyunexample01.dbf'
CHARACTER SET ZHS16GBK;
-- Database can now be opened zeroing the online logs.
ALTER DATABASE OPEN RESETLOGS;
ALTER TABLESPACE TEMP ADD TEMPFILE '/opt/oracle/product/10.2/dbs/data_D-NEWDB_I-1018019231_TS-TEMP_FNO-1_00ildsr9'
SIZE 20971520 AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M;
SHUTDOWN IMMEDIATE
STARTUP UPGRADE PFILE='/opt/oracle/product/10.2/dbs/init_00ildsr9_1_0.ora'
@@ ?/rdbms/admin/utlirp.sql
SHUTDOWN IMMEDIATE
STARTUP PFILE='/opt/oracle/product/10.2/dbs/init_00ildsr9_1_0.ora'
-- The following step will recompile all PL/SQL modules.
-- It may take serveral hours to complete.
@@ ?/rdbms/admin/utlrp.sql
set feedback 6;
更改後的指令碼內容如下:
STARTUP NOMOUNT PFILE='d:\init.ora'
CREATE CONTROLFILE REUSE SET DATABASE "NEWDB" RESETLOGS NOARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 'd:\oracle\oradata\newdb\redo01.log' SIZE 5M,
GROUP 2 'd:\oracle\oradata\newdb\redo02.log' SIZE 5M
DATAFILE
'd:\oracle\oradata\newdb\system01.dbf',
'd:\oracle\oradata\newdb\undotbs01.dbf',
'd:\oracle\oradata\newdb\sysaux01.dbf',
'd:\oracle\oradata\newdb\users01.dbf',
'd:\oracle\oradata\newdb\example01.dbf'
CHARACTER SET ZHS16GBK;
ALTER DATABASE OPEN RESETLOGS;
ALTER TABLESPACE TEMP ADD TEMPFILE 'd:\oracle\oradata\temp01.dbf'
SIZE 20971520 AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M;
SHUTDOWN IMMEDIATE
STARTUP UPGRADE PFILE='d:\init.ora'
@@ ?/rdbms/admin/utlirp.sql
SHUTDOWN IMMEDIATE
STARTUP PFILE='d:\init.ora'
-- The following step will recompile all PL/SQL modules.
-- It may take serveral hours to complete.
@@ ?/rdbms/admin/utlrp.sql
set feedback 6;
在目標資料庫新建立一個ORACLE服務,將轉換後的資料檔案COPY至目標資料庫的相應目錄,執行建庫指令碼即完成跨平臺資料庫的轉換:
C:\Documents and Settings\Roby.Xuexb>oradim -new -sid newdb -startmode m
Instance created.
C:\Documents and Settings\Roby.Xuexb>set oracle_sid=newdb
<

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/196700/viewspace-749077/,如需轉載,請註明出處,否則將追究法律責任。

相關文章