一、升級路線 10.2.0.5,11.1.0.7,11.2.0.2以上版本可以直接升級到12c。 10.2.0.5以前的版本和11.2.0.1版需要先升級到中間版本,再升級到12c。 二、環境說明 操作系統:Red Hat 8 Linux 64位 源資料庫版本:Oracle 11.2.0.3 目標數 ...
一、升級路線
- 10.2.0.5,11.1.0.7,11.2.0.2以上版本可以直接升級到12c。
- 10.2.0.5以前的版本和11.2.0.1版需要先升級到中間版本,再升級到12c。
二、環境說明
- 操作系統:Red Hat 8 Linux 64位
- 源資料庫版本:Oracle 11.2.0.3
- 目標資料庫版本:Oracle 12.1.0.2
三、升級步驟簡述
- 備份源資料庫(RMan)
- 執行Pre-Upgrade Information Tool(preupgrd.sql)
- 準備新版本的Oracle Home
- 關閉資料庫實例
- 使用12c啟動資料庫,進入升級模式
- 執行並行升級實用程式(catctl.pl)
- 執行Post-Upgrade Status Tool(utlu121s.sql)
- 執行附加腳本(catuppst.sql和utlrp.sql)
- 完成升級階段
四、升級步驟
4.1、備份資料庫
4.2、執行Pre-Upgrade Information Tool
4.2.1、運行預升級工具腳本
使用目標版本資料庫(Oracle 12C)目錄/u01/app/oracle/product/12.1.0/dbhome_1/rdbms/admin/下的preupgrd.sql腳本。在源資料庫的SQL*Plus內執行。
1 sqlplus /nolog 2 3 SQL*Plus: Release 11.2.0.3.0 Production on Thu Sep 14 15:43:31 2023 4 5 Copyright (c) 1982, 2011, Oracle. All rights reserved. 6 7 SQL> conn / as sysdba 8 Connected. 9 SQL> @/u01/app/oracle/product/12.1.0/dbhome_1/rdbms/admin/preupgrd.sql
此工具是用來分析源資料庫存在的問題,並生成用來生成解決問題的腳本。
Loading Pre-Upgrade Package... *************************************************************************** Executing Pre-Upgrade Checks in RCAT... *************************************************************************** ************************************************************ ====>> ERRORS FOUND for RCAT <<==== The following are *** ERROR LEVEL CONDITIONS *** that must be addressed prior to attempting your upgrade. Failure to do so will result in a failed upgrade. 1) Check Tag: PURGE_RECYCLEBIN Check Summary: Check that recycle bin is empty prior to upgrade Fixup Summary: "The recycle bin will be purged." You MUST resolve the above error prior to upgrade ************************************************************ ************************************************************ ====>> PRE-UPGRADE RESULTS for RCAT <<==== ACTIONS REQUIRED: 1. Review results of the pre-upgrade checks: /u01/app/oracle/cfgtoollogs/rcat/preupgrade/preupgrade.log 2. Execute in the SOURCE environment BEFORE upgrade: /u01/app/oracle/cfgtoollogs/rcat/preupgrade/preupgrade_fixups.sql 3. Execute in the NEW environment AFTER upgrade: /u01/app/oracle/cfgtoollogs/rcat/preupgrade/postupgrade_fixups.sql ************************************************************ *************************************************************************** Pre-Upgrade Checks in RCAT Completed. *************************************************************************** *************************************************************************** ***************************************************************************
以上結果提示,必須先清空源數據的回收站。
建議關註預升級檢查記錄:/u01/app/oracle/cfgtoollogs/rcat/preupgrade/preupgrade.log。
4.2.2、升級前腳本
升級前在源環境運行升級前修複腳本:/u01/app/oracle/cfgtoollogs/rcat/preupgrade/preupgrade_fixups.sql,此腳本用來修複在源數據發現的問題。
1 SQL> @/u01/app/oracle/cfgtoollogs/rcat/preupgrade/preupgrade_fixups.sql
Pre-Upgrade Fixup Script Generated on 2023-09-14 15:51:38 Version: 12.1.0.2 Build: 006 Beginning Pre-Upgrade Fixups... Executing in container RCAT ********************************************************************** Check Tag: EM_PRESENT Check Summary: Check if Enterprise Manager is present Fix Summary: Execute emremove.sql prior to upgrade. ********************************************************************** Fixup Returned Information: WARNING: --> Enterprise Manager Database Control repository found in the database In Oracle Database 12c, Database Control is removed during the upgrade. To save time during the Upgrade, this action can be done prior to upgrading using the following steps after copying rdbms/admin/emremove.sql from the new Oracle home - Stop EM Database Control: $> emctl stop dbconsole - Connect to the Database using the SYS account AS SYSDBA: SET ECHO ON; SET SERVEROUTPUT ON; @emremove.sql Without the set echo and serveroutput commands you will not be able to follow the progress of the script. ********************************************************************** ********************************************************************** Check Tag: AMD_EXISTS Check Summary: Check to see if AMD is present in the database Fix Summary: Manually execute ORACLE_HOME/oraolap/admin/catnoamd.sql script to remove OLAP. ********************************************************************** Fixup Returned Information: INFORMATION: --> OLAP Catalog(AMD) exists in database Starting with Oracle Database 12c, OLAP Catalog component is desupported. If you are not using the OLAP Catalog component and want to remove it, then execute the ORACLE_HOME/olap/admin/catnoamd.sql script before or after the upgrade. ********************************************************************** ********************************************************************** Check Tag: PURGE_RECYCLEBIN Check Summary: Check that recycle bin is empty prior to upgrade Fix Summary: The recycle bin will be purged. ********************************************************************** Fixup Succeeded ********************************************************************** ********************************************************************** Check Tag: APEX_UPGRADE_MSG Check Summary: Check that APEX will need to be upgraded. Fix Summary: Oracle Application Express can be manually upgraded prior to database upgrade. ********************************************************************** Fixup Returned Information: INFORMATION: --> Oracle Application Express (APEX) can be manually upgraded prior to database upgrade APEX is currently at version 3.2.1.00.10 and will need to be upgraded to APEX version 4.2.5 in the new release. Note 1: To reduce database upgrade time, APEX can be manually upgraded outside of and prior to database upgrade. Note 2: See MOS Note 1088970.1 for information on APEX installation upgrades. ********************************************************************** ********************************************************************** [Pre-Upgrade Recommendations] ********************************************************************** ***************************************** ********* Dictionary Statistics ********* ***************************************** Please gather dictionary statistics 24 hours prior to upgrading the database. To gather dictionary statistics execute the following command while connected as SYSDBA: EXECUTE dbms_stats.gather_dictionary_stats; ^^^ MANUAL ACTION SUGGESTED ^^^ ************************************************** ************* Fixup Summary ************ 1 fixup routine was successful. 3 fixup routines returned INFORMATIONAL text that should be reviewed. **************** Pre-Upgrade Fixup Script Complete *********************
提出的建議如下:
- 發現了Enterprise Manager,在升級過程中會刪除EM庫,為了減少升級時間,可以先刪除。已自動處理。
-
發現了OLAP Catalog組件,在12C中不再支持OLAP Catalog組件,可以在升級前或升級後使用catnoamd.sql腳本刪除,這裡就不刪除了,升級後再說。
- 回收站是空的,不需要處理。如果回收站不是空的,將自動清空回收站。
-
發現了APEX,APEX版本升級會占用比較多的時間,oracle建議可以手工升級,參考: 1088970.1,這裡也不管了,一起升級。
- 建議在資料庫升級的24小時之前執行EXECUTE dbms_stats.gather_dictionary_stats;,收集數據字典統計信息。
1 SQL> EXECUTE dbms_stats.gather_dictionary_stats;
4.2.3、升級後腳本
升級後在新環境運行升級後修複腳本:/u01/app/oracle/cfgtoollogs/rcat/preupgrade/postupgrade_fixups.sql,此腳本用來修複資料庫升級後的問題。
4.3、準備12c Oracle Home
編輯/etc/oratab文件,將RCAT的環境變數指向Oracle 12C的Oracle Home。
1 [oracle@orasrv admin]$ vim /etc/oratab
rcat:/u01/app/oracle/product/12.1.0/dbhome_1:Y
4.4、關閉資料庫實例
1 SQL> shutdown immediate
4.5、使用12c啟動資料庫,進入升級模式
1 SQL*Plus: Release 12.1.0.2.0 Production on Thu Sep 14 16:36:59 2023 2 3 Copyright (c) 1982, 2014, Oracle. All rights reserved. 4 5 SQL> conn / as sysdba 6 Connected to an idle instance. 7 SQL> startup upgrade 8 ORA-01078: failure in processing system parameters 9 LRM-00109: could not open parameter file '/u01/app/oracle/product/12.1.0/dbhome_1/dbs/initrcat.ora'
以上提示說明需要參數文件initrcat.ora,我們將11g資料庫的參數文件複製到12c的相應目錄
1 [oracle@orasrv ~]$ cp /u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfilercat.ora /u01/app/oracle/product/12.1.0/dbhome_1/dbs/
再次啟動
1 SQL> startup upgrade
4.6、執行並行升級實用程式
1 SQL> @/u01/app/oracle/product/12.1.0/dbhome_1/rdbms/admin/catupgrd.sql
DOC>###################################################################### DOC>###################################################################### DOC> NOTE DOC> DOC> The catupgrd.sql is being deprecated in the 12.1 release of the DOC> Oracle Database. Customers are encouraged to use catctl.pl as DOC> the replacement for catupgrd.sql when upgrading the database dictionary. DOC> DOC> cd $ORACLE_HOME/rdbms/admin DOC> $ORACLE_HOME/perl/bin/perl catctl.pl -n 4 catupgrd.sql DOC> DOC> Refer to the Oracle Database Upgrade Guide for more information. DOC> DOC> This database upgrade procedure must be called with the following DOC> argument when invoking from the SQL prompt: DOC> DOC> @catupgrd.sql PARALLEL=NO DOC> DOC>###################################################################### DOC>###################################################################### DOC># old 2: WHERE UPPER('&&1') = 'PARALLEL=NO' OR new 2: WHERE UPPER('') = 'PARALLEL=NO' OR old 3: UPPER('&&1') = 'PARALLEL=YES' new 3: UPPER('') = 'PARALLEL=YES' SELECT (to_number(count(*)))/(to_number(count(*))) FROM DUAL * ERROR at line 1: ORA-01476: divisor is equal to zero
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
在12c中,使用升級腳本catctl.pl代替了catupgrd.sql,升級腳本的執行方式也發生了變化。根據以上提示可知,在Linux環境下需按以下方式執行:
[oracle@orasrv ~]$ cd $ORACLE_HOME/rdbms/admin [oracle@orasrv admin]$ $ORACLE_HOME/perl/bin/perl catctl.pl -n 2 catupgrd.sql
-n後參數2代表並行度為2,可按CPU核數進行設置。接下來就進入到漫長的升級過程:
Argument list for [catctl.pl] SQL Process Count n = 2 SQL PDB Process Count N = 0 Input Directory d = 0 Phase Logging Table t = 0 Log Dir l = 0 Script s = 0 Serial Run S = 0 Upgrade Mode active M = 0 Start Phase p = 0 End Phase P = 0 Log Id i = 0 Run in c = 0 Do not run in C = 0 Echo OFF e = 1 No Post Upgrade x = 0 Reverse Order r = 0 Open Mode Normal o = 0 Debug catcon.pm z = 0 Debug catctl.pl Z = 0 Display Phases y = 0 Child Process I = 0 catctl.pl version: 12.1.0.2.0 Oracle Base = /u01/app/oracle Analyzing file catupgrd.sql Log files in /u01/app/oracle/product/12.1.0/dbhome_1/rdbms/admin catcon: ALL catcon-related output will be written to catupgrd_catcon_4741.lst catcon: See catupgrd*.log files for output generated by scripts catcon: See catupgrd_*.lst files for spool files, if any Number of Cpus = 2 SQL Process Count = 2 ------------------------------------------------------ Phases [0-73] Serial Phase #: 0 Files: 1 Time: 99s Serial Phase #: 1 Files: 5 Time: 23s Restart Phase #: 2 Files: 1 Time: 0s Parallel Phase #: 3 Files: 18 Time: 27s Restart Phase #: 4 Files: 1 Time: 0s Serial Phase #: 5 Files: 5 Time: 32s Serial Phase #: 6 Files: 1 Time: 26s Serial Phase #: 7 Files: 4 Time: 5s Restart Phase #: 8 Files: 1 Time: 0s Parallel Phase #: 9 Files: 62 Time: 63s Restart Phase #:10 Files: 1 Time: 0s Serial Phase #:11 Files: 1 Time: 43s Restart Phase #:12 Files: 1 Time: 0s Parallel Phase #:13 Files: 91 Time: 49s Restart Phase #:14 Files: 1 Time: 0s Parallel Phase #:15 Files: 111 Time: 64s Restart Phase #:16 Files: 1 Time: 0s Serial Phase #:17 Files: 3 Time: 40s Restart Phase #:18 Files: 1 Time: 0s Parallel Phase #:19 Files: 32 Time: 56s Restart Phase #:20 Files: 1 Time: 0s Serial Phase #:21 Files: 3 Time: 43s Restart Phase #:22 Files: 1 Time: 0s Parallel Phase #:23 Files: 23 Time: 105s Restart Phase #:24 Files: 1 Time: 0s Parallel Phase #:25 Files: 11 Time: 71s Restart Phase #:26 Files: 1 Time: 0s Serial Phase #:27 Files: 1 Time: 20s Restart Phase #:28 Files: 1 Time: 0s Serial Phase #:30 Files: 1 Time: 0s Serial Phase #:31 Files: 257 Time: 51s Serial Phase #:32 Files: 1 Time: 0s Restart Phase #:33 Files: 1 Time: 0s Serial Phase #:34 Files: 1 Time: 43s Restart Phase #:35 Files: 1 Time: 0s Restart Phase #:36 Files: 1 Time: 17s Serial Phase #:37 Files: 4 Time: 74s Restart Phase #:38 Files: 1 Time: 0s Parallel Phase #:39 Files: 13 Time: 55s Restart Phase #:40 Files: 1 Time: 0s Parallel Phase #:41 Files: 10 Time: 46s Restart Phase #:42 Files: 1 Time: 0s Serial Phase #:43 Files: 1 Time: 44s Restart Phase #:44 Files: 1 Time: 0s Serial Phase #:45 Files: 1 Time: 38s Serial Phase #:46 Files: 1 Time: 0s Restart Phase #:47 Files: 1 Time: 0s Serial Phase #:48 Files: 1 Time: 115s Restart Phase #:49 Files: 1 Time: 0s Serial Phase #:50 Files: 1 Time: 69s Restart Phase #:51 Files: 1 Time: 0s Serial Phase #:52 Files: 1 Time: 51s Restart Phase #:53 Files: 1 Time: 0s Serial Phase #:54 Files: 1 Time: 147s Restart Phase #:55 Files: 1 Time: 0s Serial Phase #:56 Files: 1 Time: 81s Restart Phase #:57 Files: 1 Time: 0s Serial Phase #:58 Files: 1 Time: 124s Restart Phase #:59 Files: 1 Time: 0s Serial Phase #:60 Files: 1 Time: 200s Restart Phase #:61 Files: 1 Time: 0s Serial Phase #:62 Files: 1 Time: 1016s Restart Phase #:63 Files: 1 Time: 0s Serial Phase #:64 Files: 1 Time: 32s Serial Phase #:65 Files: 1 Calling sqlpatch with LD_LIBRARY_PATH=/u01/app/oracle/product/12.1.0/dbhome_1/lib; export LD_LIBRARY_PATH;/