oracle 12c 12.2.0.1,Oracle-Database-12c-12.2.0.1升级实战

1前言

The latest generation of the world's most popular database, Oracle Database 12c Release 2 (12.2), is now available everywhere - in the Cloud, with Oracle Cloud at Customer,

and on-premises.  This latest release provides organizations of all sizes with access to the world’s fastest, most scalable and reliable database technology in a cost-effective,

hybrid Cloud environment. 12.2 also includes a series of innovations that helps customers easily transform to the Cloud while preserving their investments in Oracle Database

technologies, skills and resources.

最新一代世界上最流行的数据库,Oracle数据库12 ?第2版(12.2),在云中现已无处不在,与Oracle  云在客户和内部部署。  此最新版本为各种规模的组织提供了在经济高效的混

合云环境中访问世界上最快,最可扩展和可靠的数据库技术。12.2还包括一系列创新,帮助客户轻松转换到云 ,同时保留对Oracle数据库技术,技能和资源的投资。

Oracle 12.2.0.1于2017年3月初提供下载,本文介绍11.2.0.4升级12.2.0.1实战操作过程.

2升级要求

oracle 12c 12.2.0.1,Oracle-Database-12c-12.2.0.1升级实战_第1张图片

oracle 12c 12.2.0.1,Oracle-Database-12c-12.2.0.1升级实战_第2张图片

3 升级计划

升级前:Oracle 11.2.0.4à升级后:Oracle 12.2.0.1

4升级前准备

4.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

CORE11.2.0.4.0Production

TNS for Linux: Version 11.2.0.4.0 - Production

NLSRTL Version 11.2.0.4.0 – Production

SQL> set pagesize 500

set line 300

col comp_name format a40

col comp_name format a35

col version format a15

col status format a7

select comp_name,version,status from dba_registry;SQL>

COMP_NAME    VERSION    STATUS

----------------------------------- --------------- -------

OWB    11.2.0.4.0    VALID

Oracle Application Express    3.2.1.00.12     VALID

Oracle Enterprise Manager    11.2.0.4.0    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.

?

4.2升级前检查

1、Gathering Optimizer Statistics to Decrease Oracle Database Downtime

? Non-CDB Oracle Database: Oracle recommends that you use the

DBMS_STATS.GATHER_DICTIONARY_STATS procedure to gather these statistics.

For example, enter the following SQL statement:

SQL> EXEC DBMS_STATS.GATHER_DICTIONARY_STATS;

2、Verifying Materialized View Refreshes are Complete Before Upgrade

SQL> SELECT o.name FROM sys.obj$ o, sys.user$ u, sys.sum$ s

WHERE o.type# = 42 AND bitand(s.mflags, 8) =8;

3、Ensuring That No Files Are in Backup Mode Before Upgrading

SQL> SELECT * FROM v$backup WHERE status != 'NOT ACTIVE';

4、Ensuring That No Files Need Media Recovery Before Upgrading

SQL> SELECT * FROM v$recover_file;

5、Resolving Outstanding Distributed Transactions Before Upgrading

1. Run the following statement:

SQL> SELECT * FROM dba_2pc_pending;

2. If the query in the previous step returns any rows, then run the following

statements:

SQL> SELECT local_tran_id FROM dba_2pc_pending;

SQL> EXECUTE dbms_transaction.purge_lost_db_entry('');

SQL> COMMIT;

6、Purging the Database Recycle Bin Before Upgrading

SQL> PURGE DBA_RECYCLEBIN

四、数据库备份

1. Sign on to Oracle RMAN:

rman "target / nocatalog"

2. Run the following RMAN commands:

RUN

{ALLOCATE CHANNEL chan_name TYPE DISK;

BACKUP DATABASE FORMAT 'some_backup_directory%U' TAG before_upgrade;

BACKUP CURRENT CONTROLFILE FORMAT 'controlfile location and name';

}

5预升级检查

5.1参考文档

Oracle Database Pre-Upgrade Utility (Document ID 884522.1) at My Oracle

Support

oracle 12c 12.2.0.1,Oracle-Database-12c-12.2.0.1升级实战_第3张图片

5.2执行预升级检查

Example 2-4 Non-CDB In the Source Oracle Home Example

1. Run the new release Oracle Database Pre-Upgrade Information Tool on the earlier

release Oracle Database server (12.2), using the environment settings you have set

to the earlier release Oracle home.

mkdir –p /u01/app/oracle/product/12.2.0/rdbms/admin/

mv preupgrade.jar /u01/app/oracle/product/12.2.0/rdbms/admin/

$ORACLE_HOME/jdk/bin/java -jar /u01/app/oracle/product/12.2.0/rdbms/admin/

preupgrade.jar TERMINAL TEXT

[oracle@oracle12c soft]$ $ORACLE_HOME/jdk/bin/java -jar /u01/app/oracle/product/12.2.0/rdbms/admin/preupgrade.jar TERMINAL TEXT

Report generated by Oracle Database Pre-Upgrade Information Tool Version

12.2.0.1.0

Upgrade-To version: 12.2.0.1.0

=======================================

Status of the database prior to upgrade

=======================================

Database Name:  HSQL

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:  14

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

Oracle Workspace Manager               [to be upgraded]  VALID

OLAP Analytic Workspace                [to be upgraded]  VALID

Oracle Enterprise Manager Repository   [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

Expression Filter                      [to be upgraded]  VALID

Rule Manager                           [to be upgraded]  VALID

Oracle Application Express             [to be upgraded]  VALID

Oracle OLAP API                        [to be upgraded]  VALID

==============

BEFORE UPGRADE

==============

Run /preupgrade_fixups.sql to complete all

of the BEFORE UPGRADE action items below marked with '(AUTOFIXUP)'.

REQUIRED ACTIONS

================

+ Adjust TABLESPACE SIZES as needed.

Auto      12.2.0.1.0

Tablespace                        Size     Extend    Min Size    Action

----------                     ----------  --------  ----------  ------

SYSAUX                             510 MB  ENABLED      1420 MB  None

SYSTEM                             740 MB  ENABLED      1249 MB  None

TEMP                                29 MB  ENABLED       150 MB  None

UNDOTBS1                            80 MB  ENABLED       400 MB  None

Note that 12.2.0.1.0 minimum sizes are estimates.

If you plan to upgrade multiple pluggable databases concurrently,

then you must ensure that the UNDO tablespace size is equal to at least

the number of pluggable databases that you upgrade concurrently,

multiplied by that minimum.  Failing to allocate sufficient space can

cause the upgrade to fail.

+ Update NUMERIC INITIALIZATION PARAMETERS to meet estimated minimums.

Parameter                         12.2.0.1.0 minimum

---------                         ------------------

processes                                        300

RECOMMENDED ACTIONS

===================

+ Remove the EM repository.

- Copy the $ORACLE_HOME/rdbms/admin/emremove.sql script from the target

12.2.0.1.0 ORACLE_HOME into the source 11.2.0.4.0 ORACLE_HOME.

ls /u01/app/oracle/product/12.2.0/db_1/rdbms/admin/emremove.sql

cp /u01/app/oracle/product/12.2.0/db_1/rdbms/admin/emremove.sql /u01/app/oracle/product/11.2.0/db_1/rdbms/admin/emremove.sql

Step 1: If database control is configured, stop EM Database Control,

using the following command

$> emctl stop dbconsole

Step 2: 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.

The database has an Enterprise Manager Database Control repository.

Starting with Oracle Database 12c, the local Enterprise Manager Database

Control does not exist anymore. The repository will be removed from your

database during the upgrade.  This step can be manually performed before

the upgrade to reduce downtime.

+ Remove OLAP Catalog by running the 11.2.0.4.0 SQL script

$ORACLE_HOME/olap/admin/catnoamd.sql script.

The OLAP Catalog component, AMD, exists in the database.

Starting with Oracle Database 12c, the OLAP Catalog (OLAP AMD) is

desupported and will be automatically marked as OPTION OFF during the

database upgrade if present. Oracle recommends removing OLAP Catalog

(OLAP AMD) before database upgrade.

+ (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 11.2.0.4

Oracle Database Performance Tuning Guide.

+ Directly grant ADMINISTER DATABASE TRIGGER privilege to the owner of the

trigger or drop and re-create the trigger with a user that was granted

directly with such. You can list those triggers using "SELECT OWNER,

TRIGGER_NAME FROM DBA_TRIGGERS WHERE BASE_OBJECT_TYPE=''DATABASE'' AND

OWNER NOT IN (SELECT GRANTEE FROM DBA_SYS_PRIVS WHERE

PRIVILEGE=''ADMINISTER DATABASE TRIGGER'')"

SELECT OWNER,TRIGGER_NAME FROM DBA_TRIGGERS WHERE BASE_OBJECT_TYPE='DATABASE' AND OWNER NOT IN (SELECT GRANTEE FROM DBA_SYS_PRIVS WHERE PRIVILEGE='ADMINISTER DATABASE TRIGGER');

There is one or more database triggers whose owner does not have the

right privilege on the database.

The creation of database triggers must be done by users granted with

ADMINISTER DATABASE TRIGGER privilege. Privilege must have been granted

directly.

INFORMATION ONLY

================

+ Consider upgrading APEX manually, before the database upgrade.

The database contains APEX version 3.2.1.00.12 and will need to be

upgraded to at least version 5.0.4.00.12.

To reduce database upgrade time, you can upgrade APEX manually before

the database upgrade.  Refer to My Oracle Support Note 1088970.1 for

information on APEX installation upgrades.

=============

AFTER UPGRADE

=============

Run /postupgrade_fixups.sql to complete all

of the AFTER UPGRADE action items below marked with '(AUTOFIXUP)'.

REQUIRED ACTIONS

================

None

RECOMMENDED ACTIONS

===================

+ Upgrade the database time zone version using the DBMS_DST package.

The database is using timezone datafile version 14 and the target

12.2.0.1.0 database ships with timezone datafile version 26.

Oracle recommends using the most recent timezone data.  For further

information, refer to My Oracle Support Note 1585343.1.

+ (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.

+ Gather statistics on fixed objects two weeks after the upgrade 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.

INFORMATION ONLY

================

+ Check the Oracle documentation for the identified components for their

specific upgrade procedure.

The database upgrade script will not upgrade the following Oracle

components:  OLAP Catalog,OWB

The Oracle database upgrade script upgrades most, but not all Oracle

Database components that may be installed.  Some components that are not

upgraded may have their own upgrade scripts, or they may be deprecated

or obsolete.

upgrade to Oracle Database 12C

Preupgrade generated files:

/u01/app/oracle/cfgtoollogs/hsql/preupgrade/preupgrade_fixups.sql

/u01/app/oracle/cfgtoollogs/hsql/preupgrade/postupgrade_fixups.sql

5.3修复存在问题

根据上面执行结果提示,执行以下修复脚本:

注:请先手工修复后再执行preupgrade_fixups.sql,提高修复效率。

ALTER

SYSTEM SET PROCESSES=300 SCOPE=SPFILE;

$ORACLE_HOME/olap/admin/catnoamd.sql

EXECUTE

DBMS_STATS.GATHER_DICTIONARY_STATS;

SELECT

OWNER,TRIGGER_NAME FROM DBA_TRIGGERS WHERE BASE_OBJECT_TYPE='DATABASE' AND

OWNER NOT IN (SELECT GRANTEE FROM DBA_SYS_PRIVS WHERE PRIVILEGE='ADMINISTER

DATABASE TRIGGER');

grant

ADMINISTER DATABASE TRIGGER to sysman;

Remove the EM repository

--12C软件安装完后DBUA检查时再执行

Step 1: If database control is configured,

stop EM Database Control,

using the following command

$> emctl stop dbconsole

Step 2: Connect to the database using the SYS account AS SYSDBA

SET ECHO ON;

SET SERVEROUTPUT ON;

@emremove.sql

执行脚本

@/u01/app/oracle/cfgtoollogs/hsql/preupgrade/preupgrade_fixups.sql

检查预升级项修复

oracle 12c 12.2.0.1,Oracle-Database-12c-12.2.0.1升级实战_第4张图片

Script to Collect DB Upgrade/Migrate Diagnostic

Information (dbupgdiag.sql) (文档 ID 556610.1)

Connect as sysdba and execute the script

cd

$ sqlplus / as sysdba

sql> alter session set nls_language='American';

sql> @dbupgdiag.sql

sql> exit

6安装12C软件

6.1环境变量

export ORACLE_SID=hsql

export ORACLE_BASE=/u01/app/oracle

export ORACLE_HOME=$ORACLE_BASE/product/12.2.0/db_1

export PATH=$PATH:$ORACLE_BASE/product/12.2.0/db_1/bin

mkdir –p /u01/app/oracle/product/12.2.0/db_1

6.2解压软件:

unzip V839960-01.zip6.3安装12c软件

进入解压目录执行./runInstaller 开启12c安装进程

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

oracle 12c 12.2.0.1,Oracle-Database-12c-12.2.0.1升级实战_第5张图片

选择upgrade an existing database,next

oracle 12c 12.2.0.1,Oracle-Database-12c-12.2.0.1升级实战_第6张图片

oracle 12c 12.2.0.1,Oracle-Database-12c-12.2.0.1升级实战_第7张图片

oracle 12c 12.2.0.1,Oracle-Database-12c-12.2.0.1升级实战_第8张图片

oracle 12c 12.2.0.1,Oracle-Database-12c-12.2.0.1升级实战_第9张图片

oracle 12c 12.2.0.1,Oracle-Database-12c-12.2.0.1升级实战_第10张图片

oracle 12c 12.2.0.1,Oracle-Database-12c-12.2.0.1升级实战_第11张图片

使用root执行脚本

oracle 12c 12.2.0.1,Oracle-Database-12c-12.2.0.1升级实战_第12张图片

oracle 12c 12.2.0.1,Oracle-Database-12c-12.2.0.1升级实战_第13张图片

oracle 12c 12.2.0.1,Oracle-Database-12c-12.2.0.1升级实战_第14张图片

oracle 12c 12.2.0.1,Oracle-Database-12c-12.2.0.1升级实战_第15张图片

修复以上问题

点击:fix & check Again

ls

/u01/app/oracle/product/12.2.0/db_1/rdbms/admin/emremove.sql

cp /u01/app/oracle/product/12.2.0/db_1/rdbms/admin/emremove.sql

/u01/app/oracle/product/11.2.0/db_1/rdbms/admin/emremove.sql

@ /u01/app/oracle/product/11.2.0/db_1/rdbms/admin/emremove.sql

oracle 12c 12.2.0.1,Oracle-Database-12c-12.2.0.1升级实战_第16张图片

oracle 12c 12.2.0.1,Oracle-Database-12c-12.2.0.1升级实战_第17张图片

oracle 12c 12.2.0.1,Oracle-Database-12c-12.2.0.1升级实战_第18张图片

oracle 12c 12.2.0.1,Oracle-Database-12c-12.2.0.1升级实战_第19张图片

oracle 12c 12.2.0.1,Oracle-Database-12c-12.2.0.1升级实战_第20张图片

oracle 12c 12.2.0.1,Oracle-Database-12c-12.2.0.1升级实战_第21张图片

oracle 12c 12.2.0.1,Oracle-Database-12c-12.2.0.1升级实战_第22张图片

7 升级后检查

Gathering Dictionary Statistics After

Upgrading

SQL> EXEC

DBMS_STATS.GATHER_DICTIONARY_STATS;

Regathering Fixed Objects Statistics with

DBMS_STATS

SQL> execute

dbms_stats.gather_fixed_objects_stats;

数据库版本及组件检查

select banner from v$version;

select substr(comp_id,1,15)

comp_id,substr(comp_name,1,30) comp_name,substr(version,1,10) version,status

from dba_registry order by modified;

检查字符集及时区

select value from nls_database_parameters

where parameter='NLS_NCHAR_CHARACTERSET';

SELECT PROPERTY_NAME,

SUBSTR(property_value, 1, 30) value FROM DATABASE_PROPERTIES WHERE

PROPERTY_NAME LIKE 'DST_%' ORDER BY PROPERTY_NAME;

select TZ_VERSION from registry$database;

select * from v$timezone_file;

修改COMPATIBLE参数

SQL>show parameter COMPATIBLE

SQL> ALTER SYSTEM SET COMPATIBLE =

'12.2.0.1.0' SCOPE=SPFILE;

SQL>startup

force

历时20小时数据库已顺利从11.2.0.4升级至12.2.0.1,各们童鞋升级前请做好数据库备份,本文档仅供参考,生产环境升级请参考官方升级文档

《Oracle? Database Upgrade Guide 12c Release 2 (12.2) E49634-13》。

你可能感兴趣的:(oracle,12c,12.2.0.1)