Oracle数据库18c升级到19c

Posted dingdingfish

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Oracle数据库18c升级到19c相关的知识,希望对你有一定的参考价值。

本实验参考了文档Multitenant : Upgrading to Oracle Database 19c

已有数据库系统为Oracle 18.6,是多租户架构,有1个PDB,本文将其升级到19.3。

$ sqlplus / as sysdba

SQL*Plus: Release 18.0.0.0.0 - Production on Tue Jul 6 06:23:29 2021
Version 18.6.0.0.0

Copyright (c) 1982, 2018, Oracle.  All rights reserved.


Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.6.0.0.0

SQL> show pdbs;

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

先安装19c预安装包:

yum install -y oracle-database-preinstall-19c
yum update -y

有可能报错如下:

No package oracle-database-preinstall-19c available.
Error: Nothing to do

则改成以下命令:

yum install -y https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/getPackage/oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm

19c安装介质已上传:

$ ls -l *193*
-rw-r--r--. 1 oracle oinstall 3059705302 Feb  8 22:56 LINUX.X64_193000_db_home.zip

创建目录及解压数据库安装包:

export ORACLE_HOME=$ORACLE_BASE/product/19.0.0/dbhome_1
export SOFTWARE_DIR=~/Downloads
export ORA_INVENTORY=/u01/app/oraInventory

mkdir -p ${ORACLE_HOME}
cd $ORACLE_HOME

/bin/unzip -oq ${SOFTWARE_DIR}/LINUX.X64_193000_db_home.zip

开始安装,仅安装数据库软件:

export ORA_INVENTORY=/u01/app/oraInventory
export ORACLE_HOSTNAME=$(hostname -s)

cd $ORACLE_HOME

./runInstaller -ignorePrereq -waitforcompletion -silent                        \\
    -responseFile ${ORACLE_HOME}/install/response/db_install.rsp               \\
    oracle.install.option=INSTALL_DB_SWONLY                                    \\
    ORACLE_HOSTNAME=${ORACLE_HOSTNAME}                                         \\
    UNIX_GROUP_NAME=oinstall                                                   \\
    INVENTORY_LOCATION=${ORA_INVENTORY}                                        \\
    SELECTED_LANGUAGES=en,en_GB                                                \\
    ORACLE_HOME=${ORACLE_HOME}                                                 \\
    ORACLE_BASE=${ORACLE_BASE}                                                 \\
    oracle.install.db.InstallEdition=EE                                        \\
    oracle.install.db.OSDBA_GROUP=dba                                          \\
    oracle.install.db.OSBACKUPDBA_GROUP=dba                                    \\
    oracle.install.db.OSDGDBA_GROUP=dba                                        \\
    oracle.install.db.OSKMDBA_GROUP=dba                                        \\
    oracle.install.db.OSRACDBA_GROUP=dba                                       \\
    SECURITY_UPDATES_VIA_MYORACLESUPPORT=false                                 \\
    DECLINE_SECURITY_UPDATES=true

此过程很快,用了48秒。然后按提示以root用户执行以下脚本:

As a root user, execute the following script(s):
        1. /u01/app/oraInventory/orainstRoot.sh
        2. /u01/app/oracle/product/19.0.0/dbhome_1/root.sh

从How to Download and Run Oracle’s Database Pre-Upgrade Utility (Doc ID 884522.1)中下载Pre-Upgrade软件,并解压。

export ORACLE_HOME=$ORACLE_BASE/product/19.0.0/dbhome_1
cd $ORACLE_HOME/rdbms/admin
export SOFTWARE_DIR=~/Downloads
unzip -o $SOFTWARE_DIR/preupgrade_19_cbuild_10_lf.zip

确保是升级前的数据库环境:

$ echo $ORACLE_HOME
/u01/app/oracle/product/18.0.0/dbhome_1
$ echo $ORACLE_SID
orcl

运行升级前检查程序:

$ORACLE_BASE/product/19.0.0/dbhome_1/jdk/bin/java -jar $ORACLE_BASE/product/19.0.0/dbhome_1/rdbms/admin/preupgrade.jar TERMINAL TEXT

输出如下:

Report generated by Oracle Database Pre-Upgrade Information Tool Version
19.0.0.0.0 Build: 10 on 2021-07-06T11:16:05

Upgrade-To version: 19.0.0.0.0

=======================================
Status of the database prior to upgrade
=======================================
      Database Name:  ORCL
     Container Name:  CDB$ROOT
       Container ID:  1
            Version:  18.0.0.0.0
     DB Patch Level:  Database Release Update : 18.6.0.0.190416 (29301631)
         Compatible:  18.0.0
          Blocksize:  8192
           Platform:  Linux x86 64-bit
      Timezone File:  31
  Database log mode:  NOARCHIVELOG
           Readonly:  FALSE
            Edition:  EE

  Oracle Component                       Upgrade Action    Current Status
  ----------------                       --------------    --------------
  Oracle Server                          [to be upgraded]  VALID
  JServer JAVA Virtual Machine           [to be upgraded]  VALID
  Oracle XDK for Java                    [to be upgraded]  VALID
  Real Application Clusters              [to be upgraded]  OPTION OFF
  Oracle Workspace Manager               [to be upgraded]  VALID
  OLAP Analytic Workspace                [to be upgraded]  VALID
  Oracle Label Security                  [to be upgraded]  VALID
  Oracle Database Vault                  [to be upgraded]  VALID
  Oracle Text                            [to be upgraded]  VALID
  Oracle XML Database                    [to be upgraded]  VALID
  Oracle Java Packages                   [to be upgraded]  VALID
  Oracle Multimedia                      [to be upgraded]  VALID
  Oracle Spatial                         [to be upgraded]  VALID
  Oracle OLAP API                        [to be upgraded]  VALID

  *
  * ALL Components in This Database Registry:
  *
  Component   Current      Current      Original     Previous     Component
  CID         Version      Status       Version      Version      Schema
  ----------  -----------  -----------  -----------  -----------  ------------
  APS         18.6.0.0.0   VALID        18.1.0.0.0                SYS
  CATALOG     18.6.0.0.0   VALID        18.1.0.0.0                SYS
  CATJAVA     18.6.0.0.0   VALID        18.1.0.0.0                SYS
  CATPROC     18.6.0.0.0   VALID        18.1.0.0.0                SYS
  CONTEXT     18.6.0.0.0   VALID        18.1.0.0.0                CTXSYS
  DV          18.6.0.0.0   VALID        18.1.0.0.0                DVSYS
  JAVAVM      18.6.0.0.0   VALID        18.1.0.0.0                SYS
  OLS         18.6.0.0.0   VALID        18.1.0.0.0                LBACSYS
  ORDIM       18.6.0.0.0   VALID        18.1.0.0.0                ORDSYS
  OWM         18.6.0.0.0   VALID        18.1.0.0.0                WMSYS
  RAC         18.6.0.0.0   OPTION OFF   18.1.0.0.0                SYS
  SDO         18.6.0.0.0   VALID        18.1.0.0.0                MDSYS
  XDB         18.6.0.0.0   VALID        18.1.0.0.0                XDB
  XML         18.6.0.0.0   VALID        18.1.0.0.0                SYS
  XOQ         18.6.0.0.0   VALID        18.1.0.0.0                OLAPSYS

  *
  * Number of INVALID Objects by Oracle-Maintained and Application Users:
  *
  Oracle-Maintained User Name                   Number of INVALID Objects
  ---------------------------                   -------------------------
  CTXSYS                                        2
  MDSYS                                         7
  PUBLIC                                        5
  SYS                                           3

  Application User Name                         Number of INVALID Objects
  ---------------------------                   -------------------------
  None                                          None

==============
BEFORE UPGRADE
==============

  REQUIRED ACTIONS
  ================
  None

  RECOMMENDED ACTIONS
  ===================
  1.  Run 18.0.0.0.0 $ORACLE_HOME/rdbms/admin/utlrp.sql to recompile invalid
      objects.  You can view the individual invalid objects with

        SET SERVEROUTPUT ON;
        EXECUTE DBMS_PREUP.INVALID_OBJECTS;

      17 objects are INVALID.

      There should be no INVALID objects in SYS/SYSTEM or user schemas before
      database upgrade.

  2.  (AUTOFIXUP) Gather stale data dictionary statistics prior to database
      upgrade in off-peak time using:

        EXECUTE DBMS_STATS.GATHER_DICTIONARY_STATS;

      Dictionary statistics do not exist or are stale (not up-to-date).

      Dictionary statistics help the Oracle optimizer find efficient SQL
      execution plans and are essential for proper upgrade timing. Oracle
      recommends gathering dictionary statistics in the last 24 hours before
      database upgrade.

      For information on managing optimizer statistics, refer to the 18.0.0.0
      Oracle Database Upgrade Guide.

  INFORMATION ONLY
  ================
  3.  To help you keep track of your tablespace allocations, the following
      AUTOEXTEND tablespaces are expected to successfully EXTEND during the
      upgrade process.

                                                 Min Size
      Tablespace                        Size     For Upgrade
      ----------                     ----------  -----------
      SYSTEM                             900 MB      1011 MB
      TEMP                                39 MB       150 MB

      Minimum tablespace sizes for upgrade are estimates.

  4.  No action needed.

      Using default parallel upgrade options, this CDB with 2 PDBs will first
      upgrade the CDB$ROOT, and then upgrade at most 2 PDBs at a time using 2
      parallel processes per PDB.

      The number of PDBs upgraded in parallel and the number of parallel
      processes per PDB can be adjusted as described in Database Upgrade Guide.

  5.  In a CDB, you can recompile in N PDBs in parallel and have each PDB's
      recompilation use R degree of parallelism.
      For example:
        $ORACLE_HOME/perl/bin/perl $ORACLE_HOME/rdbms/admin/catcon.pl -b recomp
      -d $ORACLE_HOME/rdbms/admin -n <N pdbs in parallel> -l /tmp utlprp.sql
      '--p<R degree of parallelism to utlrp>'
      Note:
       a) If total number of PDBs to recompile in is more than cpu_count/2, you
      can start with N as cpu_count/2; else set N to the number of PDBs.
       b) You can start with R as 2, as in:  ..catcon.pl .. utlprp.sql '--p2'
       c) And you can adjust N and R as needed for your database and system.
       d) Note: cpu_count is an Oracle initialization parameter.

      This is an informational message on how you can run utlrp in a CDB.

      Recompiling invalid objects in a CDB can be done in multiple PDBs in
      parallel.

  6.  Check the Oracle Backup and Recovery User's Guide for information on how
      to manage an RMAN recovery catalog schema.

      If you are using a version of the recovery catalog schema that is older
      than that required by the RMAN client version, then you must upgrade the
      catalog schema.

      It is good practice to have the catalog schema the same or higher version
      than the RMAN client version you are using.

  ORACLE GENERATED FIXUP SCRIPT
  =============================
  All of the issues in database ORCL container CDB$ROOT
  which are identified above as BEFORE UPGRADE "(AUTOFIXUP)" can be resolved by
  executing the following from within the container

    SQL>@/u01/app/oracle/cfgtoollogs/orcl/preupgrade/preupgrade_fixups.sql

=============
AFTER UPGRADE
=============

  REQUIRED ACTIONS
  ================
  None

  RECOMMENDED ACTIONS
  ===================
  7.  Upgrade the database time zone file using the DBMS_DST package.

      The database is using time zone file version 31 and the target 19 release
      ships with time zone file version 32.

      Oracle recommends upgrading to the desired (latest) version of the time
      zone file.  For more information, refer to "Upgrading the Time Zone File
      and Timestamp with Time Zone Data" in the 19 Oracle Database
      Globalization Support Guide.

  8.  (AUTOFIXUP) Gather dictionary statistics after the upgrade using the
      command:

        EXECUTE DBMS_STATS.GATHER_DICTIONARY_STATS;

      Oracle recommends gathering dictionary statistics after upgrade.

      Dictionary statistics provide essential information to the Oracle
      optimizer to help it find efficient SQL execution plans. After a database
      upgrade, statistics need to be re-gathered as there can now be tables
      that have significantly changed during the upgrade or new tables that do
      not have statistics gathered yet.

  9.  Gather statistics on fixed objects after the upgrade and when there is a
      representative workload on the system using the command:

        EXECUTE DBMS_STATS.GATHER_FIXED_OBJECTS_STATS;

      This recommendation is given for all preupgrade runs.

      Fixed object statistics provide essential information to the Oracle
      optimizer to help it find efficient SQL execution plans.  Those
      statistics are specific to the Oracle Database release that generates
      them, and can be stale upon database upgrade.

      For information on managing optimizer statistics, refer to the 18.0.0.0
      Oracle Database Upgrade Guide.

  ORACLE GENERATED FIXUP SCRIPT
  =============================
  All of the issues in database ORCL container CDB$ROOT
  which are identified above as AFTER UPGRADE "(AUTOFIXUP)" can be resolved by
  executing the following from within the container

    SQL>@/u01/app/oracle/cfgtoollogs/orcl/preupgrade/postupgrade_fixups.sql


Report generated by Oracle Database Pre-Upgrade Information Tool Version
19.0.0.0.0 Build: 10 on 2021-07-06T11:16:31

Upgrade-To version: 19.0.0.0.0

=======================================
Status of the database prior to upgrade
=======================================
      Database Name:  ORCL
     Container Name:  PDB$SEED
       Container ID:  2
            Version:  18.0.0.0.0
     DB Patch Level:  Database Release Update : 18.6.0.0.190416 (29301631)
         Compatible:  18.0.0
          Blocksize:  8192
           Platform:  Linux x86 64-bit
      Timezone File:  31
  Database log mode:  NOARCHIVELOG
           Readonly:  TRUE
            Edition:  EE

  Oracle Component                       Upgrade Action    Current Status
  ----------------                       --------------    --------------
  Oracle Server                          [to be upgraded]  VALID
  JServer JAVA Virtual Machine           [to be upgraded]  VALID
  Oracle XDK for Java                    [to be upgraded]  VALID
  Real Application Clusters              [to be upgraded]  OPTION OFF
  Oracle Workspace Manager               [to be upgraded]  VALID
  OLAP Analytic Workspace                [to be upgraded]  VALID
  Oracle Label Security                  [to be upgraded]  VALID
  Oracle Database Vault                  [to be upgraded]  VALID
  Oracle Text                            [to be upgraded]  VALID
  Oracle XML Database                    [to be upgraded]  VALID
  Oracle Java Packages                   [to be upgraded]  VALID
  Oracle Multimedia                      [to be upgraded]  VALID
  Oracle Spatial                         [to be upgraded]  VALID
  Oracle OLAP API                        [to be upgraded]  VALID

  *
  * ALL Components in This Database Registry:
  *
  Component   Current      Current      Original     Previous     Component
  CID         Version      Status       Version      Version      Schema
  ----------  -----------  -----------  -----------  -----------  ------------
  APS         18.6.0.0.0   VALID        18.1.0.0.0                SYS
  CATALOG     18.6.0.0.0   VALID        18.1.0.0.0                SYS
  CATJAVA     18.6.0.0.0   VALID        18.1.0.0.0                SYS
  CATPROC     18.6.0.0.0   VALID        18.1.0.0.0                SYS
  CONTEXT     18.6.0.0.0   VALID        18.1.0.0.0                CTXSYS
  DV          18.6.0.0.0   VALID        18.1.0.0.0                DVSYS
  JAVAVM      18.6.0.0.0   VALID        18.1.0.0.0                SYS
  OLS         18.6.0.0.0   VALID        18.1.0.0.0                LBACSYS
  ORDIM       18.6.0.0.0   VALID        18.1.0.0.0                ORDSYS
  OWM         18.6.0.0.0   VALID        18.1.0.0.0                WMSYS
  RAC         18.6.0.0.0   OPTION OFF   18.1.0.0.0                SYS
  SDO         18.6.0.0.0   VALID        18.1.0.0.0                MDSYS
  XDB         18.6.0.0.0   VALID        18.1.0.0.0                XDB
  XML         18.6.0.0.0   VALID        18.1.0.0.0                SYS
  XOQ         18.6.0.0.0   VALID        18.1.0.0.0                OLAPSYS

  *
  * Number of INVALID Objects by Oracle-Maintained and Application Users:
  *
  Oracle-Maintained User Name                   Number of INVALID Objects
  ---------------------------                   -------------------------
  CTXSYS                                        14
  MDSYS                                         46
  PUBLIC                                        31
  SYS                                           50
  XDB                                           6

  Application User Name                         Number of INVALID Objects
  ---------------------------                   -------------------------
  None                                          None

==============
BEFORE UPGRADE
==============

  REQUIRED ACTIONS
  ================
  None

  RECOMMENDED ACTIONS
  ===================
  1.  Run 18.0.0.0.0 $ORACLE_HOME/rdbms/admin/utlrp.sql to recompile invalid
      objects.  You can view the individual invalid objects with

        SET SERVEROUTPUT ON;
        EXECUTE DBMS_PREUP.INVALID_OBJECTS;

      145 objects are INVALID.

      There should be no INVALID objects in SYS/SYSTEM or user schemas before
      database upgrade.

  2.  (AUTOFIXUP) Gather stale data dictionary statistics prior to database
      upgrade in off-peak time using:

        EXECUTE DBMS_STATS.GATHER_DICTIONARY_STATS;

      Dictionary statistics do not exist or are stale (not up-to-date).

      Dictionary statistics help the Oracle optimizer find efficient SQL
      execution plans and are essential for proper upgrade timing. Oracle
      recommends gathering dictionary statistics in the last 24 hours before
      database upgrade.

      For information on managing optimizer statistics, refer to the 18.0.0.0
      Oracle Database Upgrade Guide.

  3.  (AUTOFIXUP) Gather statistics on fixed objects prior to the upgrade using
      the command:

        EXECUTE DBMS_STATS.GATHER_FIXED_OBJECTS_STATS;

      None of the fixed object tables have had stats collected.

      Gathering statistics on fixed objects, if none have been gathered yet, is
      recommended prior to upgrading.

      For information on managing optimizer statistics, refer to the 18.0.0.0
      Oracle Database Upgrade Guide.

  INFORMATION ONLY
  ================
  4.  To help you keep track of your tablespace allocations, the following
      AUTOEXTEND tablespaces are expected to successfully EXTEND during the
      upgrade process.

                                                 Min Size
      Tablespace                        Size     For Upgrade
      ----------                     ----------  -----------
      SYSAUX                             350 MB       500 MB
      SYSTEM                             300 MB       409 MB
      TEMP                                62 MB       150 MB
      UNDOTBS1                           100 MB       439 MB

      Minimum tablespace sizes for upgrade are estimates.

  5.  In a CDB, you can recompile in N PDBs in parallel and have each PDB's
      recompilation use R degree of parallelism.
      For example:
        $ORACLE_HOME/perl/bin/perl $ORACLE_HOME/rdbms/admin/catcon.pl -b recomp
      -d $ORACLE_HOME/rdbms/admin -n <N pdbs in parallel> -l /tmp utlprp.sql
      '--p<R degree of parallelism to utlrp>'
      Note:
       a) If total number of PDBs to recompile in is more than cpu_count/2, you
      can start with N as cpu_count/2; else set N to the number of PDBs.
       b) You can start with R as 2, as in:  ..catcon.pl .. utlprp.sql '--p2'
       c) And you can adjust N and R as needed for your database and system.
       d) Note: cpu_count is an Oracle initialization parameter.

      This is an informational message on how you can run utlrp in a CDB.

      Recompiling invalid objects in a CDB can be done in multiple PDBs in
      parallel.

  ORACLE GENERATED FIXUP SCRIPT
  =============================
  All of the issues in database ORCL container PDB$SEED
  which are identified above as BEFORE UPGRADE "(AUTOFIXUP)" can be resolved by
  executing the following from within the container

    SQL>@/u01/app/oracle/cfgtoollogs/orcl/preupgrade/preupgrade_fixups.sql

=============
AFTER UPGRADE
=============

  REQUIRED ACTIONS
  ================
  None

  RECOMMENDED ACTIONS
  ===================
  6.  Upgrade the database time zone file using the DBMS_DST package.

      The database is using time zone file version 31 and the target 19 release
      ships with time zone file version 32.

      Oracle recommends upgrading to the desired (latest) version of the time
      zone file.  For more information, refer to "Upgrading the Time Zone File
      and Timestamp with Time Zone Data" in the 19 Oracle Database
      Globalization Support Guide.

  7.  (AUTOFIXUP) Gather dictionary statistics after the upgrade using the
      command:

        EXECUTE DBMS_STATS.GATHER_DICTIONARY_STATS;

      Oracle recommends gathering dictionary statistics after upgrade.

      Dictionary statistics provide essential information to the Oracle
      optimizer to help it find efficient SQL execution plans. After a database
      upgrade, statistics need to be re-gathered as there can now be tables
      that have significantly changed during the upgrade or new tables that do
      not have statistics gathered yet.

  8.  Gather statistics on fixed objects after the upgrade and when there is a
      representative workload on the system using the command:

        EXECUTE DBMS_STATS.GATHER_FIXED_OBJECTS_STATS;

      This recommendation is given for all preupgrade runs.

      Fixed object statistics provide essential information to the Oracle
      optimizer to help it find efficient SQL execution plans.  Those
      statistics are specific to the Oracle Database release that generates
      them, and can be stale upon database upgrade.

      For information on managing optimizer statistics, refer to the 18.0.0.0
      Oracle Database Upgrade Guide.

  ORACLE GENERATED FIXUP SCRIPT
  =============================
  All of the issues in database ORCL container PDB$SEED
  which are identified above as AFTER UPGRADE "(AUTOFIXUP)" can be resolved by
  executing the following from within the container

    SQL>@/u01/app/oracle/cfgtoollogs/orcl/preupgrade/postupgrade_fixups.sql


Report generated by Oracle Database Pre-Upgrade Information Tool Version
19.0.0.0.0 Build: 10 on 2021-07-06T11:16:21

Upgrade-To version: 19.0.0.0.0

=======================================
Status of the database prior to upgrade
=======================================
      Database Name:  ORCL
     Container Name:  ORCLPDB
       Container ID:  3
            Version:  18.0.0.0.0
     DB Patch Level:  Database Release Update : 18.6.0.0.190416 (29301631)
         Compatible:  18.0.0
          Blocksize:  8192
           Platform:  Linux x86 64-bit
      Timezone File:  31
  Database log mode:  NOARCHIVELOG
           Readonly:  FALSE
            Edition:  EE

  Oracle Component                       Upgrade Action    Current Status
  ----------------                       --------------    --------------
  Oracle Server                          [to be upgraded]  VALID
  JServer JAVA Virtual Machine           [to be upgraded]  VALID
  Oracle XDK for Java                    [to be upgraded]  VALID
  Real Application Clusters              [to be upgraded]  OPTION OFF
  Oracle Workspace Manager               [to be upgraded]  VALID
  OLAP Analytic Workspace                [to be upgraded]  VALID
  Oracle Label Security                  [to be upgraded]  VALID
  Oracle Database Vault                  [to be upgraded]  VALID
  Oracle Text                            [to be upgraded]  VALID
  Oracle XML Database                    [to be upgraded]  VALID
  Oracle Java Packages                   [to be upgraded]  VALID
  Oracle Multimedia                      [to be upgraded]  VALID
  Oracle Spatial                         [to be upgraded]  VALID
  Oracle OLAP API                        [to be upgraded]  VALID

  *
  * ALL Components in This Database Registry:
  *
  Component   Current      Current      Original     Previous     Component
  CID         Version      Status       Version      Version      Schema
  ----------  -----------  -----------  -----------  -----------  ------------
  APS         18.6.0.0.0   VALID        18.1.0.0.0                SYS
  CATALOG     18.6.0.0.0   VALID        18.1.0.0.0                SYS
  CATJAVA     18.6.0.0.0   VALID        18.1.0.0.0                SYS
  CATPROC     18.6.0.0.0   VALID        18.1.0.0.0                SYS
  CONTEXT     18.6.0.0.0   VALID        18.1.0.0.0                CTXSYS
  DV          18.6.0.0.0   VALID        18.1.0.0.0                DVSYS
  JAVAVM      18.6.0.0.0   VALID        18.1.0.0.0                SYS
  OLS         18.6.0.0.0   VALID        18.1.0.0.0                LBACSYS
  ORDIM       18.6.0.0.0   VALID        18.1.0.0.0                ORDSYS
  OWM         18.6.0.0.0   VALID        18.1.0.0.0                WMSYS
  RAC         18.6.0.0.0   OPTION OFF   18.1.0.0.0                SYS
  SDO         18.6.0.0.0   VALID        18.1.0.0.0                MDSYS
  XDB         18.6.0.0.0   VALID        18.1.0.0.0                XDB
  XML         18.6.0.0.0   VALID        18.1.0.0.0                SYS
  XOQ         18.6.0.0.0   VALID        18.1.0.0.0                OLAPSYS

  *
  * Number of INVALID Objects by Oracle-Maintained and Application Users:
  *
  Oracle-Maintained User Name                   Number of INVALID Objects
  ---------------------------                   -------------------------
  CTXSYS                                        12
  MDSYS                                         46
  PUBLIC                                        37
  SYS                                           27
  XDB                                           5

  Application User Name                         Number of INVALID Objects
  ---------------------------                   -------------------------
  BIKES                                         1
  ORDS_METADATA                                 8

==============
BEFORE UPGRADE
==============

  REQUIRED ACTIONS
  ================
  1.  (AUTOFIXUP) Empty the RECYCLEBIN immediately before database upgrade.

      The database contains 13 objects in the recycle bin.

      The recycle bin must be completely empty before database upgrade.

  RECOMMENDED ACTIONS
  ===================
  2.  Run 18.0.0.0.0 $ORACLE_HOME/rdbms/admin/utlrp.sql to recompile invalid
      objects.  You can view the individual invalid objects with

        SET SERVEROUTPUT ON;
        EXECUTE DBMS_PREUP.INVALID_OBJECTS;

      136 objects are INVALID.

      There should be no INVALID objects in SYS/SYSTEM or user schemas before
      database upgrade.

  3.  (AUTOFIXUP) Gather stale data dictionary statistics prior to database
      upgrade in off-peak time using:

        EXECUTE DBMS_STATS.GATHER_DICTIONARY_STATS;

      Dictionary statistics do not exist or are stale (not up-to-date).

      Dictionary statistics help the Oracle optimizer find efficient SQL
      execution plans and are essential for proper upgrade timing. Oracle
      recommends gathering dictionary statistics in the last 24 hours before
      database upgrade.

      For information on managing optimizer statistics, refer to the 18.0.0.0
      Oracle Database Upgrade Guide.

  INFORMATION ONLY
  ================
  4.  To help you keep track of your tablespace allocations, the following
      AUTOEXTEND tablespaces are expected to successfully EXTEND during the
      upgrade process.

                                                 Min Size
      Tablespace                        Size     For Upgrade
      ----------                     ----------  -----------
      SYSAUX                             478 MB       500 MB
      SYSTEM                             313 MB       428 MB
      UNDOTBS1                            79 MB       439 MB

      Minimum tablespace sizes for upgrade are estimates.

  5.  In a CDB, you can recompile in N PDBs in parallel and have each PDB's
      recompilation use R degree of parallelism.
      For example:
        $ORACLE_HOME/perl/bin/perl $ORACLE_HOME/rdbms/admin/catcon.pl -b recomp
      -d $ORACLE_HOME/rdbms/admin -n <N pdbs in parallel> -l /tmp utlprp.sql
      '--p<R degree of parallelism to utlrp>'
      Note:
       a) If total number of PDBs to recompile in is more than cpu_count/2, you
      can start with N as cpu_count/2; else set N to the number of PDBs.
       b) You can start with R as 2, as in:  ..catcon.pl .. utlprp.sql '--p2'
       c) And you can adjust N and R as needed for your database and system.
       d) Note: cpu_count is an Oracle initialization parameter.

      This is an informational message on how you can run utlrp in a CDB.

      Recompiling invalid objects in a CDB can be done in multiple PDBs in
      parallel.

  ORACLE GENERATED FIXUP SCRIPT
  =============================
  All of the issues in database ORCL container ORCLPDB
  which are identified above as BEFORE UPGRADE "(AUTOFIXUP)" can be resolved by
  executing the following from within the container

    SQL>@/u01/app/oracle/cfgtoollogs/orcl/preupgrade/preupgrade_fixups.sql

=============
AFTER UPGRADE
=============

  REQUIRED ACTIONS
  ================
  None

  RECOMMENDED ACTIONS
  ===================
  6.  Upgrade the database time zone file using the DBMS_DST package.

      The database is using time zone file version 31 and the target 19 release
      ships with time zone file version 32.

      Oracle recommends upgrading to the desired (latest) version of the time
      zone file.  For more information, refer to "Upgrading the Time Zone File
      and Timestamp with Time Zone Data" in the 19 Oracle Database
      Globalization Support Guide.

  7.  (AUTOFIXUP) Gather dictionary statistics after the upgrade using the
      command:

        EXECUTE DBMS_STATS.GATHER_DICTIONARY_STATS;

      Oracle recommends gathering dictionary statistics after upgrade.

      Dictionary statistics provide essential information to the Oracle
      optimizer to help it find efficient SQL execution plans. After a database
      upgrade, statistics need to be re-gathered as there can now be tables
      that have significantly changed during the upgrade or new tables that do
      not have statistics gathered yet.

  8.  Gather statistics on fixed objects after the upgrade and when there is a
      representative workload on the system using the command:

        EXECUTE DBMS_STATS.GATHER_FIXED_OBJECTS_STATS;

      This recommendation is given for all preupgrade runs.

      Fixed object statistics provide essential information to the Oracle
      optimizer to help it find efficient SQL execution plans.  Those
      statistics are specific to the Oracle Database release that generates
      them, and can be stale upon database upgrade.

      For information on managing optimizer statistics, refer to the 18.0.0.0
      Oracle Database Upgrade Guide.

  ORACLE GENERATED FIXUP SCRIPT
  =============================
  All of the issues in database ORCL container ORCLPDB
  which are identified above as AFTER UPGRADE "(AUTOFIXUP)" can be resolved by
  executing the following from within the container

    SQL>@/u01/app/oracle/cfgtoollogs/orcl/preupgrade/postupgrade_fixups.sql


==================
PREUPGRADE SUMMARY
==================
  /u01/app/oracle/cfgtoollogs/orcl/preupgrade/preupgrade.log
  /u01/app/oracle/cfgtoollogs/orcl/preupgrade/preupgrade_fixups.sql
  /u01/app/oracle/cfgtoollogs/orcl/preupgrade/postupgrade_fixups.sql

Execute fixup scripts across the entire CDB:

Before upgrade:

1. Execute preupgrade fixups with the below command
$ORACLE_HOME/perl/bin/perl -I$ORACLE_HOME/perl/lib -I$ORACLE_HOME/rdbms/admin $ORACLE_HOME/rdbms/admin/catcon.pl -l /u01/app/oracle/cfgtoollogs/orcl/preupgrade/ -b preup_orcl /u01/app/oracle/cfgtoollogs/orcl/preupgrade/preupgrade_fixups.sql

2. Review logs under /u01/app/oracle/cfgtoollogs/orcl/preupgrade/

After the upgrade:

1. Execute postupgrade fixups with the below command
$ORACLE_HOME/perl/bin/perl -I$ORACLE_HOME/perl/lib -I$ORACLE_HOME/rdbms/admin $ORACLE_HOME/rdbms/admin/catcon.pl -l /u01/app/oracle/cfgtoollogs/orcl/preupgrade/ -b postup_orcl /u01/app/oracle/cfgtoollogs/orcl/preupgrade/postupgrade_fixups.sql

2. Review logs under /u01/app/oracle/cfgtoollogs/orcl/preupgrade/

Preupgrade complete: 2021-07-06T11:16:36

这个升级前检查非常重要和必要,因为其生成了整改操作,包括升级后操作的脚本。

执行整改操作:

$ORACLE_HOME/perl/bin/perl \\
    -I$ORACLE_HOME/perl/lib \\
    -I$ORACLE_HOME/rdbms/admin \\
    $ORACLE_HOME/rdbms/admin/catcon.pl \\
    -l /u01/app/oracle/cfgtoollogs/${ORACLE_SID}/preupgrade/ \\
    -b preup_${ORACLE_SID} \\
    /u01/app/oracle/cfgtoollogs/${ORACLE_SID}/preupgrade/preupgrade_fixups.sql

输出如下:

catcon::set_log_file_base_path: ALL catcon-related output will be written to [/u01/app/oracle/cfgtoollogs/orcl/preupgrade/preup_orcl_catcon_6772.lst]

catcon::set_log_file_base_path: catcon: See [/u01/app/oracle/cfgtoollogs/orcl/preupgrade/preup_orcl*.log] files for output generated by scripts

catcon::set_log_file_base_path: catcon: See [/u01/app/oracle/cfgtoollogs/orcl/preupgrade/preup_orcl_*.lst] files for spool files, if any

catcon.pl: completed successfully

重新编译无效对象:

$ORACLE_HOME/perl/bin/perl \\
    -I$ORACLE_HOME/perl/lib \\
    -I$ORACLE_HOME/rdbms/admin \\
    $ORACLE_HOME/rdbms/admin/catcon.pl \\
    -l /u01/app/oracle/cfgtoollogs/${ORACLE_SID}/preupgrade/ \\
    -b preup_${ORACLE_SID}_recompile \\
    -C 'PDB$SEED' \\
    $ORACLE_HOME/rdbms/admin/utlrp.sql

输出如下:

catcon::set_log_file_base_path: ALL catcon-related output will be written to [/u01/app/oracle/cfgtoollogs/orcl/preupgrade/preup_orcl_recompile_catcon_7441.lst]

catcon::set_log_file_base_path: catcon: See [/u01/app/oracle/cfgtoollogs/orcl/preupgrade/preup_orcl_recompile*.log] files for output generated by scripts

catcon::set_log_file_base_path: catcon: See [/u01/app/oracle/cfgtoollogs/orcl/preupgrade/preup_orcl_recompile_*.lst] files for spool files, if any

catcon.pl: completed successfully

升级数据库

首先关闭老数据库:

shutdown immediate

将老版本数据库中的部分文件拷贝到新版本的目录:

cp $ORACLE_HOME/dbs/orapw${ORACLE_SID} $ORACLE_BASE/product/19.0.0/dbhome_1/dbs/
cp $ORACLE_HOME/dbs/spfile${ORACLE_SID}.ora $ORACLE_BASE/product/19.0.0/dbhome_1/dbs/

下面

以上是关于Oracle数据库18c升级到19c的主要内容,如果未能解决你的问题,请参考以下文章

Oracle update to 19c using DBUA

18c 与 19c 上的 Oracle 编号问题

Oracle数据库安装配置详细教程汇总(含11g12c18c19c21c)

来自 19c 的 Oracle XE 18c impdp 转储

Oracle 12c 多租户家族(12c 18c 19c)如何在 PDB 中添加 HR 模式

Oracle 19c: RAC 集群技术的坚持与放弃(含PPT下载)