探索Oracle之数据库升级六 11.2.0.4.3 Upgrade12c(12.1.0.1)

简介: 探索Oracle之数据库升级六11.2.0.4.3 Upgrade12c(12.1.0.1) 一、前言:       Oracle 12c发布距今已经一年有余了,其最大亮点是一个可以插拔的数据库(PDB),这是在之前版本没有的;但是如果我们要将以前版本的数据库升级到12c来,那么也应顺其自然的将其变成一个pdb,那么我们的工作不仅包含了数据库软件的升级,同时也包含如何将一个NO-CDB的数据库plug to CDB none。

探索Oracle之数据库升级六
11.2.0.4.3 Upgrade12c(12.1.0.1)

一、前言:

      Oracle 12c发布距今已经一年有余了,其最大亮点是一个可以插拔的数据库(PDB),这是在之前版本没有的;但是如果我们要将以前版本的数据库升级到12c来,那么也应顺其自然的将其变成一个pdb,那么我们的工作不仅包含了数据库软件的升级,同时也包含如何将一个NO-CDB的数据库plug to CDB none

二、升级要求:

 

三、升级前准备:      

   3.1、查看数据库版本及补丁信息

SQL> select * from v$version;

BANNER
--------------------------------------------------------------------------------

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
CORE 11.2.0.4.0 Production
TNS for Linux: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 – Production

SQL> show parameter name;

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------

cell_offloadgroup_name string
db_file_name_convert string
db_name string woo
db_unique_name string woo
global_names boolean FALSE
instance_name string woo
lock_name_space string
log_file_name_convert string
processor_group_name string
service_names string woo

SQL> set pagesize 500
SQL> set line 300 
SQL> col comp_name format a40
SQL> col comp_name format a35
SQL> col version format a15
SQL> col status format a7
SQL> select comp_name,version,status from dba_registry;

COMP_NAME VERSION STATUS
----------------------------------- --------------- -------

Oracle Enterprise Manager 11.2.0.4.0 VALID
OWB 11.2.0.3.0 VALID
Oracle Application Express 3.2.1.00.12 VALID
OLAP Catalog 11.2.0.4.0 VALID
Spatial 11.2.0.4.0 VALID
Oracle Multimedia 11.2.0.4.0 VALID
Oracle XML Database 11.2.0.4.0 VALID
Oracle Text 11.2.0.4.0 VALID
Oracle Expression Filter 11.2.0.4.0 VALID
Oracle Rules Manager 11.2.0.4.0 VALID
Oracle Workspace Manager 11.2.0.4.0 VALID
Oracle Database Catalog Views 11.2.0.4.0 VALID
Oracle Database Packages and Types 11.2.0.4.0 VALID
JServer JAVA Virtual Machine 11.2.0.4.0 VALID
Oracle XDK 11.2.0.4.0 VALID
Oracle Database Java Packages 11.2.0.4.0 VALID
OLAP Analytic Workspace 11.2.0.4.0 VALID
Oracle OLAP API 11.2.0.4.0 VALID

18 rows selected.

[oracle@db01 OPatch]$ ./opatch lspatches
18522509;Database Patch Set Update : 11.2.0.4.3 (18522509) 


3.2、备份数据库

[oracle@db01 Phycal]$ pwd
 /DBBackup/Phycal
 [oracle@db01 Phycal]$ rman target / 

Recovery Manager: Release 11.2.0.4.0 - Production on Thu Nov 20 04:41:01 2014 
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved. 
connected to target database: WOO (DBID=4199532651) 

RMAN> run{
 2> allocate channel chan_name type disk;
 3> backup database format '/DBBackup/Phycal/WOO%U.bak' TAG before_upgrade;
 4> BACKUP CURRENT CONTROLFILE;
 5> } 

 using target database control file instead of recovery catalog
 allocated channel: chan_name
 channel chan_name: SID=28 device type=DISK 

 Starting backup at 20-NOV-14
 channel chan_name: starting full datafile backup set
 channel chan_name: specifying datafile(s) in backup set
 input datafile file number=00001 name=/DBData/woo/woo/system01.dbf
 input datafile file number=00002 name=/DBData/woo/woo/sysaux01.dbf
 input datafile file number=00003 name=/DBData/woo/woo/undotbs01.dbf
 input datafile file number=00004 name=/DBData/woo/woo/users01.dbf
 channel chan_name: starting piece 1 at 20-NOV-14
 channel chan_name: finished piece 1 at 20-NOV-14
 piece handle=/DBBackup/Phycal/WOO0apo2ar4_1_1.bak tag=BEFORE_UPGRADE comment=NONE
 channel chan_name: backup set complete, elapsed time: 00:01:25
 channel chan_name: starting full datafile backup set
 channel chan_name: specifying datafile(s) in backup set
 including current control file in backup set
 including current SPFILE in backup set
 channel chan_name: starting piece 1 at 20-NOV-14
 channel chan_name: finished piece 1 at 20-NOV-14
 piece handle=/DBBackup/Phycal/WOO0bpo2atp_1_1.bak tag=BEFORE_UPGRADE comment=NONE
 channel chan_name: backup set complete, elapsed time: 00:00:01
 Finished backup at 20-NOV-14 

 Starting backup at 20-NOV-14
 channel chan_name: starting full datafile backup set
 channel chan_name: specifying datafile(s) in backup set
 including current control file in backup set
 channel chan_name: starting piece 1 at 20-NOV-14
 channel chan_name: finished piece 1 at 20-NOV-14
 piece handle=/DBSoft/fast_recovery_area/WOO/backupset/2014_11_20/o1_mf_ncnnf_TAG20141120T044237_b6t05y5x_.bkp tag=TAG20141120T044237 comment=NONE
 channel chan_name: backup set complete, elapsed time: 00:00:01
 Finished backup at 20-NOV-14
 released channel: chan_name 

RMAN> list backupset; 


 List of Backup Sets
 =================== 


 BS Key  Type LV Size       Device Type Elapsed Time Completion Time
 ------- ---- -- ---------- ----------- ------------ ---------------
 9       Full    1.20G      DISK        00:01:24     20-NOV-14      
         BP Key: 9   Status: AVAILABLE  Compressed: NO  Tag: BEFORE_UPGRADE
         Piece Name: /DBBackup/Phycal/WOO0apo2ar4_1_1.bak
   List of Datafiles in backup set 9
   File LV Type Ckp SCN    Ckp Time  Name
   ---- -- ---- ---------- --------- ----
   1       Full 3242521    20-NOV-14 /DBData/woo/woo/system01.dbf
   2       Full 3242521    20-NOV-14 /DBData/woo/woo/sysaux01.dbf
   3       Full 3242521    20-NOV-14 /DBData/woo/woo/undotbs01.dbf
   4       Full 3242521    20-NOV-14 /DBData/woo/woo/users01.dbf 

 BS Key  Type LV Size       Device Type Elapsed Time Completion Time
 ------- ---- -- ---------- ----------- ------------ ---------------
 10      Full    9.64M      DISK        00:00:02     20-NOV-14      
         BP Key: 10   Status: AVAILABLE  Compressed: NO  Tag: BEFORE_UPGRADE
         Piece Name: /DBBackup/Phycal/WOO0bpo2atp_1_1.bak
   SPFILE Included: Modification time: 12-NOV-14
   SPFILE db_unique_name: WOO
   Control File Included: Ckp SCN: 3242657      Ckp time: 20-NOV-14 

 BS Key  Type LV Size       Device Type Elapsed Time Completion Time
 ------- ---- -- ---------- ----------- ------------ ---------------
 11      Full    9.61M      DISK        00:00:01     20-NOV-14      
         BP Key: 11   Status: AVAILABLE  Compressed: NO  Tag: TAG20141120T044237
         Piece Name: /DBSoft/fast_recovery_area/WOO/backupset/2014_11_20/o1_mf_ncnnf_TAG20141120T044237_b6t05y5x_.bkp
   Control File Included: Ckp SCN: 3242671      Ckp time: 20-NOV-14 


四、执行预升级脚本:
4.1
根据Metalink ID:1503653 step 3中提到的到Metalink ID:556610.1下载预升级脚本preupgrd.sql检查是否满足升级条件。

[oracle@db01 ~]$ sqlplus / as sysdba @preupgrd.sql
 
SQL*Plus: Release 11.2.0.4.0 Production on Thu Nov 20 05:18:26 2014
Copyright (c) 1982, 2013, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

Loading Pre-Upgrade Package...
Executing Pre-Upgrade Checks...
Pre-Upgrade Checks Complete.
      ************************************************************

Results of the checks are located at:
 /DBSoft/cfgtoollogs/woo/preupgrade/preupgrade.log

Pre-Upgrade Fixup Script (run in source database environment):
 /DBSoft/cfgtoollogs/woo/preupgrade/preupgrade_fixups.sql

Post-Upgrade Fixup Script (run shortly after upgrade):
 /DBSoft/cfgtoollogs/woo/preupgrade/postupgrade_fixups.sql

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

         Fixup scripts must be reviewed prior to being executed.

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

      ************************************************************
                   ====>> USER ACTION REQUIRED <<====
      ************************************************************

 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

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

SQL> 


       在这里已经把需要修改的相关操作封装到了preupgrade_fixups.sql脚本中,执行该脚本按照提示修复存在的问题即可。

 

4.2 主要需要修复如下问题: 

       ALTER SYSTEM SET PROCESSES=300 SCOPE=SPFILE;   

       @$ORACLE_HOME/rdbms/admin/emremove.sql   

       @$ORACLE_HOME/olap/admin/catnoamd.sql   

        EXECUTE dbms_stats.gather_dictionary_stats;

 

4.3 执行dbupgdiag.sql收集升级前信息   

    如果有异常参考Metalink ID:556610.1进行修改。

[oracle@db01 ~]$ ll dbupgdiag.sql 
-rwxr-xr-x 1 oracle oinstall 24140 Nov 20 04:52 dbupgdiag.sql

[oracle@db01 ~]$ sqlplus / as sysdba @dbupgdiag.sql

SQL*Plus: Release 11.2.0.4.0 Production on Thu Nov 20 05:04:47 2014
Copyright (c) 1982, 2013, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

Enter location for Spooled output:

Enter value for 1: 
SP2-0137: DEFINE requires a value following equal sign

20_Nov_2014_0504 .log

woo_
Enter value for log_path: /home/oracle/diag/
SP2-0606: Cannot create SPOOL file \"/home/oracle/woo_upgrade_diag.log/db_upg_diag_woo_20_Nov_2014_0504.log\"


                          *** Start of LogFile ***

  Oracle Database Upgrade Diagnostic Utility 11-20-2014 05:05:16

===============
Hostname
===============

db01

===============
Database Name
===============

WOO

===============
Database Uptime
===============

00:34 20-NOV-14

=================
Database Wordsize
=================

This is a 64-bit database

================
Software Version
================

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
CORE 11.2.0.4.0 Production
TNS for Linux: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production

=============
Compatibility
=============

Compatibility is set as 11.2.0.0.0

================
Archive Log Mode
================

Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 151
Next log sequence to archive 153
Current log sequence 153

================
Auditing Check
================

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
audit_file_dest string /DBSoft/admin/woo/adump
audit_sys_operations boolean FALSE
audit_syslog_level string
audit_trail string DB

================
Cluster Check
================

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
cluster_database boolean FALSE
cluster_database_instances integer 1

DOC>################################################################
DOC>
DOC> If CLUSTER_DATABASE is set to TRUE, change it to FALSE before
DOC> upgrading the database
DOC>
DOC>################################################################
DOC>#

===========================================
Tablespace and the owner of the aud$ table
===========================================

OWNER TABLESPACE_NAME
------------ ------------------------------
SYS SYSTEM

============================================================================
count of records in the sys.aud$ table where dbid is null- Standard Auditing
============================================================================

         0

============================================================================================
count of records in the system.aud$ when dbid is null, Std Auditing with OLS or DV installed
============================================================================================

select count(*) from system.aud$ where dbid is null
                           *
ERROR at line 1:
ORA-00942: table or view does not exist

=============================================================================
count of records in the sys.fga_log$ when dbid is null, Fine Grained Auditing
=============================================================================

         0

==========================================
Oracle Label Security is installed or not
==========================================

Oracle Label Security is NOT installed at database level

================
Number of AQ Records in Message Queue Tables
================

SYS - ALERT_QT - 58
SYS - AQ$_MEM_MC - 0
SYS - AQ_EVENT_TABLE - 0
SYS - AQ_PROP_TABLE - 0
SYS - KUPC$DATAPUMP_QUETAB - 0
SYS - SCHEDULER$_EVENT_QTAB - 0
SYS - SCHEDULER$_REMDB_JOBQTAB - 0
SYS - SCHEDULER_FILEWATCHER_QT - 0
SYS - SYS$SERVICE_METRICS_TAB - 0
SYSMAN - MGMT_LOADER_QTABLE - 0
SYSMAN - MGMT_NOTIFY_INPUT_QTABLE - 0
SYSMAN - MGMT_NOTIFY_QTABLE - 0
SYSMAN - MGMT_PAF_MSG_QTABLE_1 - 0
SYSMAN - MGMT_PAF_MSG_QTABLE_2 - 0
SYSMAN - MGMT_TASK_QTABLE - 28
SYSTEM - DEF$_AQCALL - 0
SYSTEM - DEF$_AQERROR - 0
WMSYS - WM$EVENT_QUEUE_TABLE - 0

================
Time Zone version
================
        14

================
Local Listener
================



================
Default and Temporary Tablespaces By User
================

USERNAME TEMPORARY_TABLESPACE DEFAULT_TABLESPACE
---------------------------- ---------------------- ----------------------
MGMT_VIEW TEMP SYSTEM
SYS TEMP SYSTEM
SYSTEM TEMP SYSTEM
DBSNMP TEMP SYSAUX
SYSMAN TEMP SYSAUX
OUTLN TEMP SYSTEM
FLOWS_FILES TEMP SYSAUX
MDSYS TEMP SYSAUX
ORDSYS TEMP SYSAUX
EXFSYS TEMP SYSAUX
WMSYS TEMP SYSAUX
APPQOSSYS TEMP SYSAUX
APEX_030200 TEMP SYSAUX
OWBSYS_AUDIT TEMP SYSAUX
ORDDATA TEMP SYSAUX
CTXSYS TEMP SYSAUX
ANONYMOUS TEMP SYSAUX
XDB TEMP SYSAUX
ORDPLUGINS TEMP SYSAUX
OWBSYS TEMP SYSAUX
SI_INFORMTN_SCHEMA TEMP SYSAUX
OLAPSYS TEMP SYSAUX
SCOTT TEMP USERS
ORACLE_OCM TEMP USERS
XS$NULL TEMP USERS
MDDATA TEMP USERS
DIP TEMP USERS
APEX_PUBLIC_USER TEMP USERS
SPATIAL_CSW_ADMIN_USR TEMP USERS
SPATIAL_WFS_ADMIN_USR TEMP USERS

================
Component Status
================

Comp ID Component Status Version Org_Version Prv_Version
------- ---------------------------------- --------- -------------- -------------- --------------

AMD OLAP Catalog VALID 11.2.0.4.0 11.2.0.3.0 11.2.0.3.0
APEX Oracle Application Express VALID 3.2.1.00.12
APS OLAP Analytic Workspace VALID 11.2.0.4.0 11.2.0.3.0 11.2.0.3.0
CATALOG Oracle Database Catalog Views VALID 11.2.0.4.0 11.2.0.3.0 11.2.0.3.0
CATJAVA Oracle Database Java Packages VALID 11.2.0.4.0 11.2.0.3.0 11.2.0.3.0
CATPROC Oracle Database Packages and Types VALID 11.2.0.4.0 11.2.0.3.0 11.2.0.3.0
CONTEXT Oracle Text VALID 11.2.0.4.0 11.2.0.3.0 11.2.0.3.0
EM Oracle Enterprise Manager VALID 11.2.0.4.0
EXF Oracle Expression Filter VALID 11.2.0.4.0 11.2.0.3.0 11.2.0.3.0
JAVAVM JServer JAVA Virtual Machine VALID 11.2.0.4.0 11.2.0.3.0 11.2.0.3.0
ORDIM Oracle Multimedia VALID 11.2.0.4.0 11.2.0.3.0 11.2.0.3.0
OWB OWB VALID 11.2.0.3.0
OWM Oracle Workspace Manager VALID 11.2.0.4.0 11.2.0.3.0
RUL Oracle Rules Manager VALID 11.2.0.4.0 11.2.0.3.0 11.2.0.3.0
SDO Spatial VALID 11.2.0.4.0 11.2.0.3.0 11.2.0.3.0
XDB Oracle XML Database VALID 11.2.0.4.0 11.2.0.3.0 11.2.0.3.0
XML Oracle XDK VALID 11.2.0.4.0 11.2.0.3.0 11.2.0.3.0
XOQ Oracle OLAP API VALID 11.2.0.4.0 11.2.0.3.0 11.2.0.3.0

======================================================
List of Invalid Database Objects Owned by SYS / SYSTEM
======================================================


Number of Invalid Objects
------------------------------------------------------------------
There are no Invalid Objects

DOC>################################################################
DOC>
DOC> If there are no Invalid objects below will result in zero rows.
DOC>
DOC>################################################################
DOC>#

no rows selected

================================
List of Invalid Database Objects
================================

Number of Invalid Objects
------------------------------------------------------------------
There are no Invalid Objects

DOC>################################################################
DOC>
DOC> If there are no Invalid objects below will result in zero rows.
DOC>
DOC>################################################################
DOC>#

no rows selected

======================================================
Count of Invalids by Schema
======================================================



==============================================================
Identifying whether a database was created as 32-bit or 64-bit
==============================================================

DOC>###########################################################################
DOC>
DOC> Result referencing the string \'B023\' ==> Database was created as 32-bit
DOC> Result referencing the string \'B047\' ==> Database was created as 64-bit
DOC> When String results in \'B023\' and when upgrading database to 10.2.0.3.0
DOC> (64-bit) , For known issue refer below articles
DOC>
DOC> Note 412271.1 ORA-600 [22635] and ORA-600 [KOKEIIX1] Reported While
DOC> Upgrading Or Patching Databases To 10.2.0.3
DOC> Note 579523.1 ORA-600 [22635], ORA-600 [KOKEIIX1], ORA-7445 [KOPESIZ] and
DOC> OCI-21500 [KOXSIHREAD1] Reported While Upgrading To 11.1.0.6
DOC>
DOC>###########################################################################
DOC>#

Metadata Initial DB Creation Info
-------- -----------------------------------
B047 Database was created as 64-bit

===================================================
Number of Duplicate Objects Owned by SYS and SYSTEM
===================================================

Counting duplicate objects ....

  COUNT(1)
----------
         0

=========================================
Duplicate Objects Owned by SYS and SYSTEM
=========================================

Querying duplicate objects ....

DOC>
DOC>################################################################################
DOC>
DOC> If any objects found please follow below article.
DOC> Note 1030426.6 How to Clean Up Duplicate Objects Owned by SYS and SYSTEM schema
DOC> Read the Exceptions carefully before taking actions.
DOC>
DOC>################################################################################
DOC>#

========================
Password protected roles
========================

DOC>
DOC>################################################################################
DOC>
DOC> In version 11.2 password protected roles are no longer enabled by default so if
DOC> an application relies on such roles being enabled by default and no action is
DOC> performed to allow the user to enter the password with the set role command, it
DOC> is recommended to remove the password from those roles (to allow for existing
DOC> privileges to remain available). For more information see:
DOC>
DOC> Note 745407.1 : What Roles Can Be Set as Default for a User?
DOC>
DOC>################################################################################
DOC>#

Querying for password protected roles ....


Password protected Role Assigned by default to user
------------------------------ ------------------------------
OWB$CLIENT OWBSYS

================
JVM Verification
================


================================================
Checking Existence of Java-Based Users and Roles
================================================


DOC>
DOC>################################################################################
DOC>
DOC> There should not be any Java Based users for database version 9.0.1 and above.
DOC> If any users found, it is faulty JVM.
DOC>
DOC>################################################################################
DOC>#


User Existence
---------------------------
No Java Based Users

DOC>
DOC>###############################################################
DOC>
DOC> Healthy JVM Should contain Six Roles.
DOC> If there are more or less than six role, JVM is inconsistent.
DOC>
DOC>###############################################################
DOC>#


Role
------------------------------
There are 6 JAVA related roles
Roles

ROLE
------------------------------
JAVA_DEPLOY
JAVAUSERPRIV
JAVAIDPRIV
JAVASYSPRIV
JAVADEBUGPRIV
JAVA_ADMIN

=========================================
List of Invalid Java Objects owned by SYS
=========================================

There are no SYS owned invalid JAVA objects

DOC>
DOC>#################################################################
DOC>
DOC> Check the status of the main JVM interface packages DBMS_JAVA
DOC> and INITJVMAUX and make sure it is VALID.
DOC>
DOC> If there are no Invalid objects below will result in zero rows.
DOC>
DOC>#################################################################
DOC>#

no rows selected

DOC>
DOC>#################################################################
DOC>
DOC> If the JAVAVM component is not installed in the database (for
DOC> example, after creating the database with custom scripts), the
DOC> next query will report the following error:
DOC>
DOC> select dbms_java.longname(\'foo\') \"JAVAVM TESTING\" from dual
DOC> *
DOC> ERROR at line 1:
DOC> ORA-00904: \"DBMS_JAVA\".\"LONGNAME\": invalid identifier
DOC>
DOC> If the JAVAVM component is installed, the query should succeed
DOC> with \'foo\' as result.
DOC>
DOC>#################################################################
DOC>#

JAVAVM TESTING
---------------
foo

===================================
Oracle Multimedia/InterMedia status
===================================

.
Oracle Multimedia/interMedia is installed and listed with the following version: 11.2.0.4.0 and status: VALID
.
Checking for installed Database Schemas...
ORDSYS user exists.
ORDPLUGINS user exists.
MDSYS user exists.
SI_INFORMTN_SCHEMA user exists.
ORDDATA user exists.
.
Checking for Prerequisite Components...
JAVAVM installed and listed as valid
XDK installed and listed as valid
XDB installed and listed as valid
Validating Oracle Multimedia/interMedia...(no output if component status is valid)

PL/SQL procedure successfully completed.

                            *** End of LogFile ***

							
not spooling currently

Enter value for log_path: /home/oracle/diag/

Upload db_upg_diag_woo_20_Nov_2014_0504.log from \"/home/oracle/diag\" directory

SQL> exit 


 4.4 升级前检查无效对象:

[oracle@db01 ~]$ cd $ORACLE_HOME/rdbms/admin 
[oracle@db01 admin]$ sqlplus / as sysdba @utlrp.sql

SQL*Plus: Release 11.2.0.4.0 Production on Thu Nov 20 06:13:55 2014
Copyright (c) 1982, 2013, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_BGN 2014-11-20 06:13:56

DOC> The following PL/SQL block invokes UTL_RECOMP to recompile invalid
DOC> objects in the database. Recompilation time is proportional to the
DOC> number of invalid objects in the database, so this command may take
DOC> a long time to execute on a database with a large number of invalid
DOC> objects.
DOC>
DOC> Use the following queries to track recompilation progress:
DOC>
DOC> 1. Query returning the number of invalid objects remaining. This
DOC> number should decrease with time.
DOC> SELECT COUNT(*) FROM obj$ WHERE status IN (4, 5, 6);
DOC>
DOC> 2. Query returning the number of objects compiled so far. This number
DOC> should increase with time.
DOC> SELECT COUNT(*) FROM UTL_RECOMP_COMPILED;
DOC>
DOC> This script automatically chooses serial or parallel recompilation
DOC> based on the number of CPUs available (parameter cpu_count) multiplied
DOC> by the number of threads per CPU (parameter parallel_threads_per_cpu).
DOC> On RAC, this number is added across all RAC nodes.
DOC>
DOC> UTL_RECOMP uses DBMS_SCHEDULER to create jobs for parallel
DOC> recompilation. Jobs are created without instance affinity so that they
DOC> can migrate across RAC nodes. Use the following queries to verify
DOC> whether UTL_RECOMP jobs are being created and run correctly:
DOC>
DOC> 1. Query showing jobs created by UTL_RECOMP
DOC> SELECT job_name FROM dba_scheduler_jobs
DOC> WHERE job_name like \'UTL_RECOMP_SLAVE_%\';
DOC>
DOC> 2. Query showing UTL_RECOMP jobs that are running
DOC> SELECT job_name FROM dba_scheduler_running_jobs
DOC> WHERE job_name like \'UTL_RECOMP_SLAVE_%\';
DOC>#

PL/SQL procedure successfully completed.

TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_END 2014-11-20 06:14:06

DOC> The following query reports the number of objects that have compiled
DOC> with errors.
DOC>
DOC> If the number is higher than expected, please examine the error
DOC> messages reported with each object (using SHOW ERRORS) to see if they
DOC> point to system misconfiguration or resource constraints that must be
DOC> fixed before attempting to recompile these objects.
DOC>#

OBJECTS WITH ERRORS
-------------------
                  0

DOC> The following query reports the number of errors caught during
DOC> recompilation. If this number is non-zero, please query the error
DOC> messages in the table UTL_RECOMP_ERRORS to see if any of these errors
DOC> are due to misconfiguration or resource constraints that must be
DOC> fixed before objects can compile successfully.
DOC>#

ERRORS DURING RECOMPILATION
---------------------------
                          0

Function created.

PL/SQL procedure successfully completed.

Function dropped.

PL/SQL procedure successfully completed.

SQL> 

五、开始安装 ORACLE 12C 软件

   5.1 创建12c安装所需目录

[oracle@db01 DBSoft]$ mkdir -p /DBSoft/Product/12.1.0/db_1
 
[oracle@db01 DBSoft]$ chown -R oracle:oinstall /DBSoft/Product/12.1.0
[oracle@db01 DBSoft]$ chmod -R 755 /DBSoft/Product/12.1.0
[oracle@db01 DBSoft]$ cd /DBSoft/Product/12.1.0 


     5.2 修改用户环境变量:

[oracle@db01 Product]$ vi ~/.bash_profile
 
export PATH
export EDITOR=vi
export ORACLE_SID=woo
export ORACLE_BASE=/DBSoft
export ORACLE_HOME=$ORACLE_BASE/Product/12.1.0/db_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export PATH=$ORACLE_HOME/bin:$PATH
umask 022 


      5.3 解压缩软件:

[oracle@db01 ~]$ unzip linuxamd64_12c_database_1of2.zip
[oracle@db01 ~]$ unzip linuxamd64_12c_database_2of2.zip


 六、开始安装12c软件:
     6.1 进入解压目录执行./runInstaller 开启12c安装进程

   6.2 直接点击Next,下一步开始安装

    6.3 选择skip software updates,点击Next

     6.4 选择最后一个选项 Upgrade an existing database,点击Next

      6.5 选择所有的语言,点击Next

      6.6 选择第一个选项 EntePrise Edition (6.4GB)

     6.7 指定Oracle 12c的安装目录,会从环境变量中自动读取,点击Next

      6.8 安装Oracle的所属组和用户,无误后点击Next

    6.9 检查Oracle 12c的安装信息,无误后点击Install 开始安装

    6.10 开始安装,这个过程等待约15分钟

     6.11 弹出提示执行root.sh脚本

     6.12 开启新窗口,通过root用户登录,执行root.sh脚本

     6.13 执行完root.sh脚本后,点击完成,自动弹出监听配置,开始配置监听

      6.14 配置监听名称,默认即可

    6.15 选择监听可用的协议,通常配置TCP就可以了

     6.16 配置端口,使用默认的1521,点击即可

     6.17 问你是否还需要配置其他监听,选择No,点击Next即可

     6.18 这步提示是否需要创建一个用于客户端连接的服务,选择No,点击Next即可

     6.19 点击Finish,完成网络的配置

     6.20 现在开始对数据库进行升级(DBUA),选择第一个选项Upgrade Oracle Database,选择Next

     6.21 选择需要升级的数据库,点击Next

     6.22 执行升级检查,选择fix,后点击Next

     6.23 配置升级选项,所有的都选上,设置和CPU数量相同的并行度,点击Next

     6.24 选择EM配置,点击Next

     6.25 升级是否移动数据文件,这里不需要移动,点击Next

    6.26 选择需要升级的监听,点击Next

   6.27 数据恢复选项,升级前是否对数据库进行一次备份操作,选择备份,并指定路径,点击Next

     6.28 检查下Summary,点击Finish开始升级

     6.29 现在开始执行升级操作

     6.30 至此升级已经完成,耗时至少四个小时以上,务必预留好足够多的升级时间。

    6.31 升级已经完成,点击Next

     6.32 点击Close关闭升级窗口

 

        至此11g upgrade 12c已经接近尾声了,后续还需要做一些升级后的检查。

 

七、执行升级后的检查

    7.1 Oracle 12c版本及组件状态的检查

 

 

SQL> select banner from v$version;
 
BANNER
--------------------------------------------------------------------------------
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
PL/SQL Release 12.1.0.1.0 - Production
CORE 12.1.0.1.0 Production
TNS for Linux: Version 12.1.0.1.0 - Production
NLSRTL Version 12.1.0.1.0 – Production

SQL> set pagesize 500
SQL> set line 300 
SQL> col comp_name format a40
SQL> col comp_name format a35
SQL> col version format a15
SQL> col status format a7
SQL> select comp_name,version,status from dba_registry;

COMP_NAME VERSION STATUS
----------------------------------- --------------- -------
Oracle Application Express 4.2.0.00.27 VALID
OWB 11.2.0.3.0 VALID
OLAP Catalog 11.2.0.4.0 OPTION
                                                    OFF
Spatial 12.1.0.1.0 VALID
Oracle Multimedia 12.1.0.1.0 VALID
Oracle XML Database 12.1.0.1.0 VALID
Oracle Text 12.1.0.1.0 VALID
Oracle Workspace Manager 12.1.0.1.0 VALID
Oracle Database Catalog Views 12.1.0.1.0 VALID
Oracle Database Packages and Types 12.1.0.1.0 VALID
JServer JAVA Virtual Machine 12.1.0.1.0 VALID
Oracle XDK 12.1.0.1.0 VALID
Oracle Database Java Packages 12.1.0.1.0 VALID
OLAP Analytic Workspace 12.1.0.1.0 VALID
Oracle OLAP API 12.1.0.1.0 VALID

15 rows selected. 

 

     7.2  从上面我们可以看到有些组件的状态是不对的,这是老版本的组件,不能直接通过升级上SQL进行删除

SQL> @$ORACLE_HOME/rdbms/admin/emremove.sql
SQL> @$ORACLE_HOME/olap/admin/catnoamd.sql
SQL> EXECUTE dbms_stats.gather_dictionary_stats; 


    7.3 再次查看就没有问题了:

SQL> select comp_name,version,status from dba_registry;
 
COMP_NAME VERSION STATUS
----------------------------------- --------------- -------
Oracle Application Express 4.2.0.00.27 VALID
OWB 11.2.0.3.0 VALID
Spatial 12.1.0.1.0 VALID
Oracle Multimedia 12.1.0.1.0 VALID
Oracle XML Database 12.1.0.1.0 VALID
Oracle Text 12.1.0.1.0 VALID
Oracle Workspace Manager 12.1.0.1.0 VALID
Oracle Database Catalog Views 12.1.0.1.0 VALID
Oracle Database Packages and Types 12.1.0.1.0 VALID
JServer JAVA Virtual Machine 12.1.0.1.0 VALID
Oracle XDK 12.1.0.1.0 VALID
Oracle Database Java Packages 12.1.0.1.0 VALID
OLAP Analytic Workspace 12.1.0.1.0 VALID
Oracle OLAP API 12.1.0.1.0 VALID

14 rows selected. 


   7.4  /etc/oratab信息对比

---升级前
[root@db01 ~]# grep DBSoft /etc/oratab 
woo:/DBSoft/Product/11.2.0/db_1:N

---升级后
[root@db01 ~]# grep DBSoft /etc/oratab 
woo:/DBSoft/Product/12.1.0/db_1:N

注意:这部分不需要我们手工去修改/etc/oratab记录,执行升级会自动完成修改。 


    7.5 升级后执行postupgrade_fixups.sql检查

SQL> @/DBSoft/cfgtoollogs/woo/preupgrade/postupgrade_fixups.sql
 
Post Upgrade Fixup Script Generated on 2014-11-20 05:18:29 Version: 12.1.0.1 Build: 007
Beginning Post-Upgrade Fixups...

PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.

**********************************************************************
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.1.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.
**********************************************************************

PL/SQL procedure successfully completed.

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

PL/SQL procedure successfully completed.

                        *****************************************
                        ******** 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 ^^^

PL/SQL procedure successfully completed.

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

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

 1 fixup routine generated an INFORMATIONAL message that should be reviewed.


PL/SQL procedure successfully completed.

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

PL/SQL procedure successfully completed.

SQL>


    7.6 检查DST
     从升级后的检查结果来看,DST目前是18,说明不需要人工处理了,如果不是需要手工来处理,参考Metalink ID: 977512.1 或者参考Metalink ID 1585343.1 

SQL> r
  1 SELECT PROPERTY_NAME, SUBSTR(property_value, 1, 30) value
  2 FROM DATABASE_PROPERTIES
  3 WHERE PROPERTY_NAME LIKE \'DST_%\'
  4* ORDER BY PROPERTY_NAME

PROPERTY_NAME VALUE
---------------------------------------- ------------------------------------------------------------------------------------------------------------------------
DST_PRIMARY_TT_VERSION 18
DST_SECONDARY_TT_VERSION 0
DST_UPGRADE_STATE NONE

SQL> select * from v$timezone_file;

FILENAME VERSION CON_ID
-------------------- ---------- ----------
timezlrg_18.dat 18 0

SQL> select TZ_VERSION from registry$database;

TZ_VERSION
----------
        18 

     7.7  字符集检查

检查国家字符集,如果是以下字符集则不需要做操作:

如果返回结果是 UTF8或者 AL16UTF16,那么什么都不需要做了。
如果返回结果不是 UTF8或者 AL16UTF16,那么请参考下面的文档:   

Note 276914.1 

ID 276914.1)

<strong>SQL> select value from nls_database_parameters where parameter=\'NLS_NCHAR_CHARACTERSET\';
 
VALUE
--------------------------------------------------------------------------------
AL16UTF16 
</strong>

      7.8 修改参数文件中版本号

SQL> show parameter compatible
 
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
compatible string 11.2.0.0.0
noncdb_compatible boolean FALSE

SQL> alter system set compatible = \'12.1.0.1.0\' scope=spfile;

System altered.

SQL> startup force;

ORACLE instance started.

Total System Global Area 2772574208 bytes
Fixed Size 2292240 bytes
Variable Size 2533361136 bytes
Database Buffers 218103808 bytes
Redo Buffers 18817024 bytes

Database mounted.
Database opened.

SQL> 
SQL> show parameter compatible

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
compatible string 12.1.0.1.0
noncdb_compatible boolean FALSE

SQL> 


     至此,经过漫长而辛苦的升级,我们已经将11.2.0.4顺利升级到了12.1.0.1,整个升级过程虽然有点长,但还是比较顺利的。故需再生产环境中升级请大家务必预留好可用于升级的时间窗口,升级时间确实是非常的长。


 

相关实践学习
数据库实验室挑战任务-初级任务
本场景介绍如何开通属于你的免费云数据库,在RDS-MySQL中完成对学生成绩的详情查询,执行指定类型SQL。
阿里云云原生数据仓库AnalyticDB MySQL版 使用教程
云原生数据仓库AnalyticDB MySQL版是一种支持高并发低延时查询的新一代云原生数据仓库,高度兼容MySQL协议以及SQL:92、SQL:99、SQL:2003标准,可以对海量数据进行即时的多维分析透视和业务探索,快速构建企业云上数据仓库。 了解产品 https://www.aliyun.com/product/ApsaraDB/ads
目录
相关文章
|
4天前
|
DataWorks Oracle 关系型数据库
DataWorks操作报错合集之尝试从Oracle数据库同步数据到TDSQL的PG版本,并遇到了与RAW字段相关的语法错误,该怎么处理
DataWorks是阿里云提供的一站式大数据开发与治理平台,支持数据集成、数据开发、数据服务、数据质量管理、数据安全管理等全流程数据处理。在使用DataWorks过程中,可能会遇到各种操作报错。以下是一些常见的报错情况及其可能的原因和解决方法。
17 0
|
11天前
|
存储 Oracle 网络协议
Oracle 11gR2学习之二(创建数据库及OEM管理篇)
Oracle 11gR2学习之二(创建数据库及OEM管理篇)
|
15天前
|
Oracle 网络协议 关系型数据库
异地使用PLSQL远程连接访问Oracle数据库【内网穿透】
异地使用PLSQL远程连接访问Oracle数据库【内网穿透】
|
15天前
|
SQL Oracle 安全
Oracle数据库中的事务和锁
【4月更文挑战第19天】Oracle数据库的事务和锁是确保数据完整性和并发控制的核心机制。事务遵循ACID原则,保证操作的原子性、一致性、隔离性和持久性。通过COMMIT或ROLLBACK来管理事务更改。锁包括共享锁(读)、排他锁(写)、行级锁和表级锁,用于控制并发访问。自动锁机制在DML操作时生效,防止数据冲突。事务和锁共同维护数据库的稳定和安全。
|
15天前
|
存储 Oracle 关系型数据库
Oracle RAC:数据库集群的舞动乐章
【4月更文挑战第19天】Oracle RAC是Oracle提供的高可用性数据库解决方案,允许多个实例共享同一数据库,确保业务连续性和数据完整性。通过集群件和全局缓存服务实现服务器间的协调和通信。RAC提供高可用性,通过故障转移应对故障,同时提升性能,多个实例并行处理请求。作为数据管理员,理解RAC的架构和管理至关重要,以发挥其在数据管理中的最大价值。
|
15天前
|
监控 Oracle 安全
Oracle用户事件触发器:数据库世界的“福尔摩斯”
【4月更文挑战第19天】Oracle用户事件触发器是数据库中的监控机制,类似于“福尔摩斯”,在用户执行特定操作时自动触发。它们关注用户行为而非数据变化,可用于权限检查、安全监控、性能优化等。通过DDL语句创建,需注意逻辑清晰、条件合适及定期更新,以适应数据库变化和业务发展。掌握其使用能有效保障数据安全与稳定。
|
15天前
|
SQL 存储 Oracle
Oracle语句级触发器:数据库的“隐形哨兵”
【4月更文挑战第19天】Oracle语句级触发器是数据库中的自动执行程序,当特定事件(如INSERT、UPDATE、DELETE)发生时,会针对整个SQL语句触发。以新员工入职记录日志为例,创建语句级触发器可自动在操作后向日志表插入信息,减少手动工作并提高性能。虽然无法处理行级详细信息,但在处理大量数据时,相比行级触发器更高效。掌握触发器使用能提升数据管理效率和安全性。
|
15天前
|
Oracle 关系型数据库 数据库
Oracle示例模式Scott:数据库世界的“小导游”
【4月更文挑战第19天】Oracle的Scott模式是数据库学习的向导,提供操作性的环境,包含表(如EMP和DEPT)、视图和索引。通过它,学习者能掌握基本语法和操作,如创建表、插入数据和编写查询。它是通往Oracle数据库世界的起点,帮助新手奠定基础,开启数据库探索之旅。
|
15天前
|
存储 Oracle 关系型数据库
Oracle的模式与模式对象:数据库的“城市规划师”
【4月更文挑战第19天】在Oracle数据库中,模式是用户对象的集合,相当于数据库的城市规划,包含表、视图、索引等模式对象。模式对象是数据存储结构,如表用于存储数据,视图提供不同查看角度,索引加速数据定位。良好的模式与模式对象设计关乎数据效率、安全和稳定性。规划时需考虑业务需求、性能、安全和可扩展性,以构建高效数据库环境,支持企业业务发展。
|
15天前
|
SQL Oracle 关系型数据库
Oracle SQL*Plus的SPOOL命令:数据库世界的“录像机”
【4月更文挑战第19天】`SQL*Plus`的`SPOOL`命令是Oracle数据库中的“录像机”,能记录所有操作和输出。它在用户开始“SPOOL ON”时启动,记录SQL查询、输出、错误信息等。完成后,“SPOOL OFF”停止记录并生成日志文件,便于回顾和检查。日志文件可自定义保存位置和命名,支持多文件录制,方便分类管理。无论数据分析、SQL脚本编写还是日常维护,`SPOOL`都是强大的工具,值得一试!

推荐镜像

更多