单实例11.2.0.4升级到12.1.0.2

单实例11.2.0.4升级到12c的测试

参考了https://blog.csdn.net/shiyu1157758655/article/details/78588645的博客

一、说明
大致步骤如下:

1.检查升级条件
2.安装12c 数据库
3.执行DBUA 升级DB,当然,也可以采用手工执行命令的方式,但根据官方资料看,建议放弃这个想法,DBUA 真的简化了很多,如果手工执行,会多很多步骤,这样会增加出错的概率。
4.检查数据库状态和无效对象。

详细说明可以参考MOS:
Complete Checklist for Manual Upgrades to Oracle Database 12c Release 1 (12.1) (文档 ID 1503653.1)
 

12c升级的路线说明

三、检查当前11g 数据库

从MOS上看,升级的过程,还是有些bug,所以oracle 建议在升级之前对源库做些检查。 包含内容如下:
1.冷备或者热备数据库,Oracle 建议冷备。
rman "target / nocatalog"
RUN
{
ALLOCATE CHANNEL chan_name TYPE DISK;
BACKUP DATABASE FORMAT '<db_backup_directory>%U' TAG before_upgrade;
BACKUP CURRENT CONTROLFILE TO '<controlfile_backup_directory>';
}
2.确保Oracle 所有组件都是有效的。
3.确保SYS和SYSTEM 用户下没有重名对象。 这种情况是可能存在的,因为oracle 里有namespace的概念,只要namespace 不同,对象名可以相同。
4.禁用任何用户的触发,等升级完成之后,再启用。

5.留意Bug 20369415 - UPGRADE TO 12C FAILS - XDB ERROR ORA-1830 ORA-6512: AT "SYS.XS_OBJECT_MIGRATION"

 

当然,12c 考虑到升级的方便性,可以直接从MOS上下载dbupgdiag.sql脚本,该脚本可以完成上述的检测内容。
Note 556610.1  Script to Collect DB Upgrade/Migrate Diagnostic Information (dbupgdiag.sql)
SQL> @dbupgdiag.sql
...
PL/SQL procedure successfully completed.
                *** End of LogFile ***
Enter value for log_path: /tmp

Upload db_upg_diag_cebpm_14_Nov_2017_1240.log from "/tmp" directory

注意看log,如果检测到无效对象,需要运行$ORACLE_HOME/rdbms/admin/utlrp.sql脚本,修复无效对象,如果有需要可以多次执行。

 

四。安装oracle12c软件,注意要创建新的ORACLE_HOME目录

正如最开始所说,我们需要把12c 安装到新的ORACLE_HOME,然后执行DBUA完成升级。 当然也可以一次搞定,但根据多次失败的经验来说,分开,更靠谱点。建议。

 

创建新目录:

安装结束,执行root.sh,完成安装。(这里仅仅是安装软件,不需要创建实例)

 

五、升级DB前的准备工作

执行Pre-Upgrade 脚本,如果是一次性完成DB安装和库的升级,那么就需要从MOS上下载:

How to Download and Run Oracle's Database Pre-Upgrade Utility (Doc ID 884522.1)

--这是解压缩:

test:/u01/src@oracle>unzip preupgrade_12.1.0.2.0_17_lf.zip
Archive:  preupgrade_12.1.0.2.0_17_lf.zip
  inflating: preupgrd.sql            
  inflating: utluppkg.sql            
test:/u01/src@oracle>

在安装完12c 的DB 软件之后,12c的目录里也带这2个脚本。

test:/u01/app/oracle/product/12.1.0/db_1/rdbms/admin@oracle>ll preupgrd.sql utluppkg.sql
-rw-r--r-- 1 oracle dba  14083 5月  15 2014 preupgrd.sql
-rw-r--r-- 1 oracle dba 495482 6月  22 2014 utluppkg.sql

这里我们直接执行。

SQL> @$ORACLE_HOME/rdbms/admin/preupgrd.sql
Loading Pre-Upgrade Package...
***************************************************************************
Executing Pre-Upgrade Checks in OGG6...
***************************************************************************


      ************************************************************

           ====>> ERRORS FOUND for OGG6 <<====

 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 OGG6 <<====

ACTIONS REQUIRED:

1. Review results of the pre-upgrade checks:
 /u01/app/oracle/cfgtoollogs/ogg6/preupgrade/preupgrade.log

2. Execute in the SOURCE environment BEFORE upgrade:
 /u01/app/oracle/cfgtoollogs/ogg6/preupgrade/preupgrade_fixups.sql

3. Execute in the NEW environment AFTER upgrade:
 /u01/app/oracle/cfgtoollogs/ogg6/preupgrade/postupgrade_fixups.sql

      ************************************************************

***************************************************************************
Pre-Upgrade Checks in OGG6 Completed.
***************************************************************************

***************************************************************************
***************************************************************************
SQL> @/u01/app/oracle/cfgtoollogs/ogg6/preupgrade/preupgrade_fixups.sql
Pre-Upgrade Fixup Script Generated on 2018-09-21 05:31:33  Version: 12.1.0.2 Build: 006
Beginning Pre-Upgrade Fixups...
Executing in container OGG6

**********************************************************************
Check Tag:     DEFAULT_PROCESS_COUNT
Check Summary: Verify min process count is not too low
Fix Summary:   Review and increase if needed, your PROCESSES value.
**********************************************************************
Fixup Returned Information:
WARNING: --> Process Count may be too low

     Database has a maximum process count of 150 which is lower than the
     default value of 300 for this release.
     You should update your processes value prior to the upgrade
     to a value of at least 300.
     For example:
        ALTER SYSTEM SET PROCESSES=300 SCOPE=SPFILE
     or update your init.ora file.
**********************************************************************


**********************************************************************
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.12 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.
 4 fixup routines returned INFORMATIONAL text that should be reviewed.

**************** Pre-Upgrade Fixup Script Complete *********************

[oracle@ogg6 admin]$ cat /u01/app/oracle/cfgtoollogs/ogg6/preupgrade/preupgrade.log
Oracle Database Pre-Upgrade Information Tool 09-21-2018 05:31:34
Script Version: 12.1.0.2.0 Build: 006
**********************************************************************
   Database Name:  OGG6
  Container Name:  Not Applicable in Pre-12.1 database
    Container ID:  Not Applicable in Pre-12.1 database
         Version:  11.2.0.4.0
      Compatible:  11.2.0.4.0
       Blocksize:  8192
        Platform:  Linux x86 64-bit
   Timezone file:  V14
**********************************************************************
                           [Update parameters]
         [Update Oracle Database 11.2.0.4.0 init.ora or spfile]
 
--> If Target Oracle is 32-bit, refer here for Update Parameters:
WARNING: --> "processes" needs to be increased to at least 300
 
--> If Target Oracle is 64-bit, refer here for Update Parameters:
WARNING: --> "processes" needs to be increased to at least 300
**********************************************************************
**********************************************************************
                          [Renamed Parameters]
                     [No Renamed Parameters in use]
**********************************************************************
**********************************************************************
                    [Obsolete/Deprecated Parameters]
             [No Obsolete or Desupported Parameters in use]
**********************************************************************
                            [Component List]
**********************************************************************
--> 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     
--> Oracle Enterprise Manager Repository   [upgrade]  VALID     
--> Oracle Text                            [upgrade]  VALID     
--> Oracle XML Database                    [upgrade]  VALID     
--> Oracle Java Packages                   [upgrade]  VALID     
--> Oracle Multimedia                      [upgrade]  VALID     
--> Oracle Spatial                         [upgrade]  VALID     
--> Expression Filter                      [upgrade]  VALID     
--> Rule Manager                           [upgrade]  VALID     
--> Oracle Application Express             [upgrade]  VALID     
--> Oracle OLAP API                        [upgrade]  VALID     
**********************************************************************
                              [Tablespaces]
**********************************************************************
--> SYSTEM tablespace is adequate for the upgrade.
     minimum required size: 1250 MB
--> SYSAUX tablespace is adequate for the upgrade.
     minimum required size: 1417 MB
--> UNDOTBS1 tablespace is adequate for the upgrade.
     minimum required size: 400 MB
--> TEMP tablespace is adequate for the upgrade.
     minimum required size: 60 MB

                      [No adjustments recommended]

**********************************************************************
**********************************************************************
                          [Pre-Upgrade Checks]
**********************************************************************
WARNING: --> Process Count may be too low

     Database has a maximum process count of 150 which is lower than the
     default value of 300 for this release.
     You should update your processes value prior to the upgrade
     to a value of at least 300.
     For example:
        ALTER SYSTEM SET PROCESSES=300 SCOPE=SPFILE

     or update your init.ora file.

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.

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.

INFORMATION: --> Older Timezone in use

     Database is using a time zone file older than version 18.
     After the upgrade, it is recommended that DBMS_DST package
     be used to upgrade the 11.2.0.4.0 database time zone version
     to the latest version which comes with the new release.
     Please refer to My Oracle Support note number 977512.1 for details.

ERROR: --> RECYCLE_BIN not empty.
     Your recycle bin contains 5 object(s). 
     It is REQUIRED that the recycle bin is empty prior to upgrading.
     Immediately before performing the upgrade, execute the following
     command:
       EXECUTE dbms_preup.purge_recyclebin_fixup;

INFORMATION: --> There are existing Oracle components that will NOT be
     upgraded by the database upgrade script.  Typically, such components
     have their own upgrade scripts, are deprecated, or obsolete.
     Those components are:  OLAP Catalog,OWB

INFORMATION: --> Oracle Application Express (APEX) can be
     manually upgraded prior to database upgrade

     APEX is currently at version 3.2.1.00.12 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 ^^^


**********************************************************************
                     [Post-Upgrade Recommendations]
**********************************************************************

                        *****************************************
                        ******** Fixed Object Statistics ********
                        *****************************************

Please create stats on fixed objects two weeks
after the upgrade using the command:
   EXECUTE DBMS_STATS.GATHER_FIXED_OBJECTS_STATS;

^^^ MANUAL ACTION SUGGESTED ^^^

**********************************************************************
                   ************  Summary  ************

 1 ERROR exist that must be addressed prior to performing your upgrade.
 2 WARNINGS that Oracle suggests are addressed to improve database performance.
 4 INFORMATIONAL messages that should be reviewed prior to your upgrade.

 After your database is upgraded and open in normal mode you must run 
 rdbms/admin/catuppst.sql which executes several required tasks and completes
 the upgrade process.

 You should follow that with the execution of rdbms/admin/utlrp.sql, and a
 comparison of invalid objects before and after the upgrade using
 rdbms/admin/utluiobj.sql

 If needed you may want to upgrade your timezone data using the process
 described in My Oracle Support note 1509653.1
                   ***********************************

 

主要修改如下:修改完成后,重启DB,让修改生效。

SQL>  ALTER SYSTEM SET PROCESSES=300 SCOPE=SPFILE;

System altered.

SQL> EXECUTE dbms_stats.gather_dictionary_stats;

PL/SQL procedure successfully completed.

如果你要升级的数据库开启过em,则还要执行下面的脚本:

SQL>@/u01/app/oracle/product/12.1.0/db_1/rdbms/admin/emremove.sql


另外还要修改下面的参数:

SQL> alter system set "_diag_adr_enabled"=true;

SQL> @$ORACLE_HOME/olap/admin/catnoamd.sql

否则会遇到bug 13499432:

'ORA-04063: View "SYS.V_$DIAG_VIPS_PACKAGE_MAIN_INT" Has Errors' During Upgrade (文档 ID 1674422.1)

另外Oracle 建议在升级12c之前手工升级APEX,这样可以减少停机时间。升级参考MOS:1088970.1。 看升级过程,在使用PCIE 闪存卡,16G 内存的情况下APEX耗时18分钟。

 

六、安装12c 的数据库并执行DBUA

[oracle@ogg6 bin]$ pwd
/u01/app/oracle/product/12.1.0/db_1/bin
[oracle@ogg6 bin]$ ./dbua 

SQL> purge dba_recyclebin;

DBA Recyclebin purged.

SQL> purge dba_recyclebin;

DBA Recyclebin purged.

[oracle@ogg6 oradata12c]$ pwd
/u01/app/oracle/oradata12c

注意:如果需要Move database,那么目录一定要和之前的不同,否则会升级失败。

这里演示的是移动了数据文件,实际上在升级的时候,没必要进行MOVE,因为升级完之后,还是NON CDB,后期还需要plug 到CDB中,到时还有一次copy的过程。

七、执行Postupgrade 脚本

[oracle@ogg6 preupgrade]$ echo $ORACLE_HOME
/u01/app/oracle/product/12.1.0/db_1

先修改环境变量中的12c的ORACLE_HOME,再执行脚本

Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> @/u01/app/oracle/cfgtoollogs/ogg6/preupgrade/postupgrade_fixups.sql
Post Upgrade Fixup Script Generated on 2018-09-21 05:31:33  Version: 12.1.0.2 Build: 006
Beginning Post-Upgrade Fixups...

**********************************************************************
Check Tag:     OLD_TIME_ZONES_EXIST
Check Summary: Check for use of older timezone data file
Fix Summary:   Update the timezone using the DBMS_DST package after upgrade is complete.
**********************************************************************
Fixup Returned Information:
INFORMATION: --> Older Timezone in use

     Database is using a time zone file older than version 18.
     After the upgrade, it is recommended that DBMS_DST package
     be used to upgrade the 12.1.0.2.0 database time zone version
     to the latest version which comes with the new release.
     Please refer to My Oracle Support note number 977512.1 for details.
**********************************************************************


**********************************************************************
Check Tag:     NOT_UPG_BY_STD_UPGRD
Check Summary: Identify existing components that will NOT be upgraded
Fix Summary:   This fixup does not perform any action.
**********************************************************************
Fixup Returned Information:
This fixup does not perform any action.  
If you want to upgrade those other components, you must do so manually.
**********************************************************************


**********************************************************************
                     [Post-Upgrade Recommendations]
**********************************************************************

                        *****************************************
                        ******** Fixed Object Statistics ********
                        *****************************************

Please create stats on fixed objects two weeks
after the upgrade using the command:
   EXECUTE DBMS_STATS.GATHER_FIXED_OBJECTS_STATS;

^^^ MANUAL ACTION SUGGESTED ^^^


           **************************************************
                ************* Fixup Summary ************

 2 fixup routines generated INFORMATIONAL messages that should be reviewed.

*************** Post Upgrade Fixup Script Complete ********************

PL/SQL procedure successfully completed.

八、其他善后工作和检查工作

将实例切换成CDB

安装完成之后,之前的数据库还是NON CDB 架构的,需要切换成CDB架构。

SQL> select name,cdb from v$database;

NAME      CDB
--------- ---
OGG6      NO

在操作之前我们先用DBCA创建一个空的CDB,然后把test 实例迁入到CDB中。

具体操作过程参考:

https://blog.csdn.net/m18994118189/article/details/82875817

SQL> show pdbs;

    CON_ID CON_NAME              OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
     2 PDB$SEED              READ ONLY  NO
     3 OGG6               READ WRITE NO


我这里采用的是COPY的方式,所以完成之后,可以把之前的目录全干掉。

 

11.2.0.1.0的timezone最高支持到11,如果要升级到11.2.0.3.0,必须要将timezone升级到14.
 

此次试验参考了时雨的文档,在此表示感谢。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值