【UP_ORACLE】使用AutoUpgrade工具升級Oracle 11.2.0.4至12.2.0.1

Attack_on_Jager發表於2022-09-19

說明

AutoUpgrade工具的功能包含了:

1. 升級前識別問題

2. 執行升級前和升級後操作

3. 部署升級

4. 執行升級後操作

5. 自動啟動升級後的 Oracle 資料庫

注:如果ORACLE_HOME裡面包含了autoupgrade.jar,建議下載最新的autoupgrade.jar( 最新的jar包在MOS 2485457.1)。


實驗環境

搭建平臺:VMware Workstation

OS:RHEL 7.6

DB:Oracle 11.2.0.4 & 12.2.0.1

 

升級步驟

1.  生成config檔案模板

(1)檢查java版本, 需要升級到jdk1.8(linux 7預設版本)

$ java -version
openjdk version "1.8.0_161"
OpenJDK Runtime Environment (build 1.8.0_161-b14)
OpenJDK 64-Bit Server VM (build 25.161-b14, mixed mode)

 

(2)生成config檔案模板

$ java -jar ./autoupgrade.jar -create_sample_file config

 

(3)編輯config檔案

$ cp sample_config.cfg config.cfg
$ vi config.cfg
global.autoupg_log_dir=/u01/app/oracle/cfgtoollogs/autoupgrade
 
#
# Database number 1 - Full DB/CDB upgrade
#
upg1.log_dir=/u01/app/oracle/cfgtoollogs/autoupgrade/employee             # Path of the log directory for the upgrade job
upg1.sid=PROD1                                             # ORACLE_SID of the source DB/CDB
upg1.source_home=/u01/app/oracle/product/11.2.0/dbhome_1  # Path of the source ORACLE_HOME
upg1.target_home=/u01/app/oracle/product/12.2.0/dbhome_1  # Path of the target ORACLE_HOME
upg1.start_time=NOW                                       # Optional. [NOW | +XhYm (X hours, Y minutes after launch) | dd/mm/yyyy hh:mm:ss]
upg1.upgrade_node=hhw                                # Optional. To find out the name of your node, run the hostname utility. Default is ''localhost''
upg1.run_utlrp=yes                                  # Optional. Whether or not to run utlrp after upgrade
upg1.timezone_upg=yes                              # Optional. Whether or not to run the timezone upgrade
upg1.target_version=12.2                      # Oracle version of the target ORACLE_HOME.  Only required when the target Oracle database version is 12.2

 

2.  執行analyze操作檢查升級的前置條件

$ java -jar autoupgrade.jar -config config.cfg -mode analyze
AutoUpgrade is not fully tested on OpenJDK 64-Bit Server VM, Oracle recommends to use Java HotSpot(TM)
AutoUpgrade 22.4.220712 launched with default internal options
Processing config file ...
+--------------------------------+
| Starting AutoUpgrade execution |
+--------------------------------+
1 Non-CDB(s) will be analyzed
Type 'help' to list console commands
upg> Job 100 completed
------------------- Final Summary --------------------
Number of databases            [ 1 ]
 
Jobs finished                  [1]
Jobs failed                    [0]
 
Please check the summary report at:
/u01/app/oracle/cfgtoollogs/autoupgrade/cfgtoollogs/upgrade/auto/status/status.html
/u01/app/oracle/cfgtoollogs/autoupgrade/cfgtoollogs/upgrade/auto/status/status.log

檢視生成的status.html是否顯示“SUCCESS”

 

如果不開啟歸檔,會報錯:

 

3.  下載並安裝12.2的安裝包並打最新PSU

這一步如果不打PSU,則會報錯:

2022-09-09 09:16:27.452 ERROR Dispatcher failed:
34Error: UPG-1411
35Invalid version /u01/app/oracle/product/12.2.0.1/dbhome_1/rdbms/admin/ of catctl.pl for AutoUpgrade; patch the target home
36Cause: Invalid version of catctl.pl and catctl.pm

 

此處下載過程過程省略, 下載地址在MOS 2118136.2

注:這裡我用的是檔案系統庫(非ASM),只需下載DB的PSU,如果涉及到GI,則需要下載GI的PSU(裡面包括了DB的PSU)

打PSU過程:

$ su - oracle
$ unzip -d $ORACLE_HOME /home/oracle/soft/p6880880_122010_Linux-x86-64.zip
 
$ cd ~/soft/
$ unzip p33587128_122010_Linux-x86-64.zip
$ cd 33587128
$ $ORACLE_HOME/OPatch/opatch apply
 
$ $ORACLE_HOME/OPatch/opatch lspatches
33587128;Database Jan 2022 Release Update : 12.2.0.1. 220118 (33587128)
 
OPatch succeeded.

 

4.  升級到12.2步驟

(1)$ java -jar autoupgrade.jar -config config.txt -mode deploy   

注:該命令僅適用於本地升級,異地升級命令見後文。

檢視進度:

upg> lsj
 +----+-------+---------+---------+-------+--------------+--------+------------+
 |Job#|DB_NAME|    STAGE|OPERATION| STATUS|    START_TIME| UPDATED|     MESSAGE|
 +----+-------+---------+---------+-------+--------------+--------+------------+
 | 100| LHR11G|DBUPGRADE|EXECUTING|RUNNING|22/09/09 09:29|01:02:17|98%Upgraded |
+----+-------+---------+---------+-------+--------------+--------+------------+
Total jobs 1

 

(2)檢視元件升級情況:

SQL > select COMP_ID,COMP_NAME,VERSION,STATUS from dba_registry;
 
COMP_ID    COMP_NAME                                VERSION         ATUS
---------- ---------------------------------------- --------------- ---------------
CATALOG    Oracle Database Catalog Views            12.2.0.1.0      UPGRADED
CATPROC    Oracle Database Packages and Types       12.2.0.1.0      UPGRADED
JAVAVM     JServer JAVA Virtual Machine             12.2.0.1.0      UPGRADED
XML        Oracle XDK                               12.2.0.1.0      UPGRADED
CATJAVA    Oracle Database Java Packages            12.2.0.1.0      UPGRADED
APS        OLAP Analytic Workspace                  12.2.0.1.0      UPGRADED
XOQ        Oracle OLAP API                          11.2.0.4.0      VALID
OWM        Oracle Workspace Manager                 12.2.0.1.0      UPGRADED
CONTEXT    Oracle Text                              12.2.0.1.0      UPGRADED
XDB        Oracle XML Database                      12.2.0.1.0      UPGRADED
ORDIM      Oracle Multimedia                        11.2.0.4.0      UPGRADING
SDO        Spatial                                  11.2.0.4.0      VALID
APEX       Oracle Application Express               3.2.1.00.12     VALID

 

(3)升級完成:

+----+-------+----------+---------+-------+--------------+--------+-------------+
|Job#|DB_NAME|     STAGE|OPERATION| STATUS|    START_TIME| UPDATED|      MESSAGE|
+----+-------+----------+---------+-------+--------------+--------+-------------+
| 100| LHR11G|POSTFIXUPS|EXECUTING|RUNNING|22/09/09 09:29|01:08:19|Remaining 3/4|
+----+-------+----------+---------+-------+--------------+--------+-------------+
Total jobs 1
upg> Job 100 completed
------------------- Final Summary --------------------
Number of databases            [ 1 ]
 
Jobs finished                  [1]
Jobs failed                    [0]
Jobs pending                   [0]
 
Please check the summary report at:
/home/oracle/cfgtoollogs/upgrade/auto/status/status.html
/home/oracle/cfgtoollogs/upgrade/auto/status/status.log

 

注:

如果是 異機升級(比如用備份恢復到異機),則需要使用如下兩個命令:

1)java -jar autoupgrade.jar -config config.txt -mode fixups

2)java -jar autoupgrade.jar -config config.txt -mode upgrade

 

(4)升級完成後步驟

alter system set compatible='12.2.0' scope=spfile;   ##重啟DB生效


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

相關文章