利用AutoUpgrade工具升级数据库

0. 当升级到12cR2及以上的版本时,可以使用AutoUpgrade工具来完成升级工作。具体可以参考MOS文档AutoUpgrade Tool (Doc ID 2485457.1)。在本示例中,源数据库的版本为:11.2.0.4;目标数据库的版本为:19.3.0。
    
1.生成autoupgrade配置文件模板
/u01/app/oracle/product/19.0.0/dbhome_1/jdk/bin/java -jar /u01/app/oracle/product/19.0.0/dbhome_1/rdbms/admin/autoupgrade.jar -create_sample_file config


2.编辑autoupgrade配置文件
[oracle@oem ~]$ cat sample_config.cfg |grep -v ^# |grep -v ^$
global.autoupg_log_dir=/u01/app/oracle/cfgtoollogs/autoupgrade
upg1.log_dir=/u01/app/oracle/cfgtoollogs/autoupgrade/employee             # Path of the log directory for the upgrade job
upg1.sid=sdswhxcx                                              # ORACLE_SID of the source DB/CDB
upg1.source_home=/u01/app/oracle/product/11.2.0.4/dbhome_1  # Path of the source ORACLE_HOME
upg1.target_home=/u01/app/oracle/product/19.0.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=oem                                # 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=19                      # Oracle version of the target ORACLE_HOME.  Only required when the target Oracle database version is 12.2
根据实际情况修改以上参数值。

3.利用autoupgrade工具
分析当前数据库
[oracle@oem ~]$ /u01/app/oracle/product/19.0.0/dbhome_1/jdk/bin/java -jar /u01/app/oracle/product/19.0.0/dbhome_1/rdbms/admin/autoupgrade.jar -config sample_config.cfg -mode analyze
AutoUpgrade 22.5.221011 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 101 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
[oracle@oem ~]$
查看status.html文件,检查升级前的precheck工作是否成功,也可以根据status.log文件中记录的日志查看更详细的内容。如果当前数据库不满足升级要求,则根据提示进行调整。

4.利用autoupgrade工具正式升级
[oracle@oem ~]$ /u01/app/oracle/product/19.0.0/dbhome_1/jdk/bin/java -jar /u01/app/oracle/product/19.0.0/dbhome_1/rdbms/admin/autoupgrade.jar -config sample_config.cfg -mode deploy
AutoUpgrade 22.5.221011 launched with default internal options
Processing config file ...
+--------------------------------+
| Starting AutoUpgrade execution |
+--------------------------------+
1 Non-CDB(s) will be processed
Type 'help' to list console commands
upg> help
exit                             // To close and exit
help                            // Displays help
lsj [<option>] [-a <number>]    // list jobs by status up to n elements.
        -f                Filter by finished jobs.
        -r                Filter by running jobs.
        -e                Filter by jobs with errors.
        -p                Filter by jobs being prepared.
        -n <number>       Display up to n jobs.
        -a <number>       Repeats the command (in <number> seconds).
lsr                             // Displays the restoration queue
lsa                             // Displays the abort queue
tasks                           // Displays the tasks running
clear                           // Clears the terminal
resume -job <number>            // Restarts a previous job that was running
status [<option>] [-a <number>] // Summary of current execution
        -config                     Show Config Information
        -job <number>               Summary of a given job
        -job <number> -c <dbname>   Show details of container
        -a [<number>]               Repeats the command (in <number> seconds).
restore -job <number>           // Restores the database to its state prior to the upgrade
restore all_failed              // Restores all failed jobs to their previous states prior to the upgrade
logs                            // Displays all the log locations
abort -job <number>             // Aborts the specified job
h[ist]                          // Displays the command line history
/[<number>]                     // Executes the command specified from the history. The default is the last command
meta                            // Displays Internal latch count
hwinfo                          // Displays additional information
fxlist -job <number> [<option>]                // FixUps summary
        -c <dbname>                                  Container specific FixUps
        -c <dbname> alter <check> run <yes|no|skip>  Update Run Configuration
upg> lsj
+----+--------+---------+---------+-------+----------+-------+-------+
|Job#| DB_NAME|    STAGE|OPERATION| STATUS|START_TIME|UPDATED|MESSAGE|
+----+--------+---------+---------+-------+----------+-------+-------+
| 102|sdswhxcx|PREFIXUPS|EXECUTING|RUNNING|  14:45:03|11s ago|       |
+----+--------+---------+---------+-------+----------+-------+-------+
Total jobs 1

upg> tasks
+---+------------------+-------------+
| ID|              NAME|         Job#|
+---+------------------+-------------+
|  1|              main|      WAITING|
| 42|        event_loop|TIMED_WAITING|
| 43|           console|     RUNNABLE|
| 44|      queue_reader|      WAITING|
| 46|             cmd-0|      WAITING|
| 47|     job_manager-0|      WAITING|
|222|sdswhxcx-puifxl0-0|      WAITING|
|223|sdswhxcx-puifxl0-1|      WAITING|
|224|sdswhxcx-puifxl0-2|      WAITING|
|225|sdswhxcx-puifxl0-3|      WAITING|
|234|         exec_loop|      WAITING|
|237|        sql-512443|     RUNNABLE|
+---+------------------+-------------+
upg> Job 102 completed
------------------- Final Summary --------------------
Number of databases            [ 1 ]

Jobs finished                  [1]
Jobs failed                    [0]
Jobs restored                  [0]
Jobs pending                   [0]

---- Drop GRP at your convenience once you consider it is no longer needed ----
Drop GRP from sdswhxcx: drop restore point AUTOUPGRADE_9212_SDSWHXCX112040

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
[oracle@oem ~]$
查看status.html文件,检查升级工作是否成功。


5.设置compatible参数
在设置该参数之前,先删除之前创建的restore point。

SQL> drop restore point AUTOUPGRADE_9212_SDSWHXCX112040;

Restore point dropped.

SQL> alter database flashback off;

Database altered.

SQL> alter system set compatible='19.3.0' scope=spfile sid='*';

System altered.

6.重启数据库。
SQL> startup force

posted @ 2023-02-08 18:31  石云华  阅读(144)  评论(0编辑  收藏  举报