1 数据库升级到11.2.0.4
Oracle从10g升级到11g详细步骤数据库旧版本:10.2.0.5
数据库新版本:11.2.0.4
OS 版本: IBM 750 6.1
参考文档:Complete Checklist for Manual Upgrades to 11gR2 [ID 837570.1]
1.1 安装软件
$ unzip p13390677_112040_AIX64-5L_1of7.zip
$ unzip p13390677_112040_AIX64-5L_2of7.zip
$ echo $ORACLE_HOME
/n/oracle/product/10.2.0.5/db_1
配置新的ORACLE_HOME为/n/oracle/product/11.2.0.4/db_1
创建新的ORACLE_HOME
cd /n/oracle/product/
mkdir 11.2.0.4
更新.profile文件
$ more .profile
PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/X11:/sbin:.
export PATH
if [ -s "$MAIL" ] # This is at Shell startup. In normal
then echo "$MAILMSG" # operation, the Shell checks
fi # periodically.
export ORACLE_SID=n
export ORACLE_BASE=/n/oracle/product
export ORACLE_HOME=/n/oracle/product/10.2.0.5/db_1
#export ORACLE_HOME=/n/oracle/product/11.2.0.4/db_1
export PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:$ORACLE_HOME/bin:/usr/bin/X11:/sbin:.:/bin:$ORACLE_HOME/OPatch
安装过程
$ ./runInstaller
********************************************************************************
Your platform requires the root user to perform certain pre-installation
OS preparation. The root user should run the shell script 'rootpre.sh' before
you proceed with Oracle installation. rootpre.sh can be found at the top level
of the CD or the stage area.
Answer 'y' if root has run 'rootpre.sh' so you can proceed with Oracle
installation.
Answer 'n' to abort installation and then ask root to run 'rootpre.sh'.
********************************************************************************
Has 'rootpre.sh' been run by root? [y/n] (n)
# ./rootpre.sh
./rootpre.sh output will be logged in /tmp/rootpre.out_18-10-30.11:45:01
Checking if group services should be configured....
Group "hagsuser" does not exist.
Creating required group for group services: hagsuser
Please add your Oracle userid to the group: hagsuser
Configuring HACMP group services socket for possible use by Oracle.
Could not locate group services socket.
Ensure that the group services subsystem is active.
Aborting pre-installation procedure. Installations of Oracle may fail.
上述问题进行处理:
# chdev -l sys0 -a maxuproc=2047
这里对软件的安装就不详细说明了,可以参考相应的文档。
这里需要注意的是:如果你想在11gr2上打上最新的PSU或CPU,可以先在软件级别上打上PSU或CPU,这样就不用跑两次catbundle.sql,减少停机时间。
- 软件安装目录指定到新的ORACLE_HOME
- 关闭nbu备份
- 初步检查
- 在升级之前,确保所有的组件和对象都是valid:
set lines 120
col comp_name for a40
col status for a10
col version for a20
select substr(comp_name,1,40) comp_name, status, substr(version,1,10) version from dba_registry order by comp_name; --针对组件
select owner,object_type,count(*) from dba_objects where status='INVALID' group by
owner,object_type order by owner,object_type;如果有invalid的对象,运行utlrp.sql重新编译对象。
1 记录无效对象用户对象数量。
2 创建表存储无效对象owner以及无效对象type以及名称,以便升级完成后进行对照。
- 确保sys和system下没有重复的对象:
set lines 120
col object_name for a30
col object_type for a15
select object_name, object_type from dba_objects where object_name||object_type in (select object_name||object_type from dba_objects where owner = 'SYS') and owner = 'SYSTEM';
如果有其它记录返回,则必须根据下面这篇文档把重复记录删除:
How to Clean Up Duplicate Objects Owned by SYS and SYSTEM Schema [ID 1030426.6]
- 升级预检查
从11gR2的Oracle Home下拷贝以下文件至一个临时文件夹
drop user dvsys; cd /nmmp/oracle/product/11.2.0.4/db_1/rdbms/admin cp utlu112i.sql /nmmp/oracle/product/10.2.0.5/db_1/rdbms/admin 登陆数据库,运行:(老home下sqlplus命令0) $ sqlplus '/ as sysdba' spool upgrade_info11.2.log @?/rdbms/admin/utlu112i.sql spool off |
生成的upgrade_info.log里的内容很重要,后续步骤要根据该文件的内容做相应的修改,因此一定要保留下来。分析日志:
$ sqlplus / as sysdba SQL*Plus: Release 10.2.0.5.0 - Production on Tue Oct 30 13:01:05 2018 Copyright (c) 1982, 2010, Oracle. All Rights Reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> spool upgrade_info11.2.log SQL> @?/rdbms/admin/utlu112i.sql Oracle Database 11.2 Pre-Upgrade Information Tool 10-30-2018 13:11:18 Script Version: 11.2.0.4.0 Build: 001 ********************************************************************** Database: ********************************************************************** --> name: N --> version: 10.2.0.5.0 --> compatible: 10.2.0.5 --> blocksize: 8192 --> platform: AIX-Based Systems (64-bit) --> timezone file: V4 . ********************************************************************** Tablespaces: [make adjustments in the current environment] ********************************************************************** --> SYSTEM tablespace is adequate for the upgrade. .... minimum required size: 3484 MB --> UNDOTBS1 tablespace is adequate for the upgrade. .... minimum required size: 400 MB --> SYSAUX tablespace is adequate for the upgrade. .... minimum required size: 1244 MB --> TEMP tablespace is adequate for the upgrade. .... minimum required size: 60 MB --> USERS tablespace is adequate for the upgrade. .... minimum required size: 4708 MB . ********************************************************************** Flashback: OFF ********************************************************************** ********************************************************************** Update Parameters: [Update Oracle Database 11.2 init.ora or spfile] Note: Pre-upgrade tool was run on a lower version 64-bit database. ********************************************************************** --> If Target Oracle is 32-Bit, refer here for Update Parameters: -- No update parameter changes are required. --> If Target Oracle is 64-Bit, refer here for Update Parameters: -- No update parameter changes are required. . ********************************************************************** Renamed Parameters: [Update Oracle Database 11.2 init.ora or spfile] ********************************************************************** -- No renamed parameters found. No changes are required. . ********************************************************************** Obsolete/Deprecated Parameters: [Update Oracle Database 11.2 init.ora or spfile] ********************************************************************** -- No obsolete parameters found. No changes are required .
********************************************************************** 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 [upgrade] VALID --> Oracle XDK for Java [upgrade] VALID --> Oracle Workspace Manager [upgrade] VALID --> OLAP Analytic Workspace [upgrade] VALID --> OLAP Catalog [upgrade] VALID --> Oracle Database Vault [upgrade] ... To successfully upgrade Oracle Database Vault, choose ... 'Select Options' in Oracle installer and then select ... Oracle Label Security. –dvsys用户
drop user dvsys; --> EM Repository [upgrade] VALID --> Oracle Text [upgrade] VALID --> Oracle XML Database [upgrade] VALID --> Oracle Java Packages [upgrade] VALID --> Oracle interMedia [upgrade] VALID --> Spatial [upgrade] VALID --> Data Mining [upgrade] VALID --> Expression Filter [upgrade] VALID --> Rule Manager [upgrade] VALID --> Oracle OLAP API [upgrade] VALID . ********************************************************************** Miscellaneous Warnings ********************************************************************** WARNING: --> Database is using a timezone file older than version 14. .... After the release migration, it is recommended that DBMS_DST package .... be used to upgrade the 10.2.0.5.0 database timezone version .... to the latest version which comes with the new release. WARNING: --> Database contains INVALID objects prior to upgrade. .... The list of invalid SYS/SYSTEM objects was written to .... registry$sys_inv_objs. .... The list of non-SYS/SYSTEM objects was written to .... registry$nonsys_inv_objs. .... Use utluiobj.sql after the upgrade to identify any new invalid .... objects due to the upgrade. .... USER AUTHDB has 2 INVALID objects. .... USER NETMAINTAIN has 34 INVALID objects. .... USER DW_REPROTACCOUNT has 3 INVALID objects. .... USER NETMAINTAINNEW has 119 INVALID objects. .... USER CMUSER has 5 INVALID objects. .... USER ZSYW has 1 INVALID objects. WARNING: --> EM Database Control Repository exists in the database. .... Direct downgrade of EM Database Control is not supported. Refer to the .... Upgrade Guide for instructions to save the EM data prior to upgrade. WARNING: --> Your recycle bin contains 206442 object(s). .... It is REQUIRED that the recycle bin is empty prior to upgrading .... your database. The command: PURGE DBA_RECYCLEBIN .... must be executed immediately prior to executing your upgrade. WARNING: --> JOB_QUEUE_PROCESS value must be updated .... Your current setting of "0" is too low.
.... Starting with Oracle Database 11g Release 2 (11.2), setting .... JOB_QUEUE_PROCESSES to 0 causes both DBMS_SCHEDULER and .... DBMS_JOB jobs to not run. Previously, setting JOB_QUEUE_PROCESSES .... to 0 caused DBMS_JOB jobs to not run, but DBMS_SCHEDULER jobs were .... unaffected and would still run. This parameter must be updated to .... a value greater than 16 (default value is 1000) prior to upgrade. .... Not doing so will affect the running of utlrp.sql after the upgrade . ********************************************************************** Recommendations ********************************************************************** Oracle recommends gathering dictionary statistics prior to upgrading the database. To gather dictionary statistics execute the following command while connected as SYSDBA:
EXECUTE dbms_stats.gather_dictionary_stats;
********************************************************************** Oracle recommends reviewing any defined events prior to upgrading.
To view existing non-default events execute the following commands while connected AS SYSDBA: Events: SELECT (translate(value,chr(13)||chr(10),' ')) FROM sys.v$parameter2 WHERE UPPER(name) ='EVENT' AND isdefault='FALSE'
Trace Events: SELECT (translate(value,chr(13)||chr(10),' ')) from sys.v$parameter2 WHERE UPPER(name) = '_TRACE_EVENTS' AND isdefault='FALSE'
Changes will need to be made in the init.ora or spfile.
********************************************************************** |
从下面这篇文档里可以下载到脚本dbupgdiag.sql:
Script. to Collect DB Upgrade/Migrate Diagnostic Information (dbupgdiag.sql) [ID 556610.1]
运行这个脚本:
scp dbupgdiag.sql zhzydb@10.228.248.46:/export/home/zhzydb/up11.2 cd /export/home/zhzydb/up11.2 $ sqlplus / as sysdba sql> alter session set nls_language='American'; SQL> @dbupgdiag.sql Enter location for Spooled output: Enter value for 1: /export/home/zhzydb/up11.2 |
如果该脚本报告有invalid对象,运行以下命令重编译无效对象:
$ cd $ORACLE_HOME/rdbms/admin $ sqlplus "/ as sysdba" SQL> @utlrp.sql |
从10.2开始,CONNECT角色的权限变少了,所以如果你是从10.2之前升级到11g的话,升级之后,需要重新授予缺少的权限,但是如果是从10.2及之后升级到11g的话,就不需要重新赋权限了,本例是从10.2.0.4升级到11g的,因此不需要该步骤。
生成重建dblink的脚本,以防万一数据库需要降级。和Step 4一样,本例是从10.2.0.4升级到11g的,因此不需要该步骤。
orachk检查
解压新版本的orachk安装包,执行如下命令 cd hs ./orachk -u -o pre |
- Timezone检查
检查Timezone版本,主要参考:
Actions For DST Updates When Upgrading To Or Applying The 11.2.0.2 Patchset [ID 1201253.1]
注意:11g的软件里已经自带了版本1-14的Timezone。
先检查一下当前timezone版本:
SQL> conn / as sysdba Connected. SQL>SELECT version FROM v$timezone_file;
|
根据当前timezone的版本,又分三种情况:
1)等于14:这已经是11g需要的版本了,所以升级前后都不需要做任何事,这种情况很罕见。
2)高于14:升级前,必须得给11g软件打上该timezone版本的DST补丁,这种情况也很罕见。
3)低于14:大多数都是这种情况,在升级前不需要在11g软件层面打补丁,在升级后需要再数据库层面将Timezone升级至14,具体看后面的步骤
- 国家字符集检查
检查国家字符集是否是UTF8或AL16UTF16:
SQL> select value from NLS_DATABASE_PARAMETERS where parameter = 'NLS_NCHAR_CHARACTERSET';
|
如果是,则什么都不用做;如果不是,那你就惨了,跟着下面长长的这篇文档一步一步做吧:
The National Character Set ( NLS_NCHAR_CHARACTERSET ) in Oracle 9i, 10g and 11g [ID 276914.1]
- 收集数据字典统计信息
收集统计信息,以减少停机时间。
$ sqlplus "/as sysdba" SQL> EXEC DBMS_STATS.GATHER_DICTIONARY_STATS; SQL>purge dba_RECYCLEBIN; --较少升级时间 |
- 是否开启Valut及其他检查
如果你有开启Vault,那么你需要先在11gR2软件下禁用Vault,等升级结束后,再启用Vault,否则会在升级过程中报错。
select * from v$option where parameter like '%Vault%'; -- force未开启
备份Enterprise Manager Database Control Data,因为本例并没有使用EM,所以不需要该步骤。
配置网络ACL's,在本例中不需要配置。
- 脚本Analyze执行
使用以下语句生产分析数据字典的脚本 (as sysdba):
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 |
确保所有的snapshot都已被成功刷新,且replication已被关闭:
SELECT DISTINCT(TRUNC(last_refresh)) FROM dba_snapshot_refresh_times; |
- 数据文件状态检查
确保当前没有文件需要介质恢复:
SELECT * FROM v$recover_file; SELECT * FROM v$backup WHERE status != 'NOT ACTIVE';
|
上面语句没有返回结果才是正确的。
- 6.2.9 分布式事务检查
解决分布式事务。
先查询是否还有分布式事务:
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; |
- 6.2.10 检查standby
检查是否有Standby数据库存在:
SELECT SUBSTR(value,INSTR(value,'=',INSTR(UPPER(value),'SERVICE'))+1) FROM v$parameter WHERE name LIKE 'log_archive_dest%' AND UPPER(value) LIKE 'SERVICE%';
|
如果有返回结果,则在升级之前,要保证Standby和Primary是处于同步的状态。
禁用所有的batch和cron jobs ddl before/after 用户trigger,用户schema jobs
- 6.2.11 用户SYS和SYSTEM表空间
确保用户SYS和SYSTEM的默认表空间都是SYSTEM:
SQL> SELECT username, default_tablespace FROM dba_users WHERE username in ('SYS','SYSTEM');
|
如果不是,则要用以下语句修改为SYSTEM:
SQL> ALTER user SYS default tablespace SYSTEM; SQL> ALTER user SYSTEM default tablespace SYSTEM; |
- 6.2.12 AUD$检查
确保AUD$表建在SYS用户下和SYSTEM表空间下:
SQL> SELECT owner,tablespace_name FROM dba_tables WHERE table_name='AUD$';
|
如果不是,则要做相应的修改。
- 6.2.13 SSL用户检查
检查是否有外部认证的SSL用户:
SQL> SELECT name FROM sys.user$ WHERE ext_username IS NOT NULL AND password = 'GLOBAL';
|
- 6.2.14 记录数据库文件
记下数据文件、联机日志文件和控制文件的位置:
SQL> SELECT name FROM v$controlfile; SQL> SELECT file_name FROM dba_data_files; SQL> SELECT group#, member FROM v$logfile; 且备份listener.ora, tnsnames.ora, sqlnet.ora等文件。 |
- 6.2.16 设置share pool 和java pool
在执行catupgrd脚本过程中可能由于system表空间不足或者share以及java pool不足导致ORA-29554报错
- 6.2.17 修改oratab文件
可能dbua不能似乎别到instance,可以修改/var/opt/oracle/oratab文件。(10G环境)
1 开启闪回功能,创建闪回点RP1
SQL> set lines 120 SQL> show parameter db_recover
NAME TYPE VALUE ------------------------------------ -------------------------------- ------------------------------ db_recovery_file_dest string db_recovery_file_dest_size big integer 0 SQL> alter system set db_recovery_file_dest='/zhzydb/oracle/data3[A1] '; SQL>alter system set db_recovery_file_dest_size=100G; SQL> shutdown immediate; SQL> startup mount; SQL> alter database flashback on; SQL> alter database open; SQL> drop restore point rp1; SQL> drop restore point rp2; SQL> create restore point rp1; SQL> create restore point rp2;[C2] |
经典案例ORA-38792/ORA-38880
在10g环境flashback的话报错
ORA-38792: encountered unknown flashback record from release 11.0.0.0.0, |
提前修改参数的话报错:
新实例的初始参数中必须COMPATIBLE ='10.2.0.5.0',否则会报ORA-38880: Cannot advance compatibility from 10.2.0.5.0 to 11.2.0.0.
1在进行10.2到11.2的升级过程中,对于11.2环境下采用startup upgrade方式打开数据库中,如果参数文件中compatible参数设置为11.2.0.4, 则控制文件变成11.2.0.4,原来的10G home将无法打开[C3] ???
旧ORACLE_HOME下创建担保性还原点 SQL> CREATE RESTORE POINT before_upgrade GUARANTEE FLASHBACK DATABASE; 注:必须先开启归档并启用闪回恢复区,预计产生800M左右闪回日志; 新实例的初始参数中必须COMPATIBLE ='10.2.0.5.0',否则会报ORA-38880: Cannot advance compatibility from 10.2.0.5.0 to 11.2.0.0.0 due to guaranteed restore points 在闪回时,必须在新ORACLE_HOME下完成闪回操作,并关闭数据库。 然后才能在旧 ORACLE_HOME下先mount再alter database open resetlogs。 --------------------- |
控制文件版本 >=compatlible参数。 数据库无法打开mount报错
控制文件版本<= compatlible参数,mount成功且控制文件版本提升到compatlible一致
SQL> show parameter db_recover
NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ db_recovery_file_dest string db_recovery_file_dest_size big integer 0 SQL> SQL> alter system set db_recovery_file_dest_size=100g; System altered. SQL> alter system set db_recovery_file_dest='/nmmp/'; System altered. SQL> System altered.
SQL> SHUTDOWN IMMEDIATE; Database closed. Database dismounted. ORACLE instance shut down. SQL> STARTUP MOUNT; ORACLE instance started.
Total System Global Area 7516192768 bytes Fixed Size 2108040 bytes Variable Size 285214072 bytes Database Buffers 7214202880 bytes Redo Buffers 14667776 bytes Database mounted. SQL> ALTER DATABASE FLASHBACK ON;
Database altered.
SQL> ALTER DATABASE OPEN;
|
- 对于关闭的数据库,dbua将把数据库进行启动。
- 调整oratab文件
升级前的检查步骤基本上已经完成了,需要把相关参数改为指向新的11g软件:
$ export ORACLE_HOME=<location of Oracle 11.2> $ export PATH=$ORACLE_HOME/bin:$PATH $ export ORACLE_BASE=<Oracle_Base set during installation> |
接着修改oratab中的内容:
n:/opt/oracle/product/10.2/db_1:N |
步骤如下:
应该选择不配置!
新的密码文件.
升级即可.
- 升级完成后/etc/oratab文件更新。
- 应该选择不配置!升级完成后/etc/oratab文件更新。
- 升级-脚本方式
- 创建pfile
以10g的pfile为模板,并根据生成的upgrade_info.log里的建议,为11g创建一个新的pfile。
create pfile='/export/home/zhzydb/up11.2/pfiletmp.ora' from spfile; vi pfiletmp.ora *.diagnostic_dest=’ /nmmp/oracle/product’ --ORACLE_BASE 用此版本加入参数时发现启动过程中总是发现过期参数,直接办法从现成的11g环境中拷贝参数文件并修改相应的参数值。 删除参数 background_dump_dest user_dump_dest core_dump_dest ----可使用现成的11.2.0.4版本生成pfile进行修改
create pfile='/nmmp/oracle/product/11.2.0.4/db_1/dbs/initn.ora' from spfile; |
- 实施升级
前面所有的一切准备,都是为了这一步能成功执行,先把数据库起到upgrade状态:
$ sqlplus / as sysdba SQL*Plus: Release 10.2.0.5.0 - Production on Thu May 9 11:20:42 2019 Copyright (c) 1982, 2010, Oracle. All Rights Reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> shutdown immediate; $ vi .profile ".profile" 14 lines, 532 characters
PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/X11:/sbin:.
export PATH
if [ -s "$MAIL" ] # This is at Shell startup. In normal then echo "$MAILMSG" # operation, the Shell checks fi # periodically. export ORACLE_SID=n export ORACLE_BASE=/n/oracle/product #export ORACLE_HOME=/n/oracle/product/10.2.0.5/db_1 export ORACLE_HOME=/n/oracle/product/11.2.0.4/db_1 export PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:$ORACLE_HOME/bin:/usr/bin/X11:/sbin:.:/bin:$ORACLE_HOME/OPatch ~ ~$ sqlplus "/ as sysdba" SQL> startup UPGRADE 接着开始跑升级脚本: SQL> set echo on SQL> SPOOL upgrade.log SQL> create table invalid_ob as select * From dba_objects where status='INVALID'; SQL> @catupgrd.sql -1小时 SQL> spool off |
replication_dependency_tracking turned off (no async multimaster replication found) Thu May 09 11:30:06 2019 XDB UNINITIALIZED: XDB$SCHEMA not accessible Thu May 09 11:30:18 2019 Completed: ALTER DATABASE OPEN MIGRATE WARNING: Heavy swapping observed on system in last 5 mins. pct of memory swapped in [2.05%] pct of memory swapped out [0.60%]. Please make sure there is no memory pressure and the SGA and PGA are configured correctly. Look at DBRM trace file for more details. SERVER COMPONENT id=RDBMS: status=VALID, version=11.2.0.4.0, timestamp=2019-05-09 11:59:28 SERVER COMPONENT id=JAVAVM: status=VALID, version=11.2.0.4.0, timestamp=2019-05-09 12:24:51 SERVER COMPONENT id=XML: status=VALID, version=11.2.0.4.0, timestamp=2019-05-09 12:30:39 SERVER COMPONENT id=APS: status=VALID, version=11.2.0.4.0, timestamp=2019-05-09 12:32:07 SERVER COMPONENT id=AMD: status=VALID, version=11.2.0.4.0, timestamp=2019-05-09 12:34:15 SERVER COMPONENT id=EM: status=VALID, version=11.2.0.4.0, timestamp=2019-05-09 13:05:55 SERVER COMPONENT id=CONTEXT: status=VALID, version=11.2.0.4.0, timestamp=2019-05-09 13:10:15 SERVER COMPONENT id=XDB: status=VALID, version=11.2.0.4.0, timestamp=2019-05-09 13:47:58 SERVER COMPONENT id=CATJAVA: status=VALID, version=11.2.0.4.0, timestamp=2019-05-09 13:49:20 SERVER COMPONENT id=ORDIM: status=VALID, version=11.2.0.4.0, timestamp=2019-05-09 14:20:18 SERVER COMPONENT id=SDO: status=VALID, version=11.2.0.4.0, timestamp=2019-05-09 14:47:08 SERVER COMPONENT id=OWM: status=VALID, version=11.2.0.4.0, timestamp=2019-05-09 14:49:35 SERVER COMPONENT id=ODM: status=VALID, version=11.2.0.4.0, timestamp=2019-05-09 14:49:41 SERVER COMPONENT id=EXF: status=VALID, version=11.2.0.4.0, timestamp=2019-05-09 14:51:31 SERVER COMPONENT id=RUL: status=VALID, version=11.2.0.4.0, timestamp=2019-05-09 14:52:41 SERVER COMPONENT id=XOQ: status=VALID, version=11.2.0.4.0, timestamp=2019-05-09 14:55:36 $
系统收集统计信息的方式: SQL> begin 2 dbms_stats.delete_table_stats('SYS', 'OBJ$MIG'); 3 dbms_stats.delete_table_stats('SYS', 'USER$MIG'); 4 dbms_Stats.gather_table_stats('SYS', 'OBJ$MIG', estimate_percent => 100, 5 method_opt=>'FOR ALL COLUMNS SIZE SKEWONLY'); 6 dbms_Stats.gather_table_stats('SYS', 'USER$MIG', estimate_percent => 100, 7 method_opt=>'FOR ALL COLUMNS SIZE SKEWONLY'); 8 end; 9 /
SQL> SQL> shutdown immediate; Database closed. Database dismounted. ORACLE instance shut down. SQL> SQL> SQL> SQL> DOC DOC>####################################################################### DOC>####################################################################### DOC> DOC> The above sql script is the final step of the upgrade. Please DOC> review any errors in the spool log file. If there are any errors in DOC> the spool file, consult the Oracle Database Upgrade Guide for DOC> troubleshooting recommendations. DOC> DOC> Next restart for normal operation, and then run utlrp.sql to DOC> recompile any invalid application objects. DOC> DOC> If the source database had an older time zone version prior to DOC> upgrade, then please run the DBMS_DST package. DBMS_DST will upgrade DOC> TIMESTAMP WITH TIME ZONE data to use the latest time zone file shipped DOC> with Oracle. DOC> DOC>####################################################################### DOC>####################################################################### DOC># SQL> SQL> Rem Set errorlogging off SQL> SET ERRORLOGGING OFF; SQL> SQL> REM END OF CATUPGRD.SQL SQL> SQL> REM bug 12337546 - Exit current sqlplus session at end of catupgrd.sql. SQL> REM This forces user to start a new sqlplus session in order SQL> REM to connect to the upgraded db. SQL> exit Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options $ |
- 状态检查
这个脚本大概持续55分,脚本的最后会自动关闭数据库。升级脚本跑完之后,再跑下面这个脚本,检查数据库状态:
$ sqlplus "/as sysdba" SQL> STARTUP SQL> @?/rdbms/admin/utlu112s.sql . Oracle Database 11.2 Post-Upgrade Status Tool 03-22-2018 14:41:23 . Component Current Version Elapsed Time Name Status Number HH:MM:SS . Oracle Server . VALID 11.2.0.4.0 00:16:13 JServer JAVA Virtual Machine . VALID 11.2.0.4.0 00:11:20 Oracle Workspace Manager . VALID 11.2.0.4.0 00:00:36 OLAP Analytic Workspace . VALID 11.2.0.4.0 00:00:32 OLAP Catalog . VALID 11.2.0.4.0 00:00:45 Oracle OLAP API . VALID 11.2.0.4.0 00:00:23 Oracle Enterprise Manager . VALID 11.2.0.4.0 00:06:30 Oracle XDK . VALID 11.2.0.4.0 00:02:20 Oracle Text . VALID 11.2.0.4.0 00:00:38 Oracle XML Database . VALID 11.2.0.4.0 00:05:31 Oracle Database Java Packages . VALID 11.2.0.4.0 00:00:15 Oracle Multimedia . VALID 11.2.0.4.0 00:03:19 Spatia VALID 11.2.0.4.0 00:04:45 Oracle Expression Filter VALID 11.2.0.4.0 00:00:09 Oracle Rules Manager. VALID 11.2.0.4.0 00:00:08 Final Actions 00:00:55 Total Upgrade Time: 00:54:29 PL/SQL procedure successfully completed. |
如果该报告中包含错误,请查阅相关文档解决,直到没有错误之后,再跑下面的脚本:
执行 Post-Upgrade Status Tool $ORACLE_HOME/rdbms/admin/utlu112s.sql, 它会提供一个关于升级的总结. 它会显示升级后各个数据库组件的状态和各个组件升级花费的时间。任何在升级中碰到的错误也会被列出,这些错误必须得到妥善的处理。 $ sqlplus "/as sysdba" SQL> STARTUP SQL> @utlu112s.sql 运行 $ORACLE_HOME/rdbms/admin 目录下的 catuppst.sql, 完成不需要在数据库处于 UPGRADE 模式下操作的其它升级的动作: SQL> @catuppst.sql 这个脚本可以和 utlrp.sql 并行运行. 在另一个 session 里运行 utlrp.sql 来重新编译剩下的 PL/SQL 和 Java 代码: SQL> @?/rdbms/admin/catuppst.sql TIMESTAMP -------------------------------------------------------------------------------- COMP_TIMESTAMP POSTUP_BGN 2018-03-22 14:42:11 PL/SQL procedure successfully completed. This script will migrate the Baseline data on a pre-11g database to the 11g database. Move BL Data "SYS"."WRH$_FILESTATXS" (0 rows in 0 seconds) Move BL Data "SYS"."WRH$_SQLSTAT" (0 rows in 0 seconds) Move BL Data "SYS"."WRH$_SYSTEM_EVENT" (0 rows in 0 seconds) Move BL Data "SYS"."WRH$_WAITSTAT" (0 rows in 0 seconds) Move BL Data "SYS"."WRH$_LATCH" (0 rows in 0 seconds) Move BL Data "SYS"."WRH$_LATCH_CHILDREN" (0 rows in 0 seconds) Move BL Data "SYS"."WRH$_LATCH_PARENT" (0 rows in 0 seconds) Move BL Data "SYS"."WRH$_LATCH_MISSES_SUMMARY" (0 rows in 0 seconds) Move BL Data "SYS"."WRH$_DB_CACHE_ADVICE" (0 rows in 0 seconds) Move BL Data "SYS"."WRH$_ROWCACHE_SUMMARY" (0 rows in 0 seconds) Move BL Data "SYS"."WRH$_SGASTAT" (0 rows in 0 seconds) Move BL Data "SYS"."WRH$_SYSSTAT" (0 rows in 0 seconds) Move BL Data "SYS"."WRH$_PARAMETER" (0 rows in 0 seconds) Move BL Data "SYS"."WRH$_SEG_STAT" (0 rows in 0 seconds) Move BL Data "SYS"."WRH$_DLM_MISC" (0 rows in 0 seconds) Move BL Data "SYS"."WRH$_SERVICE_STAT" (0 rows in 0 seconds) Move BL Data "SYS"."WRH$_TABLESPACE_STAT" (0 rows in 0 seconds) Move BL Data "SYS"."WRH$_OSSTAT" (0 rows in 0 seconds) Move BL Data "SYS"."WRH$_SYS_TIME_MODEL" (0 rows in 0 seconds) Move BL Data "SYS"."WRH$_SERVICE_WAIT_CLASS" (0 rows in 0 seconds) Move BL Data "SYS"."WRH$_INST_CACHE_TRANSFER" (0 rows in 0 seconds) Move BL Data "SYS"."WRH$_ACTIVE_SESSION_HISTORY" (0 rows in 0 seconds) ... ... ... Completed Moving the Baseline Data ... ... ... ... If there are no Move BL Data messages ... ... above, then there are no renamed ... ... baseline tables in the system. ... ... ... Drop Renamed Baseline Table SYS."WRH$_FILESTATXS_BR" Drop Renamed Baseline Table SYS."WRH$_SQLSTAT_BR" Drop Renamed Baseline Table SYS."WRH$_SYSTEM_EVENT_BR" Drop Renamed Baseline Table SYS."WRH$_WAITSTAT_BR" Drop Renamed Baseline Table SYS."WRH$_LATCH_BR" Drop Renamed Baseline Table SYS."WRH$_LATCH_CHILDREN_BR" Drop Renamed Baseline Table SYS."WRH$_LATCH_PARENT_BR" Drop Renamed Baseline Table SYS."WRH$_LATCH_MISSES_SUMMARY_BR" Drop Renamed Baseline Table SYS."WRH$_DB_CACHE_ADVICE_BR" Drop Renamed Baseline Table SYS."WRH$_ROWCACHE_SUMMARY_BR" Drop Renamed Baseline Table SYS."WRH$_SGASTAT_BR" Drop Renamed Baseline Table SYS."WRH$_SYSSTAT_BR" Drop Renamed Baseline Table SYS."WRH$_PARAMETER_BR" Drop Renamed Baseline Table SYS."WRH$_SEG_STAT_BR" Drop Renamed Baseline Table SYS."WRH$_DLM_MISC_BR" Drop Renamed Baseline Table SYS."WRH$_SERVICE_STAT_BR" Drop Renamed Baseline Table SYS."WRH$_TABLESPACE_STAT_BR" Drop Renamed Baseline Table SYS."WRH$_OSSTAT_BR" Drop Renamed Baseline Table SYS."WRH$_SYS_TIME_MODEL_BR" Drop Renamed Baseline Table SYS."WRH$_SERVICE_WAIT_CLASS_BR" Drop Renamed Baseline Table SYS."WRH$_INST_CACHE_TRANSFER_BR" Drop Renamed Baseline Table SYS."WRH$_ACTIVE_SESSION_HISTORY_BR" ... ... ... Completed the Dropping of the ... ... Renamed Baseline Tables ... ... ... ... If there are no Drop Table messages ... ... above, then there are no renamed ... ... baseline tables in the system. ... ... ...
PL/SQL procedure successfully completed. 692 rows created. Commit complete. Table created. 1 row created. 1 row updated. 1 row updated 692 rows updated. Table dropped Commit complete. 691 rows updated. Commit complete. 691 rows updated. Commit complete. 141 rows updated. Commit complete.
142 rows created. Commit complete. 2206 rows created.
Commit complete. PL/SQL procedure successfully completed.
TIMESTAMP -------------------------------------------------------------------------------- COMP_TIMESTAMP POSTUP_END 2018-03-22 14:42:31 PL/SQL procedure successfully completed. PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.
Generating apply and rollback scripts... Check the following file for errors: /zhzydb/oracle/product/cfgtoollogs/catbundle/catbundle_PSU_TJNRMS_GENERATE_2018Mar22_14_42_36.log Apply script: /zhzydb/oracle/product/11.2.0.4/rdbms/admin/catbundle_PSU_TJNRMS_APPLY.sql Rollback script: /zhzydb/oracle/product/11.2.0.4/rdbms/admin/catbundle_PSU_TJNRMS_ROLLBACK.sql
PL/SQL procedure successfully completed.
Executing script file... SQL> COLUMN spool_file NEW_VALUE spool_file NOPRINT SQL> SELECT '/zhzydb/oracle/product/cfgtoollogs/catbundle/' || 'catbundle_PSU_' || name || '_APPLY_' || TO_CHAR(SYSDATE, 'YYYYMonDD_hh24_mi_ss', 'NLS_DATE_LANGUAGE=''AMERICAN''') || '.log' AS spool_file FROM v$database; SQL> SPOOL &spool_file SQL> exec dbms_registry.set_session_namespace('SERVER')
PL/SQL procedure successfully completed.
SQL> ALTER SESSION SET current_schema = SYS;
Session altered.
SQL> PROMPT Updating registry... Updating registry... SQL> INSERT INTO registry$history 2 (action_time, action, 3 namespace, version, id, 4 bundle_series, comments) 5 VALUES 6 (SYSTIMESTAMP, 'APPLY', 7 SYS_CONTEXT('REGISTRY$CTX','NAMESPACE'), 8 '11.2.0.4', 9 0, 10 'PSU', 11 'Patchset 11.2.0.2.0');
1 row created.
SQL> COMMIT;
Commit complete.
SQL> SPOOL off SQL> SET echo off Check the following log file for errors: /zhzydb/oracle/product/cfgtoollogs/catbundle/catbundle_PSU_TJNRMS_APPLY_2018Mar22_14_42_37.log |
前面的升级脚本是运行在upgrade模式下,该脚本主要是在open模式下做些升级动作,不需要花很多时间。
接着重新编译一下无效对象:
SQL> @?/rdbms/admin/utlrp.sql SQL>@dbupgdiag.sql |
确保数据库是好的。
- 调整timezone
注意:只有当Timezone的版本小于14时,才需要执行该步骤。
主要参考:Updating the RDBMS DST version in 11gR2 (11.2.0.1 and up) using DBMS_DST [ID 977512.1]
1)Timezone升级前的准备工作:
先检查一下当前的timezone版本:
conn / as sysdba SELECT version FROM v$timezone_file; SQL> SELECT version FROM v$timezone_file;
VERSION ---------- 14 --升级完成后自动变成14 SELECT PROPERTY_NAME, SUBSTR(property_value, 1, 30) value FROM DATABASE_PROPERTIES WHERE PROPERTY_NAME LIKE 'DST_%' ORDER BY PROPERTY_NAME; 一个典型的输出是: PROPERTY_NAME VALUE ------------------------------ ------------------------------ DST_PRIMARY_TT_VERSION 4 DST_SECONDARY_TT_VERSION 0 DST_UPGRADE_STATE NONE |
然后开始准备工作:
alter session set "_with_subquery"=materialize; exec DBMS_DST.BEGIN_PREPARE(14); 接着检查准备状态: SELECT PROPERTY_NAME, SUBSTR(property_value, 1, 30) value FROM DATABASE_PROPERTIES WHERE PROPERTY_NAME LIKE 'DST_%' ORDER BY PROPERTY_NAME; |
一个典型的输出是:
PROPERTY_NAME VALUE ------------------------------ ------------------------------ DST_PRIMARY_TT_VERSION 4 DST_SECONDARY_TT_VERSION 14 DST_UPGRADE_STATE PREPARE -- truncate logging tables if they exist. TRUNCATE TABLE SYS.DST$TRIGGER_TABLE; TRUNCATE TABLE sys.dst$affected_tables; TRUNCATE TABLE sys.dst$error_table; -- log affected data set serveroutput on BEGIN DBMS_DST.FIND_AFFECTED_TABLES (affected_tables => 'sys.dst$affected_tables', log_errors => TRUE, log_errors_table => 'sys.dst$error_table'); END; / |
下面的语句都不能有返回结果:
SELECT * FROM sys.dst$affected_tables; SELECT * FROM sys.dst$error_table; SELECT * FROM sys.dst$error_table where ERROR_NUMBER= '1883'; SELECT * FROM sys.dst$error_table where ERROR_NUMBER= '1878'; SELECT * FROM sys.dst$error_table where ERROR_NUMBER not in ('1878','1883'); -- end prepare window, the rows above will stay in those tables. EXEC DBMS_DST.END_PREPARE; -- check if this is ended SELECT PROPERTY_NAME, SUBSTR(property_value, 1, 30) value FROM DATABASE_PROPERTIES WHERE PROPERTY_NAME LIKE 'DST_%' ORDER BY PROPERTY_NAME; 一个典型的输出是: PROPERTY_NAME VALUE ------------------------------ ------------------------------ DST_PRIMARY_TT_VERSION 4 DST_SECONDARY_TT_VERSION 0 DST_UPGRADE_STATE NONE |
2)真正开始升级Timezone
conn / as sysdba shutdown immediate; startup upgrade; set serveroutput on purge dba_recyclebin; TRUNCATE TABLE SYS.DST$TRIGGER_TABLE; TRUNCATE TABLE sys.dst$affected_tables; TRUNCATE TABLE sys.dst$error_table; alter session set "_with_subquery"=materialize; EXEC DBMS_DST.BEGIN_UPGRADE(14); SELECT PROPERTY_NAME, SUBSTR(property_value, 1, 30) value FROM DATABASE_PROPERTIES WHERE PROPERTY_NAME LIKE 'DST_%' ORDER BY PROPERTY_NAME; 一个典型的输出是: PROPERTY_NAME VALUE ------------------------------ ------------------------------ DST_PRIMARY_TT_VERSION 14 DST_SECONDARY_TT_VERSION 4 DST_UPGRADE_STATE UPGRADE 下面这条语句应该没有返回结果: SELECT OWNER, TABLE_NAME, UPGRADE_IN_PROGRESS FROM ALL_TSTZ_TABLES where UPGRADE_IN_PROGRESS='YES'; 重启数据库: shutdown immediate startup 升级相关的table: alter session set "_with_subquery"=materialize; set serveroutput on VAR numfail number BEGIN DBMS_DST.UPGRADE_DATABASE(:numfail, parallel => TRUE, log_errors => TRUE, log_errors_table => 'SYS.DST$ERROR_TABLE', log_triggers_table => 'SYS.DST$TRIGGER_TABLE', error_on_overlap_time => FALSE, error_on_nonexisting_time => FALSE); DBMS_OUTPUT.PUT_LINE('Failures:'|| :numfail); END; / 如果没有错误,则结束升级: VAR fail number BEGIN DBMS_DST.END_UPGRADE(:fail); DBMS_OUTPUT.PUT_LINE('Failures:'|| :fail); END; / 最后一次检查: SELECT PROPERTY_NAME, SUBSTR(property_value, 1, 30) value FROM DATABASE_PROPERTIES WHERE PROPERTY_NAME LIKE 'DST_%' ORDER BY PROPERTY_NAME; 典型输出是: PROPERTY_NAME VALUE ------------------------------ ------------------------------ DST_PRIMARY_TT_VERSION 14 DST_SECONDARY_TT_VERSION 0 DST_UPGRADE_STATE NONE SELECT * FROM v$timezone_file; FILENAME VERSION -------------------- ---------- timezlrg_14.dat 14
|
创建spfile:
SQL> create spfile from pfile; |
- Spfile
$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Thu May 9 16:15:33 2019
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
SQL> create spfile from pfile;
File created.
SQL>startup force |
- 环境变量
环境变量.profile中ORACLE_HOME
- 调整.ora文件
修改listener.ora,使listener执行新的11g Home,然后重新启动listener:
$ cp *.ora $ORACLE_HOME/network/admin/修改listener中ORACLE_HOME值 /nmmp/oracle/product/11.2.0.4/db_1
lsnrctl start |
- 创建密码文件
orapwd file=/nmmp/oracle/product/11.2.0.4/db_1/dbs/orapwn password=tjnmc#2013 Sql>CREATE SPFILE FROM pfile='/export/home/zhzydb/up11.2/pfiletmp.ora'; |
- 调整valut
如果你关闭了Vault,则必须在此步骤重新启用。
Note 453903.1- Enabling and Disabling Oracle Database Vault in UNIX |
- 目录对象确认
SQL> select directory_path from dba_directories;
DIRECTORY_PATH -------------------------------------------------------------------------------- /n/oracle/product/11.2.0.4/db_1/ccr/state /n/oracle/product/admin/n/dpdump/ /n/oracle/product/10.2.0.5/db_1/inventory/ContentsXML /data/expdpbackupnew /n/oracle/product/11.2.0.4/db_1/ccr/state
SQL> drop directory patch_dir; create directory patch_dir as '/n/oracle/product/11.2.0.4/db_1/inventory/ContentsXML'; grant read,write on directory patch_dir to public; |
- 调整参数compatible
$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.4.0 Production on Fri Nov 2 11:24:17 2018 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 SQL> show parameter com
NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ cell_offload_compaction string ADAPTIVE commit_logging string commit_point_strength integer 1 commit_wait string commit_write string compatible string 10.2.0.5 nls_comp string BINARY plsql_v2_compatibility boolean FALSE SQL> alter system set compatible='11.2.0.4' scope=spfile;
System altered.
SQL> startup force ORACLE instance started.
Total System Global Area 7482626048 bytes Fixed Size 2260920 bytes Variable Size 1325400136 bytes Database Buffers 6140461056 bytes Redo Buffers 14503936 bytes Database mounted. Database opened. SQL> |
- 检查确认
SQL> select * from v$version;
set lines 120 col action_time for a40 select to_char(action_time,'yyyy-mm-dd hh24:mi:ss') action_time,action,version from dba_registry_history;
col comp_id for a10 col comp_name for a50 select comp_id,comp_name,version,status from dba_registry;
|
- 更新psu和jvm补丁
1 更新opatch
OPatch patch of version 11.2.0.3.19 for Oracle software releases 11.2.0.x and 18.x (APR 2018) (补丁程序) |
停止监听以及数据库。
lsnrctl stop sqlplus / as sysdba shutdown immediate $ unzip p6880880_112000_AIX64-5L.zip cd $ORACLE_HOME mv OPatch OPatchbak mv OPatch $ORACLE_HOME/ opatch version
|
更新psu
$ unzip p27734982_112040_AIX64-5L.zip
|
Jvm
$ unzip p27923163_112040_AIX64-5L.zip
|
验证:
set line 150 col ACTION_TIME for a30 col ACTION for a8 col NAMESPACE for a8 col VERSION for a10 col BUNDLE_SERIES for a5 col COMMENTS for a20 select * from dba_registry_history;
|
- 十大新特性处理优化
Oracle的任何一个新版本,总是会带来大量引人瞩目的新特性,但是往往在这些新特性引入之初,首先引起的是一些麻烦,因为对于新技术的不了解、因为对于旧环境的不适应,从Oracle产品到技术服务运维,总是要走过一个磨合的长期过程。
请注意:我们并不推荐大家盲目的关闭和摒弃Oracle的新特性,我们建议大家在遇到问题时,做出适合自己的调整。
就此盘点一下 Oracle 11g 中,那些新特性带来的新烦恼,如果有用户准备或者刚刚踏入这个新版本,则可以作为借鉴。
-
- Adaptive direct path read - 自适应的直接路径读
在Oracle Database 11g中有一个新特性,全表扫描可以通过直接路径读的方式来执行(Direct Path Read),这是一个合理的变化,如果全表扫描的大量数据读取是偶发性的,则直接路径读可以避免大量数据对于Buffer Cache的冲击。
可是现实往往是残酷的:在很多业务系统中,全表扫描是普遍存在的常态,将大表的全表扫描全部转化为直接路径读,反而不如Cache在Buffer Cache中效率高,Direct Path Read反而成为了一个严重的负担。
当然对于小表来说,Oracle允许通过Buffer Cache来进行全表扫描,因为这可能更快,也对性能影响不大。小表受到隐含参数:_small_table_threshold 影响。如果表大于 5 倍的小表限制,则自动会使用DPR替代FTS。
如果遇到这个特性的负面影响,可以设置初始化参数: _serial_direct_read 来禁用串行直接路径读,其默认值为AUTO,设置为NEVER时禁用 11g 的自动direct path read的特性。该参数可以动态在实例或会话级别修改,而无需重启实例(可以结合Event 10949设置)。
SQL> alter system set "_serial_direct_read"=auto;
SQL> alter system set "_serial_direct_read"=never;
以下的AWR信息是典型的DPR症状,我们看到Direct Path Read在这个报告中处于最占用DB Time的部分:
如果结合ASH报告更加一目了然,显示全表扫描的SQL,都在以Direct Path Read的方式执行 Table Access Full:
-
- Adaptive Log File Sync - 自适应的Log File Sync
关于 Log File Sync 等待的优化,在Oracle数据库中一直是常见问题,LOG FILE的写出性能一旦出现波动,该等待就可能十分突出。
在Oracle 11.2.0.3 版本中,Oracle 将隐含参数 _use_adaptive_log_file_sync 的初始值设置为 TRUE,由此带来了很多 Log File Sync 等待异常的情况,这个问题虽然由来已久,但是仍然有很多Oracle的用户并不知情。
当前台进程提交事务(commit)后,LGWR需要执行日志写出操作,而前台进程因此进入 Log File Sync 等待周期。
在以前版本中,LGWR 执行写入操作完成后,会通知前台进程,这也就是 Post/Wait 模式;在11gR2 中,为了优化这个过程,前台进程通知LGWR写之后,可以通过定时获取的方式来查询写出进度,这被称为 Poll 的模式,在11.2.0.3中,这个特性被默认开启。这个参数的含义是:数据库可以在自适应的在 post/wait 和 polling 模式间选择和切换。
_use_adaptive_log_file_sync 参数的解释就是: Adaptively switch between post/wait and polling ,正是由于这个原因,带来了很多Bug,反而使得 Log File Sync 的等待异常的高,如果你在 11.2.0.3 版本中观察到这样的表征,那就极有可能与此有关。
在遇到问题是,通常将 _use_adaptive_log_file_sync 参数设置为 False,回归以前的模式,将会有助于问题的解决。
-
- Adaptive Cursor Sharing - 自适应游标共享
Oracle数据库的SQL使用的是共享机制,通过绑定变量可以使Oracle DB 可以为多条SQL 语句共享单个游标,以减少分析SQL 语句所使用的共享内存和CPU资源等。
然而一个执行计划并不总是适用于所有绑定值,为了尽可能生成准确的执行计划,Oracle Database 11g 引入了自适应游标共享的新特性,在执行共享SQL时考虑更多的因素,如果与资源开销相比,使用多个执行计划所带来的收益更重要,则会为使用绑定变量的每条SQL 语句生成多个执行计划。
Adaptive Cursor Sharing 通过自适应游标共享,可以仅针对使用绑定变量的语句智能地共享游标。但是有时候这个特性会使得确定的执行计划变得不稳定,如果你确定系统中无需额外自适应的分析和变更执行计划,或者可能被不稳定的执行计划影响。那么可能需要调整这个特性的使用。
关闭这个特性,可以设置隐含参数:
alter session set"_optimizer_extended_cursor_sharing_rel"=none;
alter session set"_optimizer_extended_cursor_sharing"=none;
alter session set"_optimizer_adaptive_cursor_sharing"=false;
-
- Oracle 11g 密码延迟认证
在 Oracle 11g 中,为了提升安全性,Oracle 引入了『密码延迟验证』的新特性。这个特性的作用是,如果用户输入了错误的密码尝试登录,那么随着登录错误次数的增加,每次登录前验证的时间也会增加,以此减缓可能对于数据库重复的口令尝试攻击。
但是对于正常的系统,由于口令的更改,可能存在某些被遗漏的客户端,不断重复尝试,从而引起数据库内部长时间的 Library Cache Lock的等待,这种情形非常常见。
如果遇到这一类问题,可以通过Event 28401关闭这个特性,从而消除此类影响,以下命令将修改设置在参数文件中:
ALTER SYSTEM SET EVENT ='28401 TRACE NAME CONTEXT FOREVER, LEVEL 1' SCOPE = SPFILE;
出现这类问题非常典型的AWR报告呈现如下,首先在 TOP 5 中,你可能看到显著的 Library Cache Lock 的等待,以下范例来自11.2.0.3.0版本的真实情况:
在这类情况下,时间模型 - Time Model 中会显示如下指标,其中 connection management call elapsed time 占据了主要的DB Time,这个等待直接表明是在建立数据库连接时产生的:
这类问题,在Oracle的11g中是常见和确定的,在MOS上可以找到相应的记录:High 'library cache lock' Wait Time Due to Invalid Login Attempts(1309738.1)此外Oracle 11g开启了密码大小写验证,如果从Oracle 10g升级过来,需要特别的当心这个变化,通过初始化参数SEC_CASE_SENSITIVE_LOGON 可以来控制这个特性。
从Oracle 11.2.0.2版本开始,一个新的隐含参数 - _datafile_write_errors_crash_instance 被引入到数据库中,通过这个参数名就可以了解到其含义:当发生数据文件写错误时,Crash数据库实例。
为什么要引入这个参数呢?这个参数后台解决的是什么问题呢?
我在《数据安全警示录》一书上曾经写过多个案例,在归档模式下当发生文件(非SYSTEM文件)写错误时,Oracle会自动将数据文件离线,这造成了很多灾难,类似的错误日志可能是这样的:
Fri Jan 13 19:32:21 2013
KCF: write/open error block=0xf1fa6 online=1
file=73 /dev/rods_gm05
error=27063 txt: 'IBM AIX RISC System/6000 Error: 22: Invalid argument
Additional information: -1
Additional information: 557056'
Automatic datafile offline due to write error on
file 73: /dev/rods_gm05
鉴于很多用户遇到的困境,Oracle做出了修正,这一修正在MOS上以BUG形式被提交,其内容为:Bug 7691270 Crash the DB in case of write errors (rather than just offline files) 。
在11.2.0.2之前,如果数据库运行在归档模式下,并且写错误发生在非SYSTEM表空间文件,则数据库会将发生错误的文件离线,在从11.2.0.2开始,数据库会Crash实例以替代Offline。注意:在非归档模式下或者SYSTEM遭受错误时,数据库会直接崩溃。
好了,现在答案清楚了:为了解决数据文件损失,离线控制存在的不确定性风险,Oracle引入的 _datafile_write_errors_crash_instance 控制数据库实例直接崩溃。
如果你不能接受这一选择,那么设置参数 _datafile_write_errors_crash_instance 为False。
-
- _optimizer_use_feedback - 优化器的基数反馈
Cardinality Feedback - 基数反馈,是Oracle 11.2中引入的新特性,这个新特性利用SQL执行过程中的信息采集,动态的调整执行计划,以解决统计信息陈旧、无直方图或基于直方图基数计算不准确等情况。
Oracle希望由此提升执行计划的准确性,但是在某些情况下,我们可能遇到SQL 第一次执行性能最好,之后再运行其性能变差的情况。
初始化参数 _optimizer_use_feedback 可以控制这个特性的启用,设置为False关闭了这个特性:
alter system set “_optimizer_use_feedback”=false;
在Oracle 11.2中, 当我们创建一个空表或者空分区时,为了加快创建速度,Oracle并不会立即分配初始段和空间,实际的表段Table Segement被延迟到第一行数据插入时创建。
该功能通过DEFERRED_SEGMENT_CREATION参数启用,默认为TRUE。延迟段创建可以节省空间,加快初始化过程,是面向性能和资源的一个优化。
这个新特性带来的一个问题是,在使用 exp / imp 进行导出导入时,不会包含这些空表,可能导致遗漏对象。
如果觉得这个特性是困扰,可以通过修改参数关闭这个特性:
alter system set deferred_segment_creation=flase sscope=spfile;
在11g中,Oracle的资源管理器缺省被启用,并且时常发挥作用,并可能引发竞争。
你可能在TOP 5事件中看到类似的情景:
有两个参数配合设置,可以在你不需要资源管理器时彻底关闭这个隐含的控制:
SQL> alter system set "_resource_manager_always_off"=true scope=spfile;
SQL> alter system set "_resource_manager_always_on"=false scope=spfile;
-
- _gc_policy_time - RAC集群中的DRM管理
DRM是 Dynamic Resource Management 的简称,意思就是动态资源管理。在Oracle RAC中,所有的数据块(Data block)都有一个实例作为主实例进行管理,叫做Master,Master 负责照看好自己所管辖的data block的状态,包括锁定等,并对跨实例访问进行授权。
如果能随着数据块的访问频繁动态的修改数据块的master节点,那么对应GC的grant message则会大量的减少。基于以上考虑,DRM特性应运而生。但是早期的DRM在进行 re-master的过程中长长带来短时的性能影响,在很多重要环境中,这是不能忍受的。
如果希望关闭DRM这个特性,可以结合设置 _gc_policy_time 和 _gc_undo_affinity :
alter system set "_gc_policy_time" = 0 scope=spfile;
alter system set "_gc_undo_affinity" = false scope=spfile;
-
- cleanup_rollback_entries 、_undo_autotune UNDO的清理和调整
在UNDO的管理中,如何设置保留时间,清理回滚段条目,释放UNDO空间,在高事务率的数据库中非常重要。
_cleanup_rollback_entries - 指定回滚时每次回滚的ENTRIES个数,默认为100,可以设置更高提升回滚速度;
_undo_autotune - 用于自动调整undo retention时间,设置 _undo_autotune=true,则undo_retention不再适用,Oracle会自行决定tuned_undo_retention;
以下设置在需要时对这些特性做出调整:
alter system set "_undo_autotune" = false scope=spfile;
alter system set "_cleanup_rollback_entries" = 1000 scope=spfile;
----关闭对auto space advisor调用
begin dbms_auto_task_admin.disable(client_name => 'auto space advisor', operation => null, window_name => null); end; |
----关闭对sql tuning advisor调用
begin dbms_auto_task_admin.disable(client_name => 'sql tuning advisor', operation => null, window_name => null); end; |
----开启统计信息采集
begin dbms_auto_task_admin.enable(client_name => 'auto optimizer stats collection', operation => null, window_name => null); end; |
停止异常数据库
在启动数据库实例到upgrade模式中,com参数切勿修改为11.2, 在11.2HOME下进行flashback,在10.2HOME下进行resetlogs打开数据库完成回滚。 sqlplus / as sysdba shutdown immediate |
调整/etc/oratab文件,指定到新的10.2.0.5版本。
SQL> alter system set sec_case_sensitive_logon=false;
System altered.
CREATE OR REPLACE TRIGGER logon_denied_to_alert AFTER servererror ON DATABASE DECLARE message VARCHAR2(168); ip VARCHAR2(15); v_os_user VARCHAR2(80); v_module VARCHAR2(50); v_action VARCHAR2(50); v_pid VARCHAR2(10); v_sid NUMBER; v_program VARCHAR2(48); v_session_user VARCHAR2(48); BEGIN IF (ora_is_servererror(1017)) THEN
-- get ip FOR remote connections : IF upper(sys_context('userenv', 'network_protocol')) = 'TCP' THEN ip := sys_context('userenv', 'ip_address'); END IF;
SELECT sid INTO v_sid FROM sys.v_$mystat WHERE rownum < 2; SELECT p.spid, v.program INTO v_pid, v_program FROM v$process p, v$session v WHERE p.addr = v.paddr AND v.sid = v_sid;
v_os_user := sys_context('userenv', 'os_user'); v_session_user := sys_context('userenv', 'session_user'); dbms_application_info.read_module(v_module, v_action);
message := to_char(SYSDATE, 'YYYYMMDD HH24MISS') || ' logon denied from ' || nvl(ip, 'localhost') || ' ' || v_pid || ' ' || v_os_user || ' with ' || v_program || ' – ' || v_module || ' ' || v_action||' connect_user:'||v_session_user;
sys.dbms_system.ksdwrt(2, message);
END IF; END; / |
[A1]size参数以及dest参数恢复原来的值,需要在参数文件pfile中改正.
[C2]如果升级的数据库修改了compatible参数,则强制闪回点将无效无法闪回且报错/
[C3]新HOME下compatible参数千万不好提前修改