Oracle 9208 upgrade to 10205 Step By Step


0. summary

1. 升级环境
.   1.1 系统版本
.   1.2 系统补丁检查
2. 升级准备
.   2.1 数据字典一致性检查                      
.   2.2 执行Database Pre-Upgrade Utility        
.   2.3 检查失效对象                            
.   2.4 检查DBA_REGISTRY                        
.   2.5 收集统计信息                            
.   2.6 如果存在表XDB.MIGR9202STATUS, 需要drop掉
3. 安装10gR2介质
.   3.1 拷贝tar包并解压  
.   3.2 准备10g的环境变量
.   3.3 创建全局Inventory
.   3.4 relink 
4. 开始升级                                               
.   4.1 CONNECT角色中权限的回收                                       
.   4.2 确保物化视图已经全部刷新                                      
.   4.3 停监听                                                
.   4.4 禁止批处理的JOB和crontab                              
.   4.5 备份DBLINK创建脚本                                    
.   4.6 确认SYS、SYSTEM用户处于自已的表空间                            
.   4.7 如果启用审计,确认aud$在SYSTEM表空间                  
.   4.8 备份数据库                                            
.   4.9 检查归档目录剩余大小                                  
.   4.10 检查NLS_NCHAR_CHARACTERSET                           
.   4.11 修改参数文件                                         
.   4.12 创建SYSAUX表空间                                            
.   4.13 复制SQL*Net文件、密码文件到新环境                    
.   4.14 再次执行utlu102i并检查输出        
.   4.15 停库并启动upgrade并执行升级                                             
.   4.16 检查升级后状态                                       
.   4.17 关库并启动到restrict模式,执行utlu102s.sql、utlrp.sql
.   4.18 检查失效对象并对比invalid_pre.lst                    
.   4.19 重新赋予connect角色缺少的权限                        
.   4.20 重建Oracle Label Security的DML Triggers    
.   4.21 重启库并启动监听
.   4.22 确认/etc/oratab
.   4.23 收集数据字典统计信息
.   4.24 设置正确的备份连接
.   4.25 修改profile
5. 参考文档

1. 升级环境

1.1 系统版本

zjquery1#[/oracle9i/script]uname -a
HP-UX zjquery1 B.11.11 U 9000/800 3800820170 unlimited-user license

1.2 系统补丁检查

/usr/sbin/swlist -l bundle | grep "GOLD"
/usr/sbin/swlist -l patch -a supersedes | grep -in 31221
/usr/sbin/swlist -l patch -a supersedes | grep -in 30970
/usr/sbin/swlist -l patch -a supersedes | grep -in 32508
/usr/sbin/swlist -l patch -a supersedes | grep -in 32509
/usr/sbin/swlist -l patch -a supersedes | grep -in 32510

2. 升级准备

2.1 数据字典一致性检查

参考:

hcheck.sql - Script to Check for Known Problems in Oracle8i, Oracle9i, Oracle10g, Oracle 11g and Oracle 12c (文档 ID 136697.1)

SQL> @hout

Package created.

No errors.

Package body created.

SQL> spool hcheck.log
SQL> @hcheck4

Package created.


Package body created.

H.Check Version 4.1
---------------------------------------
Catalog Version  9.2.0.8.0  (902000800)
db_name: QUERY

06-JUN-2016 16:58:57
---------------------------------------

                                   Catalog       Fixed
Procedure Name                     Version    Vs Release      Run
------------------------------ ... ---------- -- ----------   ---
.- SynLastDDLTim               ... 902000800  <= 1001000200 : Ok  06/06 16:58:57

HCKW-0001: Synonym's LAST_DDL_TIME != CREATED
OBJ#=5804 Name=QUERY.ACCT_ITEM_TYPE
OBJ#=5805 Name=QUERY.A_APP_ERROR
OBJ#=5806 Name=QUERY.A_BSS_ORG_SWITCH
OBJ#=5809 Name=QUERY.B_INST_TABLE_LIST_CFG
OBJ#=5811 Name=QUERY.OUTER_QUERY_LOG
OBJ#=5814 Name=QUERY.STAFF
OBJ#=5817 Name=QUERY.ACCT
OBJ#=5829 Name=QUERY.B_INST_TABLE_LIST
OBJ#=5839 Name=QUERY.ORG
OBJ#=5840 Name=QUERY.PAYMENT
OBJ#=6981 Name=QUERY.CUST
OBJ#=6982 Name=QUERY.A_SERV_EX
OBJ#=6984 Name=QUERY.B_ACCU_TYPE
OBJ#=6985 Name=QUERY.B_ACCU_CAL_RULE
OBJ#=6986 Name=QUERY.EVENT_AGGR
OBJ#=10768 Name=QUERY.B_HEAD_REGION
OBJ#=10772 Name=QUERY.SYS_DOMAIN
OBJ#=30027 Name=QUERY.B_AREA_CODE
OBJ#=31402 Name=QUERY.CCG_PRODUCT_DESC

.- LobNotInObj                 ... 902000800  <=  *All Rel* : Ok  06/06
16:58:57
.- MissingOIDOnObjCol          ... 902000800  <=  *All Rel* : Ok  06/06 16:58:57
.- SourceNotInObj              ... 902000800  <=  *All Rel* : Ok  06/06 16:58:57
.- IndIndparMismatch           ... 902000800  <= 1102000100 : Ok  06/06 16:58:59
.- InvCorrAudit                ... 902000800  <= 1102000100 : Ok  06/06 16:58:59
.- OversizedFiles              ... 902000800  <=  *All Rel* : Ok  06/06 16:58:59
.- TinyFiles                   ... 902000800  >   900010000 : n/a
.- PoorDefaultStorage          ... 902000800  <=  *All Rel* : Ok  06/06 16:58:59

HCKW-0002: Poor Default Storage Clauses For Tablespace (Doc ID 1360493.1)
Tablespace                    Init      Next      Min       Pct MaxExtents
TOOLS                         32768     32768     1         0   4096

.- PoorStorage                 ... 902000800  <=  *All Rel* : Ok  06/06
16:58:59
.- MissTabSubPart              ... 902000800  >   900010000 : n/a
.- PartSubPartMismatch         ... 902000800  <= 1102000100 : Ok  06/06 16:59:01
.- TabPartCountMismatch        ... 902000800  <=  *All Rel* : Ok  06/06 16:59:01
.- OrphanedTabComPart          ... 902000800  <=  *All Rel* : Ok  06/06 16:59:01
.- ZeroIndSubPart              ... 902000800  >   902000100 : n/a
.- MissingSum$                 ... 902000800  <=  *All Rel* : Ok  06/06 16:59:01
.- MissingDir$                 ... 902000800  <=  *All Rel* : Ok  06/06 16:59:02
.- DuplicateDataobj            ... 902000800  <=  *All Rel* : Ok  06/06 16:59:02
.- ObjSynMissing               ... 902000800  <=  *All Rel* : Ok  06/06 16:59:02
.- ObjSeqMissing               ... 902000800  <=  *All Rel* : Ok  06/06 16:59:02
.- OrphanedUndo                ... 902000800  <=  *All Rel* : Ok  06/06 16:59:02
.- OrphanedIndex               ... 902000800  <=  *All Rel* : Ok  06/06 16:59:02
.- OrphanedIndexPartition      ... 902000800  <=  *All Rel* : Ok  06/06 16:59:02
.- OrphanedIndexSubPartition   ... 902000800  <=  *All Rel* : Ok  06/06 16:59:02
.- OrphanedTable               ... 902000800  <=  *All Rel* : Ok  06/06 16:59:02
.- OrphanedTablePartition      ... 902000800  <=  *All Rel* : Ok  06/06 16:59:02
.- OrphanedTableSubPartition   ... 902000800  <=  *All Rel* : Ok  06/06 16:59:02
.- MissingPartCol              ... 902000800  <=  *All Rel* : Ok  06/06 16:59:02
.- OrphanedSeg$                ... 902000800  <=  *All Rel* : Ok  06/06 16:59:02
.- OrphanedIndPartObj#         ... 902000800  <=  *All Rel* : Ok  06/06 16:59:02
.- DuplicateBlockUse           ... 902000800  <=  *All Rel* : Ok  06/06 16:59:02
.- FetUet                      ... 902000800  <=  *All Rel* : Ok  06/06 16:59:02
.- Uet0Check                   ... 902000800  <=  *All Rel* : Ok  06/06 16:59:02
.- ExtentlessSeg               ... 902000800  <= 1102000100 : Ok  06/06 16:59:02
.- SeglessUET                  ... 902000800  <=  *All Rel* : Ok  06/06 16:59:02
.- BadInd$                     ... 902000800  <=  *All Rel* : Ok  06/06 16:59:02
.- BadTab$                     ... 902000800  <=  *All Rel* : Ok  06/06 16:59:02
.- BadIcolDepCnt               ... 902000800  <=  *All Rel* : Ok  06/06 16:59:02
.- WarnIcolDep                 ... 902000800  <= 1101000700 : Ok  06/06 16:59:02
.- ObjIndDobj                  ... 902000800  <=  *All Rel* : Ok  06/06 16:59:02
.- DropForceType               ... 902000800  <= 1001000200 : Ok  06/06 16:59:02
.- TrgAfterUpgrade             ... 902000800  <=  *All Rel* : Ok  06/06 16:59:03
.- ObjType0                    ... 902000800  <=  *All Rel* : Ok  06/06 16:59:03
.- ObjOidView                  ... 902000800  >   900010000 : n/a
.- Idgen1$TTS                  ... 902000800  >   900010000 : n/a
.- DroppedFuncIdx              ... 902000800  >   902000100 : n/a
.- BadOwner                    ... 902000800  <=  *All Rel* : Ok  06/06 16:59:03
.- StmtAuditOnCommit           ... 902000800  <=  *All Rel* : Ok  06/06 16:59:03

HCKW-0013: option# in STMT_AUDIT_OPTION_MAP(ON COMMIT REFRESH) (Doc ID
1361021.1)
-- Please run the following:
SQL> update STMT_AUDIT_OPTION_MAP set option#=234
where name ='ON COMMIT REFRESH' ;
SQL> commit ;

.- BadPublicObjects            ... 902000800  <=  *All Rel* : Ok  06/06
16:59:03
.- BadSegFreelist              ... 902000800  <=  *All Rel* : Ok  06/06 16:59:03
.- BadCol#                     ... 902000800  <= 1001000200 : Ok  06/06 16:59:03
.- BadDepends                  ... 902000800  <=  *All Rel* : Ok  06/06 16:59:03
.- CheckDual                   ... 902000800  <=  *All Rel* : Ok  06/06 16:59:03
.- ObjectNames                 ... 902000800  <=  *All Rel* : Ok  06/06 16:59:03
.- BadCboHiLo                  ... 902000800  <=  *All Rel* : Ok  06/06 16:59:03
.- ChkIotTs                    ... 902000800  <=  *All Rel* : Ok  06/06 16:59:03
.- NoSegmentIndex              ... 902000800  <=  *All Rel* : Ok  06/06 16:59:03
.- BadNextObject               ... 902000800  <=  *All Rel* : Ok  06/06 16:59:03
.- OrphanIndopt                ... 902000800  <=  902000800 : Ok  06/06 16:59:03

HCKE-0041: Binding w/ multiple dictionary entries
OBJ# 3876 - BIND# 1(11)

HCKE-0041: Binding w/ multiple dictionary entries
OBJ# 3930 - BIND# 1(2)

.- UpgFlgBitTmp                ... 902000800  <= 1001000100 : Ok  06/06
16:59:03
.- RenCharView                 ... 902000800  <= 1001000100 : Ok  06/06 16:59:03
.- Upg9iTab$                   ... 902000800  >   902000400 : n/a
.- Upg9iTsInd                  ... 902000800  >   902000500 : n/a
.- Upg10gInd$                  ... 902000800  <= 1002000000 : Ok  06/06 16:59:03

HCKW-0025: IND$ contains corrupt data after upgrade to 10g
Total number of entries wrong: 2

.- DroppedROTS                 ... 902000800  <=  *All Rel* : Ok  06/06
16:59:03
.- ChrLenSmtcs                 ... 902000800  <= 1101000600 : Ok  06/06 16:59:03
.- FilBlkZero                  ... 902000800  <=  *All Rel* : Ok  06/06 16:59:03
.- DbmsSchemaCopy              ... 902000800  <=  *All Rel* : Ok  06/06 16:59:03
.- OrphanedIdnseqObj           ... 902000800  <  1201000000 : n/a
.- OrphanedIdnseqSeq           ... 902000800  <  1201000000 : n/a
.- OrphanedObjError            ... 902000800  <  1102000000 : n/a
.- ObjNotLob                   ... 902000800  <=  *All Rel* : Ok  06/06 16:59:03
.- MaxControlfSeq              ... 902000800  <=  *All Rel* : Ok  06/06 16:59:03

Found 2 potential problem(s) and 22 warning(s)
Contact Oracle Support with the output
to check if the above needs attention or not

PL/SQL procedure successfully completed.

Statement processed.

Output is also in trace file:
/oracle9i/admin/query/udump/query_ora_4193_HCHECK.trc

SQL> spool off

或者使用如下脚本生成analyze.sql

SET verify off
SET SPACE 0
SET line 120
SET heading off
SET feedback off
SET pages 1000
Spool analyze.sql

SELECT 'Analyze cluster "'||cluster_name||'" validate structure cascade;'
FROM dba_clusters
WHERE owner='SYS'
UNION
SELECT 'Analyze table "'||TABLE_NAME||'" validate structure cascade;'
FROM dba_tables
WHERE owner='SYS'
AND partitioned='NO'
AND (iot_type='IOT' OR iot_type IS NULL)
UNION
SELECT 'Analyze table "'||TABLE_NAME||'" validate structure cascade into invalid_rows;'
FROM dba_tables
WHERE owner='SYS'
AND partitioned='YES';

spool off

注意修改下analyze.sql, 执行

$ sqlplus "/ as sysdba"

SQL> @$ORACLE_HOME/rdbms/admin/utlvalid.sql
SQL> @analyze.sql

2.2 执行Database Pre-Upgrade Utility

参考:

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

SQL> spool utlu102i.out
SQL> @utlu102i_2
SP2-0734: unknown command beginning "Connecting..." - rest of line ignored.
SP2-0734: unknown command beginning "Fetched rd..." - rest of line ignored.
SP2-0734: unknown command beginning "its affili..." - rest of line ignored.
Oracle Database 10.2 Upgrade Information Utility    06-06-2016 17:04:25
.
**********************************************************************
Database:
**********************************************************************
--> name:       QUERY
--> version:    9.2.0.8.0
--> compatible: 9.2.0.8
--> blocksize:  8192
.
**********************************************************************
Logfiles: [make adjustments in the current environment]
**********************************************************************
--> The existing log files are adequate. No changes are required.
.
**********************************************************************
Tablespaces: [make adjustments in the current environment]
**********************************************************************
--> SYSTEM tablespace is adequate for the upgrade.
.... minimum required size: 562 MB
--> TEMP tablespace is adequate for the upgrade.
.... minimum required size: 58 MB
.
**********************************************************************
Update Parameters: [Update Oracle Database 10.2 init.ora or spfile]
**********************************************************************
WARNING: --> "java_pool_size" needs to be increased to at least 67108864
WARNING: --> "streams_pool_size" is not currently defined and needs a value of
at least 50331648
WARNING: --> "session_max_open_files" needs to be increased to at least 20
.
**********************************************************************
Renamed Parameters: [Update Oracle Database 10.2 init.ora or spfile]
**********************************************************************
-- No renamed parameters found. No changes are required.
.
**********************************************************************
Obsolete/Deprecated Parameters: [Update Oracle Database 10.2 init.ora or spfile]
**********************************************************************
--> "log_archive_start"
--> "max_enabled_roles"
.
**********************************************************************
Components: [The following database components will be upgraded or installed]
**********************************************************************
--> Oracle Catalog Views         [upgrade]  VALID
--> Oracle Packages and Types    [upgrade]  VALID
--> JServer JAVA Virtual Machine [install]
...The 'JServer JAVA Virtual Machine' JAccelerator (NCOMP)
...is required to be installed from the 10g Companion CD.
--> Oracle XDK for Java          [install]
--> Oracle Java Packages         [install]
--> Oracle XML Database          [install]
--> Real Application Clusters    [upgrade]  INVALID
--> Oracle interMedia            [install]
...The 'Oracle interMedia Image Accelerator' is
...required to be installed from the 10g Companion CD.
--> Spatial                      [upgrade]  LOADED
.
**********************************************************************
Miscellaneous Warnings
**********************************************************************
WARNING: --> Passwords exist in some database links.
.... Passwords will be encrypted during the upgrade.
.... Downgrade of database links with passwords is not supported.
WARNING: --> Deprecated CONNECT role granted to some user/roles.
.... CONNECT role after upgrade has only CREATE SESSION privilege.
WARNING: --> Database contains stale optimizer statistics.
.... Refer to the 10g Upgrade Guide for instructions to update
.... statistics prior to upgrading the database.
.... Component Schemas with stale statistics:
....   SYS
....   MDSYS
WARNING: --> Database contains INVALID objects prior to upgrade.
.... USER CAL has 5 INVALID objects.
.... USER PERFSTAT has 1 INVALID objects.
.... USER QUERY has 42 INVALID objects.
.... USER WXZX has 4 INVALID objects.
.
**********************************************************************
SYSAUX Tablespace:
[Create tablespace in the Oracle Database 10.2 environment]
**********************************************************************
--> New "SYSAUX" tablespace
.... minimum required size for database upgrade: 500 MB
.

PL/SQL procedure successfully completed.

SQL> spool off

2.3 检查失效对象

script

spool invalid_pre.lst
set echo on
set lines 200 pages 100
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 substr(owner,1,12) owner,
substr(object_name,1,30) object,
substr(object_type,1,30) type, status
from dba_objects
where status <> 'VALID'
order by owner, type;
spool off;
set echo off;

output

SQL> spool invalid_pre.lst
SQL> set echo on
SQL> set lines 200 pages 100
SQL> select substr(comp_id,1,15) comp_id,
  2  substr(comp_name,1,30) comp_name,
  3  substr(version,1,10) version,
  4  status
  5  from dba_registry
  6  order by modified;

COMP_ID                        COMP_NAME                                                    VERSION              STATUS
------------------------------ ------------------------------------------------------------ -------------------- -----------
RAC                            Oracle9i Real Application Clus                               9.2.0.8.0            INVALID
SDO                            Oracle Spatial                                               8.1.7.0.0            LOADED
CATALOG                        Oracle9i Catalog Views                                       9.2.0.8.0            VALID
CATPROC                        Oracle9i Packages and Types                                  9.2.0.8.0            VALID

SQL> select substr(owner,1,12) owner,
  2  substr(object_name,1,30) object,
  3  substr(object_type,1,30) type, status
  4  from dba_objects
  5  where status <> 'VALID'
  6  order by owner, type;

OWNER                    OBJECT                                                       TYPE                                 STATUS
------------------------ ------------------------------------------------------------ ------------------------------------ -------
CAL                      GET_QUERY_NAME                                               FUNCTION                             INVALID
CAL                      KEVIN_TJ_TMP                                                 PROCEDURE                            INVALID
CAL                      QUERY_NET_REST_TIME                                          PROCEDURE                            INVALID
CAL                      TIGER_HLR_TEMP                                               PROCEDURE                            INVALID
CAL                      TIGER_UPDATE_277                                             PROCEDURE                            INVALID
PERFSTAT                 STATSPACK                                                    PACKAGE BODY                         INVALID
QUERY                    MOBILE_HDTJ                                                  PROCEDURE                            INVALID
QUERY                    YC_CDMA_HY_DAILY                                             PROCEDURE                            INVALID
QUERY                    DATA_EVENT_201206_DY_V                                       VIEW                                 INVALID
QUERY                    DATA_EVENT_201206_JR_V                                       VIEW                                 INVALID
QUERY                    DATA_EVENT_201206_YZ_V                                       VIEW                                 INVALID
QUERY                    DATA_EVENT_201206_ZJ_V                                       VIEW                                 INVALID
QUERY                    DATA_EVENT_201207_DY_V                                       VIEW                                 INVALID
QUERY                    DATA_EVENT_201207_JR_V                                       VIEW                                 INVALID
QUERY                    DATA_EVENT_201207_YZ_V                                       VIEW                                 INVALID
QUERY                    DATA_EVENT_201207_ZJ_V                                       VIEW                                 INVALID
QUERY                    DATA_EVENT_201208_DY_V                                       VIEW                                 INVALID
QUERY                    DATA_EVENT_201208_JR_V                                       VIEW                                 INVALID
QUERY                    DATA_EVENT_201208_YZ_V                                       VIEW                                 INVALID
QUERY                    DATA_EVENT_201208_ZJ_V                                       VIEW                                 INVALID
QUERY                    DATA_EVENT_201209_DY_V                                       VIEW                                 INVALID
QUERY                    DATA_EVENT_201209_JR_V                                       VIEW                                 INVALID
QUERY                    DATA_EVENT_201209_YZ_V                                       VIEW                                 INVALID
QUERY                    DATA_EVENT_201209_ZJ_V                                       VIEW                                 INVALID
QUERY                    DATA_EVENT_201210_DY_V                                       VIEW                                 INVALID
QUERY                    DATA_EVENT_201210_JR_V                                       VIEW                                 INVALID
QUERY                    DATA_EVENT_201210_YZ_V                                       VIEW                                 INVALID
QUERY                    DATA_EVENT_201210_ZJ_V                                       VIEW                                 INVALID
QUERY                    DATA_EVENT_201211_DY_V                                       VIEW                                 INVALID
QUERY                    DATA_EVENT_201211_JR_V                                       VIEW                                 INVALID
QUERY                    DATA_EVENT_201211_YZ_V                                       VIEW                                 INVALID
QUERY                    DATA_EVENT_201211_ZJ_V                                       VIEW                                 INVALID
QUERY                    DATA_EVENT_201212_DY_V                                       VIEW                                 INVALID
QUERY                    DATA_EVENT_201212_JR_V                                       VIEW                                 INVALID
QUERY                    DATA_EVENT_201212_YZ_V                                       VIEW                                 INVALID
QUERY                    DATA_EVENT_201212_ZJ_V                                       VIEW                                 INVALID
WXZX                     CALL_TICKET_BEFORE                                           VIEW                                 INVALID
WXZX                     CALL_TICKET_TODAY                                            VIEW                                 INVALID
WXZX                     LS_CALL_TICKET_BEFORE                                        VIEW                                 INVALID
WXZX                     LS_CALL_TICKET_TODAY                                         VIEW                                 INVALID

40 rows selected.

SQL> spool off;
SQL> set echo off;

2.4 检查DBA_REGISTRY

如果是从Oracle 9iR2升级,检查dba_registry是否有信息,如果没有,在9.2的ORACLE_HOME中执行如下脚本:

$ sqlplus '/as sysdba' 
SQL> @?/rdbms/admin/catalog.sql 
SQL> @?/rdbms/admin/catproc.sql 
SQL> @?/rdbms/admin/utlrp.sql

2.5 收集统计信息

参考:

Script that Checks for Schemas Containing Stale Statistics (文档 ID 560336.1)

SQL> @check_stale_stats.sql

-- There are no stale statistics in MDSYS schema.

-- There are no stale statistics in SYS schema.

2.6 如果存在表XDB.MIGR9202STATUS, 需要drop掉

参考:

ORA-7445 [qmeLoadMetadata()+452] During 10.1 to 10.2 Upgrade (文档 ID 356082.1)

3. 安装10gR2介质

这里演示的tar包直接拷贝

3.1 拷贝tar包并解压

3.2 准备10g的环境变量

vi /ora10g/.profile10g

TERM=vt100
export TERM

umask 022

export ORACLE_BASE=/ora10g/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export ORACLE_SID=query
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export NLS_LANG=American_america.zhs16gbk
export NLS_TIMESTAMP_FORMAT='YYYY-MM-DD HH24:MI:SS.FF'
export SHLIB_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/lib32

PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH
export PATH

3.3 创建全局Inventory

$ . ./.profile10g
$ cd $ORACLE_HOME/oui/bin                                                                                                         
$ pwd
/ora10g/app/oracle/product/10.2.0/db_1/oui/bin
$ ./runInstaller -silent -ignoreSysPrereqs -attachHome ORACLE_HOME="/ora10g/app/oracle/product/10.2.0/db_1" ORACLE_HOME_NAME="OraDb10g_home1"
Starting Oracle Universal Installer...

No pre-requisite checks found in oraparam.ini, no system pre-requisite checks will be executed.

>>> Ignoring required pre-requisite failures. Continuing...

The inventory pointer is located at /var/opt/oracle/oraInst.loc
The inventory is located at /oracle9i/oraInventory
'AttachHome' was successful.

3.4 relink

$ $ORACLE_HOME/bin/relink all

4. 开始升级

4.1 CONNECT角色中权限的回收

在升级到10gR2后,CONNECT角色只包含CREATE SESSION权限,其它权限被回收了。升级脚本只会调整Oracle提供的用户。

检查有connect角色的用户

SELECT grantee FROM dba_role_privs
WHERE granted_role = 'CONNECT' and
grantee NOT IN (
'SYS', 'OUTLN', 'SYSTEM', 'CTXSYS', 'DBSNMP',
'LOGSTDBY_ADMINISTRATOR', 'ORDSYS', 
'ORDPLUGINS', 'OEM_MONITOR', 'WKSYS', 'WKPROXY',
'WK_TEST', 'WKUSER', 'MDSYS', 'LBACSYS', 'DMSYS',
'WMSYS', 'OLAPDBA', 'OLAPSVR', 'OLAP_USER', 
'OLAPSYS', 'EXFSYS', 'SYSMAN', 'MDDATA',
'SI_INFORMTN_SCHEMA', 'XDB', 'ODM');

output

SQL> SELECT grantee FROM dba_role_privs
  2  WHERE granted_role = 'CONNECT' and
  3  grantee NOT IN (
  4  'SYS', 'OUTLN', 'SYSTEM', 'CTXSYS', 'DBSNMP',
  5  'LOGSTDBY_ADMINISTRATOR', 'ORDSYS', 
  6  'ORDPLUGINS', 'OEM_MONITOR', 'WKSYS', 'WKPROXY',
  7  'WK_TEST', 'WKUSER', 'MDSYS', 'LBACSYS', 'DMSYS',
  8  'WMSYS', 'OLAPDBA', 'OLAPSVR', 'OLAP_USER', 
  9  'OLAPSYS', 'EXFSYS', 'SYSMAN', 'MDDATA',
 10  'SI_INFORMTN_SCHEMA', 'XDB', 'ODM');

GRANTEE
------------------------------
WXZX
QUERY
BCKMGR
CALQR2
CHECKDB
MONITOR

6 rows selected.

如果需要恢复,升级完后执行$ORACLE_HOME/rdbms/admin/rstrconn.sql. 该步骤在4.19.

DBA_CONNECT_ROLE_GRANTEES视图允许管理员决定继续使用旧的connect角色以列出哪些用户具有connect的角色。

4.2 确保物化视图已经全部刷新

$ sqlplus '/ as sysdba' 
SQL> select distinct(trunc(last_refresh)) from dba_snapshot_refresh_times; 

SQL> select distinct owner, name mview, master_owner master_owner, last_refresh from dba_mview_refresh_times;

output

SQL> select distinct owner, name mview, master_owner master_owner, last_refresh from dba_mview_refresh_times;

OWNER                          MVIEW                          MASTER_OWNER                   LAST_REFR
------------------------------ ------------------------------ ------------------------------ ---------
QUERY                          A_MERGE_ITEM_EVENT_TYPE        ZJCOMM                         06-JUN-16
QUERY                          BILLING_CYCLE                  ZJCOMM                         06-JUN-16
QUERY                          BSS_ORG                        ZJCOMM                         02-JAN-14
QUERY                          PRODUCT                        ZJCOMM                         06-JUN-16
QUERY                          PRODUCT_OFFER                  ZJCOMM                         06-JUN-16
QUERY                          PRODUCT_OFFER_INSTANCE         ZJCOMM                         06-JUN-16
QUERY                          PRODUCT_OFFER_INSTANCE_DETAIL  ZJCOMM                         06-JUN-16
QUERY                          RATABLE_EVENT_TYPE             ZJCOMM                         06-JUN-16
QUERY                          SERV                           ZJCOMM                         06-JUN-16
QUERY                          SERV_ACCT                      ZJCOMM                         06-JUN-16
QUERY                          SERV_LOCATION                  ZJCOMM                         06-JUN-16

11 rows selected.

4.3 停监听

$ lsnrctl 
LSNRCTL> stop

确认没有要恢复的文件

SQL> select * from v$recover_file;

no rows selected

确认没有数据文件处理备份模式

SQL> select * from v$backup where status!='NOT ACTIVE';

no rows selected

确认没有分布式未决事务

SQL> select * from dba_2pc_pending;

如果有未决事务,处理如下

SQL> select local_tran_id from dba_2pc_pending;
SQL> execute dbms_transaction.purge_lost_db_entry(''); 
SQL> commit;

4.4 禁止批处理的JOB和crontab

4.5 备份DBLINK创建脚本

script

SELECT
'create '||DECODE(U.NAME,'PUBLIC','public ')||'database link '||CHR(10)
||DECODE(U.NAME,'PUBLIC',Null, U.NAME||'.')|| L.NAME||chr(10)
||'connect to ' || L.USERID || ' identified by '''
||L.PASSWORD||''' using ''' || L.host || ''''
||chr(10)||';' TEXT
FROM sys.link$ L,
sys.user$ U
WHERE L.OWNER# = U.USER# ;

output

SQL> col text for a100
SQL> SELECT
  2  'create '||DECODE(U.NAME,'PUBLIC','public ')||'database link '||CHR(10)
  3  ||DECODE(U.NAME,'PUBLIC',Null, U.NAME||'.')|| L.NAME||chr(10)
  4  ||'connect to ' || L.USERID || ' identified by '''
  5  ||L.PASSWORD||''' using ''' || L.host || ''''
  6  ||chr(10)||';' TEXT
  7  FROM sys.link$ L,
  8  sys.user$ U
  9  WHERE L.OWNER# = U.USER# ;

TEXT
----------------------------------------------------------------------------------------------------
create database link
QUERY.DB_ACCT
connect to ZJQUERY identified by '7PR-_5rx' using 'sjzzw_zj'
;

create database link
QUERY.DB_BILL
connect to ZJQUERY identified by 'JQ_0906Y' using 'sjzjf_zj'
;


2 rows selected.

4.6 确认SYS、SYSTEM用户处于自已的表空间

SQL> select username, default_tablespace from dba_users 
  2  where username in ('SYS','SYSTEM'); 

USERNAME                       DEFAULT_TABLESPACE
------------------------------ ------------------------------
SYSTEM                         SYSTEM
SYS                            SYSTEM

2 rows selected.

如果不是,修改如下

SQL> alter user sys default tablespace SYSTEM; 
SQL> alter user system default tablespace SYSTEM;

4.7 如果启用审计,确认aud$在SYSTEM表空间

SQL> show parameter audit

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
audit_file_dest                      string      ?/rdbms/audit
audit_sys_operations                 boolean     FALSE
audit_trail                          string      NONE
transaction_auditing                 boolean     TRUE

4.8 备份数据库

4.9 检查归档目录剩余大小

4.10 检查NLS_NCHAR_CHARACTERSET

从9i开始,国际字符集(NLS_NCHAR_CHARACTERSET)被限制成只能使用UTF8和AL16UTF16. 其它不被支持了。

SQL> select value from NLS_DATABASE_PARAMETERS where parameter = 'NLS_NCHAR_CHARACTERSET';

VALUE
--------------------------------------------------------------------------------
AL16UTF16

If this is UTF8 or AL16UTF16 then no action is needed.
If is not UTF8 or AL16UTF16 then refer to the following article:

参考:

276914.1 "The National Character Set in Oracle 9i, 10g and 11g"

4.11 修改参数文件

$ sqlplus "/as sysdba"
SQL> create pfile='/ora10g/app/oracle/product/10.2.0/db_1/dbs/initquery.ora' from spfile;
SQL> exit
$ vi /ora10g/app/oracle/product/10.2.0/db_1/dbs/initquery.ora

dump目录

background_dump_dest = /ora10g/app/oracle/admin/query/bdump
core_dump_dest = /ora10g/app/oracle/admin/query/cdump
user_dump_dest = /ora10g/app/oracle/admin/query/udump

去除的废弃参数

log_archive_start = false
max_enabled_roles = 30

修改及添加的参数

*.java_pool_size = 157286400
*.streams_pool_size = 50331648
*.session_max_open_files = 2000 

创建dump目录

$ cd /ora10g/app/oracle
$ ls
oraInventory  product
$ mkdir -p admin/query/bdump
$ mkdir -p admin/query/cdump
$ mkdir -p admin/query/udump

4.12 创建SYSAUX表空间

根据2.2 执行Database Pre-Upgrade Utility执行结果

SQL> CREATE TABLESPACE sysaux DATAFILE '/dev/vgxd02/rlvsysaux' SIZE 1400M REUSE
EXTENT MANAGEMENT LOCAL
SEGMENT SPACE MANAGEMENT AUTO
ONLINE;

4.13 复制SQL*Net文件、密码文件到新环境

$ cd $ORACLE_HOME/network/admin                                                                                                 
$ cp *.ora /ora10g/app/oracle/product/10.2.0/db_1/network/admin/
$ cd $ORACLE_HOME/dbs
$ cp orapwquery /ora10g/app/oracle/product/10.2.0/db_1/dbs/

4.14 再次执行utlu102i并检查输出

SQL> spool utlu102i_new.out
SQL> @utlu102i_2
SQL> spool off

4.15 停库并启动upgrade并执行升级

$ sqlplus "/ as sysdba"
SQL> shutdown immediate
SQL> exit

. /ora10g/.profile10g
cd /oracle9i/script
$ sqlplus "/ as sysdba"
SQL> create spfile from pfile;
SQL> startup upgrade
SQL> spool upgrade.log
SQL> @?/rdbms/admin/catupgrd.sql
SQL> spool off

4.16 检查升级后状态

SQL> set linesize 120
SQL> column comp_name format a40
SQL> select comp_name, status, version from dba_registry;

COMP_NAME                                STATUS                 VERSION
---------------------------------------- ---------------------- ------------------------------
Oracle XML Database                      VALID                  10.2.0.5.0
Spatial                                  VALID                  10.2.0.5.0
Oracle interMedia                        VALID                  10.2.0.5.0
Oracle Database Catalog Views            VALID                  10.2.0.5.0
Oracle Database Packages and Types       VALID                  10.2.0.5.0
Oracle Real Application Clusters         INVALID                10.2.0.5.0
JServer JAVA Virtual Machine             VALID                  10.2.0.5.0
Oracle XDK                               VALID                  10.2.0.5.0
Oracle Database Java Packages            VALID                  10.2.0.5.0

9 rows selected.

4.17 关库并启动到restrict模式,执行utlu102s.sql、utlrp.sql

SQL> shutdown immediate
SQL> startup restrict
SQL> @?/rdbms/admin/utlu102s.sql TEXT
.
Oracle Database 10.2 Upgrade Status Utility           06-07-2016 12:15:31
.
Component                                Status         Version  HH:MM:SS
Oracle Database Server                    VALID      10.2.0.5.0  00:12:17
JServer JAVA Virtual Machine              VALID      10.2.0.5.0  00:00:00
Oracle XDK                                VALID      10.2.0.5.0  00:00:00
Oracle Database Java Packages             VALID      10.2.0.5.0  00:00:00
Oracle XML Database                       VALID      10.2.0.5.0  00:00:00
Oracle Real Application Clusters        INVALID      10.2.0.5.0  00:00:00
Oracle interMedia                         VALID      10.2.0.5.0  00:00:00
Spatial                                   VALID      10.2.0.5.0  00:06:05
.
Total Upgrade Time: 00:21:12

PL/SQL procedure successfully completed.

SQL> @?/rdbms/admin/utlrp.sql

4.18 检查失效对象并对比invalid_pre.lst

script

spool invalid_post.lst
set echo on
set lines 200 pages 100
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 substr(owner,1,12) owner,
substr(object_name,1,30) object,
substr(object_type,1,30) type, status
from dba_objects
where status <> 'VALID'
order by owner, type;
spool off;
set echo off;

NOTE: If you have upgraded from version 9.2 to version 10.2 and find that the following views are invalid, the views can be safely ignored (or dropped):

SYS.V_$KQRPD
SYS.V_$KQRSD
SYS.GV_$KQRPD
SYS.GV_$KQRSD

处理部分失效对象
删除statspack

SQL> select owner,table_owner,table_name from dba_synonyms where synonym_name='STATS$ENQUEUESTAT';

OWNER                          TABLE_OWNER                    TABLE_NAME
------------------------------ ------------------------------ ------------------------------
PUBLIC                         PERFSTAT                       STATS$ENQUEUESTAT

1 row selected.

SQL> @?/rdbms/admin/spdrop.sql

SQL> drop public synonym STATS$ENQUEUESTAT;

Synonym dropped.

install Csscan

SQL> set TERMOUT ON
SQL> set ECHO ON
SQL> spool csminst.log
SQL> @?/rdbms/admin/csminst.sql

sqlplus "/as sysdba"
SQL> alter user csmig account lock;

处理oracle_ocm

Errors in file /ora10g/app/oracle/admin/query/bdump/query_j008_2998.trc:
ORA-12012: error on auto execute of job 54663
ORA-04068: existing state of packagesORA-04068: existing state of packages has been discarded
ORA-04065: not executed, altered or dropped stored procedure "PUBLIC.UTL_FILE"
ORA-06508: PL/SQL: could not find program unit being called: "PUBLIC.UTL_FILE"
ORA-06512: at "ORACLE_OCM.MGMT_DB_LL_METRICS", line 2275
ORA-04065: not executed, altered or dropped stored procedure "PUBLIC.UTL_FILE"
ORA-06508: PL/SQL: could not find program unit being called: "PUBLIC.UTL_FILE"
ORA-06512: at line 1
 has been discarded

参考:

"ORA-12012: error on auto execute of job ORACLE_OCM.MGMT_CONFIG_JOB_2_1" And "ORA-29280: invalid directory path" In Database AlertLog (文档 ID 1615561.1)

connect as sysdba

SQL> @?/rdbms/admin/ocmjb10.sql
SQL> @?/rdbms/admin/execocm.sql

Depending on OCM and/or Oracle Databases releases the scripts location may change.

Example:

SQL> @ORACLE_HOME/rdbms/admin/ocmjb10.sql
SQL> @ORACLE_HOME/rdbms/admin/execocm.sql

其他一些参考文档:

How to Diagnose Invalid or Missing Data Dictionary (SYS) Objects (文档 ID 554520.1)
Master Note for Oracle XML Database (XDB) Install / Deinstall (文档 ID 1292089.1)
Invalid KU$ Views and CATALOG, CATPROC components after XDB Deinstall in 10.2 (文档 ID 1375280.1)
How To Re-register XML Schemas After XDB Has Been Re-installed? (文档 ID 558834.1)
How To Reload Oracle Spatial Related Information When XML Database (XDB) Has Been Reinstalled (文档 ID 1180293.1)
Invalid Object KUPW$WORKER In The Database After Upgrade (文档 ID 394569.1)
Invalid x_$ Objects After Upgrade (文档 ID 361757.1)

4.19 重新赋予connect角色缺少的权限

SQL> @?/rdbms/admin/rstrconn
SQL> Rem
SQL> Rem $Header: rstrconn.sql 10-aug-2004.14:24:52 pthornto Exp $
SQL> Rem
SQL> Rem rstrconn.sql
SQL> Rem
SQL> Rem Copyright (c) 2004, Oracle. All rights reserved.
SQL> Rem
SQL> Rem    NAME
SQL> Rem    rstrconn.sql - SQL*Plus script to grant all the
SQL> Rem                   pre-10gR2 privielges back to CONNECT Role.
SQL> Rem
SQL> Rem    DESCRIPTION
SQL> Rem    This script should be run by a user who is a SYSDBA or has the
SQL> Rem    DBA role granted to them.
SQL> Rem
SQL> Rem    NOTES
SQL> Rem    By default, 10gR2 and higher only grants CREATE SESSION
SQL> Rem    to CONNECT. This script can be used to restore
SQL> Rem    pre-10GR2 CONNECT privileges
SQL> Rem
SQL> Rem    MODIFIED   (MM/DD/YY)
SQL> Rem    pthornto    08/10/04 - pthornto_sqlbsq_connect_deprecate
SQL> Rem    pthornto    08/10/04 - Created
SQL> Rem
SQL> 
SQL> GRANT create session, create table, create view, create synonym,
  2    create database link, create cluster, create sequence, alter session
  3    TO CONNECT;

Grant succeeded.

SQL> commit;

Commit complete.

4.20 重建Oracle Label Security的DML Triggers

只有存在Oracle Label Security组件是才需要执行

SQL> @?/rdbms/admin/olstrig.sql

4.21 收集用户统计信息

vi gath.sh

sqlplus "/ as sysdba" < 100, degree => 4, cascade => true, options => 'GATHER STALE');
exec dbms_stats.gather_database_stats(estimate_percent => 100, degree => 4, cascade => true, options => 'GATHER EMPTY');
exit
EOF

4.21 重启库并启动监听

SQL> alter system set local_listener='(ADDRESS = (PROTOCOL = TCP)(HOST = 132.231.33.215)(PORT = 1521))' scope=both sid='*';

SQL> shutdown immediate
SQL> startup up

$ lsnrctl start

LSNRCTL for HPUX: Version 10.2.0.5.0 - Production on 07-JUN-2016 12:51:22

Copyright (c) 1991, 2010, Oracle.  All rights reserved.

Starting /ora10g/app/oracle/product/10.2.0/db_1/bin/tnslsnr: please wait...

TNSLSNR for HPUX: Version 10.2.0.5.0 - Production
System parameter file is /ora10g/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Log messages written to /ora10g/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=132.231.33.215)(PORT=1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=132.231.33.215)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for HPUX: Version 10.2.0.5.0 - Production
Start Date                07-JUN-2016 12:51:23
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /ora10g/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File         /ora10g/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=132.231.33.215)(PORT=1521)))
Services Summary...
Service "query" has 1 instance(s).
  Instance "query", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

4.22 确认/etc/oratab

没有可参考MOS进行重建:

Find or Create Oratab File (文档 ID 394251.1)

4.23 收集数据字典统计信息

SQL> @check_stale_stats.sql

......

EXEC DBMS_STATS.GATHER_DICTIONARY_STATS('SYS',OPTIONS=>'GATHER STALE', ESTIMATE_PERCENT  => DBMS_STATS.AUTO_SAMPLE_SIZE, METHOD_OPT => 'FOR ALL COLUMNS SIZE AUTO', CASCADE => TRUE);
......

SQL> EXEC DBMS_STATS.GATHER_DICTIONARY_STATS('SYS',OPTIONS=>'GATHER STALE', ESTIMATE_PERCENT  => DBMS_STATS.AUTO_SAMPLE_SIZE, METHOD_OPT => 'FOR ALL COLUMNS SIZE AUTO', CASCADE => TRUE);

PL/SQL procedure successfully completed.

4.24 设置正确的备份连接

4.25 修改profile

$ cp .profile .profile9i
$ cp /ora10g/.profile10g .profile
$ exit
$ pwd                                                                                                                           
/oracle9i
$ echo $ORACLE_BASE
/ora10g/app/oracle

5. 参考文档

Testing an upgrade of a very large 9i Database to 10g and rolling back a failed upgrade back to 9i (文档 ID 883066.1)
Complete Checklist for Manual Upgrades to 10gR2 (文档 ID 316889.1)

你可能感兴趣的:(Oracle 9208 upgrade to 10205 Step By Step)