隨著Oracle 版本的升級,RMAN 也得到增強,在Oracle11g中的RMAN 支援不同作業系統和不同DB 之前的使用,關於RMAN 的相容性,參考:
Oracle RMAN 相容性 及 不同版本和不同平台之間使用 常見問題說明
這篇文章示範一個linux 下10g 恢複到11g中的樣本。
Target 端:
OS: Oracle Linux 6.1 64位
DB: 11.2.0.3
Source 端:
OS:Oracle Linux 6.1 64位
DB: 10.2.0.5
注意:
Oracle 10.2.0.1 不能直接升級到11gR2,至少需要先升級到10.2.0.2 以後才可以升級到11gR2,關於Oracle 升級路線圖參考我的Blog:Oracle9i/10g/11g 資料庫 升級路線圖(upgrade roadmap)
簡單的來說就是2個步驟:
1. 將10g 資料庫 還原11g上
2. 升級還原的10g資料庫到11g。
具體操作步驟如下。
一.在Source 庫用RMAN 備份資料庫
1.1 在Source 庫上執行utlu112i.sql指令碼
在Source 備份之前,需要執行一下utlu112i.sql 指令碼,如果不執行,那麼在升級時執行 @?/rdbms/admin/catupgrd.sql 指令碼時會報如下錯誤:
DOC> The following error is generated if the pre-upgrade tool has not been
DOC> run in the old ORACLE_HOME home prior to upgrading a pre-11.2 database:
DOC>
DOC> SELECT TO_NUMBER('MUST_HAVE_RUN_PRE-UPGRADE_TOOL_FOR_TIMEZONE')
DOC> *
DOC> ERROR at line 1:
DOC> ORA-01722: invalid number
DOC>
DOC> o Action:
DOC> Shutdown database ("alter systemcheckpoint" and then "shutdown abort").
DOC> Revert to the original oracle home andstart the database.
DOC> Run pre-upgrade tool against thedatabase.
DOC> Review and take appropriate actionsbased on the pre-upgrade
DOC> output before opening the datatabase inthe new software version.
DOC>
將11g $ORACLE_HOME/rdbms/admin 下的utlu112i.sql指令碼copy到10g的$ORACLE_HOME/rdbms/admin 下,並在10g上執行,這個指令碼可以檢查升級前的一些資訊。如果不滿足條件,會列出。
SQL> spool upgrade_info.log
SQL> @?/rdbms/admin/utlu112i.sql
Oracle Database 11.2 Pre-UpgradeInformation Tool 03-01-2012 19:53:57
Script Version: 11.2.0.3.0 Build: 001
.
**********************************************************************
Database:
**********************************************************************
--> name: ANQING
--> version: 10.2.0.5.0
--> compatible: 10.2.0.5.0
--> blocksize: 8192
--> platform: Linux x86 64-bit
--> timezone file: V4
.
**********************************************************************
Tablespaces: [make adjustments in thecurrent environment]
**********************************************************************
--> SYSTEM tablespace is adequate forthe upgrade.
.... minimum required size: 682 MB
--> UNDOTBS1 tablespace is adequate forthe upgrade.
.... minimum required size: 400 MB
--> SYSAUX tablespace is adequate forthe upgrade.
.... minimum required size: 454 MB
--> TEMP tablespace is adequate for theupgrade.
.... minimum required size: 60 MB
.
**********************************************************************
Flashback: OFF
**********************************************************************
**********************************************************************
Update Parameters: [Update Oracle Database11.2 init.ora or spfile]
Note: Pre-upgrade tool was run on a lowerversion 64-bit database.
**********************************************************************
--> If Target Oracle is 32-Bit, referhere for Update Parameters:
-- No update parameter changes are required.
.
--> If Target Oracle is 64-Bit, referhere for Update Parameters:
WARNING: --> "sga_target"needs to be increased to at least 596 MB
.
**********************************************************************
Renamed Parameters: [Update Oracle Database11.2 init.ora or spfile]
**********************************************************************
-- No renamed parameters found. No changesare required.
.
**********************************************************************
Obsolete/Deprecated Parameters: [UpdateOracle Database 11.2 init.ora or spfile]
**********************************************************************
--> background_dump_dest 11.1 DEPRECATED replaced by "diagnostic_dest"
--> user_dump_dest 11.1 DEPRECATED replaced by "diagnostic_dest"
.
**********************************************************************
Components: [The following databasecomponents will be upgraded or installed]
**********************************************************************
--> Oracle Catalog Views [upgrade] VALID
--> Oracle Packages and Types [upgrade] VALID
--> JServer JAVA Virtual Machine[upgrade] VALID
--> Oracle XDK for Java [upgrade] VALID
--> Oracle Workspace Manager [upgrade] VALID
--> OLAP Analytic Workspace [upgrade] VALID
--> OLAP Catalog [upgrade] VALID
--> EM Repository [upgrade] VALID
--> Oracle Text [upgrade] VALID
--> Oracle XML Database [upgrade] VALID
--> Oracle Java Packages [upgrade] VALID
--> Oracle interMedia [upgrade] VALID
--> Spatial [upgrade] VALID
--> Data Mining [upgrade] VALID
--> Expression Filter [upgrade] VALID
--> Rule Manager [upgrade] VALID
--> Oracle OLAP API [upgrade] VALID
.
**********************************************************************
Miscellaneous Warnings
**********************************************************************
WARNING: --> Database is using atimezone file older than version 14.
.... After the release migration, it isrecommended that DBMS_DST package
.... be used to upgrade the 10.2.0.5.0database timezone version
.... to the latest version which comes withthe new release.
WARNING: --> EM Database ControlRepository exists in the database.
.... Direct downgrade of EM DatabaseControl is not supported. Refer to the
.... Upgrade Guide for instructions to savethe EM data prior to upgrade.
WARNING: --> Your recycle bin is turnedon and currently contains no objects.
.... Because it is REQUIRED that therecycle bin be empty prior to upgrading
.... and your recycle bin is turned on, youmay need to execute the command:
PURGE DBA_RECYCLEBIN
.... prior to executing your upgrade toconfirm the recycle bin is empty.
.
**********************************************************************
Recommendations
**********************************************************************
Oracle recommends gathering dictionarystatistics prior to
upgrading the database.
To gather dictionary statistics execute thefollowing command
while connected as SYSDBA:
EXECUTE dbms_stats.gather_dictionary_stats;
**********************************************************************
Oracle recommends reviewing any definedevents prior to upgrading.
To view existing non-default events executethe following commands
while connected AS SYSDBA:
Events:
SELECT (translate(value,chr(13)||chr(10),' ')) FROM sys.v$parameter2
WHERE UPPER(name) ='EVENT'AND isdefault='FALSE'
Trace Events:
SELECT (translate(value,chr(13)||chr(10),' ')) from sys.v$parameter2
WHERE UPPER(name) = '_TRACE_EVENTS' AND isdefault='FALSE'
Changes will need to be made in theinit.ora or spfile.
**********************************************************************
SQL>
如果直接在11g上執行這個指令碼,那麼會報如下錯誤:
SQL> @?/rdbms/admin/utlu112i.sql
ERROR:
ORA-04023: Object SYS.STANDARD could not bevalidated or authorized
MOS 對這個問題的說明:
ORA-04023 On SYS.STANDARD When RunningUTLU111I.SQL or UTLU112I.SQL [ID 984511.1]
在網上搜到這麼一段:
WARNING: –> Database is using an oldtimezone file version.
…. Patch the 10.2.0.1.0 database to timezone file version 4
…. BEFORE upgrading the database. Re-run utlu111i.sql after
…. patching the database to record the new timezone file version.
To find time zone file version on sourcedatabase (10g) run
SQL> select * from v$timezone_file;
If time zone file version is lessthan 4 then apply time zone patch 5632264 manually for 10.2.0.1database。
--之前我們說10.2.0.1 不能直接升級到11gR2,通過這段文字,這個不能升級的原因可能就是與Time zone 相關。10.2.0.5的Time zone 值是4,滿足條件。對於timezone 值小於4的,要打Patch 5632264。
手頭沒有10.2.0.1的庫,暫時不能查詢,之前也遇到過一個time zone的問題。
Oracle TTSORA-39322: Cannot use transportable tablespace with different timezone version 說明
1.2 備份Source庫
備份指令碼參考:
Linux平台下RMAN 全備 和 增量備份shell 指令碼
Nocatalog下的RMAN 增量備份shell指令碼