使用sid方式直接访问pdb(USE_SID_AS_SERVICE_LISTENER)

联系:手机/微信(+86 17813235971) QQ(107644445)QQ咨询惜分飞

标题:使用sid方式直接访问pdb(USE_SID_AS_SERVICE_LISTENER)

作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]

有些应用,因为特殊原因,需要通过sid来访问数据库,在pdb环境中原则上都是通过服务名访问的,可以通过一定的监听配置实现使用pdb名的sid来访问该pdb
在pdb0中创建u_test用户并授权

[oracle@ora19c:/u01/app/oracle/product/19.3.0/db/network/admin]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Mon Feb 17 22:01:54 2025
Version 19.24.0.0.0

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


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.24.0.0.0

sys@ORA19C 22:01:54> show pdbs;

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB0                           READ WRITE NO
         4 PDBXXX                         MOUNTED
sys@ORA19C 22:01:56> alter session set container=pdb0;

Session altered.

Elapsed: 00:00:00.16
sys@ORA19C 22:02:07> create user u_test identified by oracle;

User created.

Elapsed: 00:00:00.29
sys@ORA19C 22:02:21> grant dba to u_test;

Grant succeeded.

Elapsed: 00:00:00.01

监听的配置和状态

[oracle@ora19c:/home/oracle]$ cat /u01/app/oracle/product/19.3.0/db/network/admin/listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/19.3.0/db/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = ora19c)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )



[oracle@ora19c:/home/oracle]$ lsnrctl status

LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 17-FEB-2025 22:07:12

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ora19c)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date                17-FEB-2025 22:06:39
Uptime                    0 days 0 hr. 0 min. 32 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/19.3.0/db/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/ora19c/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ora19c)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "21b067cbda1dbcd4e0630100007f12b6" has 1 instance(s).
  Instance "ora19c", status READY, has 1 handler(s) for this service...
Service "22394b20557aff3ee0630100007fafe0" has 1 instance(s).
  Instance "ora19c", status READY, has 1 handler(s) for this service...
Service "86b637b62fdf7a65e053f706e80a27ca" has 1 instance(s).
  Instance "ora19c", status READY, has 1 handler(s) for this service...
Service "ora19c" has 1 instance(s).
  Instance "ora19c", status READY, has 1 handler(s) for this service...
Service "ora19cXDB" has 1 instance(s).
  Instance "ora19c", status READY, has 1 handler(s) for this service...
Service "pdb0" has 1 instance(s).
  Instance "ora19c", status READY, has 1 handler(s) for this service...
Service "pdbxxx" has 1 instance(s).
  Instance "ora19c", status READY, has 1 handler(s) for this service...
The command completed successfully

创建pdb0基于服务和sid的tns(pdb0,pdb0_sid)

[oracle@ora19c:/u01/app/oracle/product/19.3.0/db/network/admin]$ cat tnsnames.ora
pdb0 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = ora19c)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = pdb0)
    )
  )
pdb0_sid =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = ora19c)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (sid = pdb0)
    )
  )

[oracle@ora19c:/u01/app/oracle/product/19.3.0/db/network/admin]$ tnsping pdb0

TNS Ping Utility for Linux: Version 19.0.0.0.0 - Production on 17-FEB-2025 22:03:00

Copyright (c) 1997, 2024, Oracle.  All rights reserved.

Used parameter files:
/u01/app/oracle/product/19.3.0/db/network/admin/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = ora19c)(PORT = 1521)) 
(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = pdb0)))
OK (0 msec)
[oracle@ora19c:/u01/app/oracle/product/19.3.0/db/network/admin]$ tnsping pdb0_sid

TNS Ping Utility for Linux: Version 19.0.0.0.0 - Production on 17-FEB-2025 22:03:10

Copyright (c) 1997, 2024, Oracle.  All rights reserved.

Used parameter files:
/u01/app/oracle/product/19.3.0/db/network/admin/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = ora19c)(PORT = 1521))
 (CONNECT_DATA = (SERVER = DEDICATED) (sid = pdb0)))
OK (0 msec)

分别测试pdb0和pdb0_sid访问数据库
测试证明基于服务名的方式可以正常访问pdb,基于sid的方式无法访问pdb

[oracle@ora19c:/home/oracle]$ sqlplus u_test/oracle@pdb0

SQL*Plus: Release 19.0.0.0.0 - Production on Mon Feb 17 22:08:35 2025
Version 19.24.0.0.0

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

Last Successful login time: Mon Feb 17 2025 22:06:11 +08:00

Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.24.0.0.0

u_test@PDB0 22:08:35> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.24.0.0.0
[oracle@ora19c:/home/oracle]$ sqlplus u_test/oracle@pdb0_sid

SQL*Plus: Release 19.0.0.0.0 - Production on Mon Feb 17 22:08:39 2025
Version 19.24.0.0.0

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

ERROR:
ORA-12505: TNS:listener does not currently know of SID given in connect
descriptor


Enter user-name: 
ERROR:
ORA-01017: invalid username/password; logon denied


Enter user-name: 
ERROR:
ORA-01017: invalid username/password; logon denied


SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus

在listener.ora中增加USE_SID_AS_SERVICE_LISTENER = ON,并reload加载
注意:USE_SID_AS_SERVICE_LISTENER 中的LISTENER根据不同的监听名字而发生改变

[oracle@ora19c:/home/oracle]$ cat /u01/app/oracle/product/19.3.0/db/network/admin/listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/19.3.0/db/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = ora19c)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )
USE_SID_AS_SERVICE_LISTENER = ON

[oracle@ora19c:/home/oracle]$ lsnrctl reload

LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 17-FEB-2025 22:12:13

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ora19c)(PORT=1521)))
The command completed successfully

[oracle@ora19c:/home/oracle]$ lsnrctl status

LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 17-FEB-2025 22:13:05

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ora19c)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date                17-FEB-2025 22:06:39
Uptime                    0 days 0 hr. 6 min. 26 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/19.3.0/db/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/ora19c/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ora19c)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "21b067cbda1dbcd4e0630100007f12b6" has 1 instance(s).
  Instance "ora19c", status READY, has 1 handler(s) for this service...
Service "22394b20557aff3ee0630100007fafe0" has 1 instance(s).
  Instance "ora19c", status READY, has 1 handler(s) for this service...
Service "86b637b62fdf7a65e053f706e80a27ca" has 1 instance(s).
  Instance "ora19c", status READY, has 1 handler(s) for this service...
Service "ora19c" has 1 instance(s).
  Instance "ora19c", status READY, has 1 handler(s) for this service...
Service "ora19cXDB" has 1 instance(s).
  Instance "ora19c", status READY, has 1 handler(s) for this service...
Service "pdb0" has 1 instance(s).
  Instance "ora19c", status READY, has 1 handler(s) for this service...
Service "pdbxxx" has 1 instance(s).
  Instance "ora19c", status READY, has 1 handler(s) for this service...
The command completed successfully

尝试tns名字为pdb0和pdb0_sid名字登录数据库
在listener.ora文件中设置了USE_SID_AS_SERVICE_LISTENER = ON之后,基于sid的方式可以直接访问pdb

[oracle@ora19c:/home/oracle]$ sqlplus u_test/oracle@pdb0_sid

SQL*Plus: Release 19.0.0.0.0 - Production on Mon Feb 17 22:12:16 2025
Version 19.24.0.0.0

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

Last Successful login time: Mon Feb 17 2025 22:08:35 +08:00

Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.24.0.0.0

u_test@PDB0 22:12:16> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.24.0.0.0
[oracle@ora19c:/home/oracle]$ sqlplus u_test/oracle@pdb0

SQL*Plus: Release 19.0.0.0.0 - Production on Mon Feb 17 22:12:28 2025
Version 19.24.0.0.0

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

Last Successful login time: Mon Feb 17 2025 22:12:16 +08:00

Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.24.0.0.0

u_test@PDB0 22:12:28> 

ORA-600 [4000] [a]相关bug

联系:手机/微信(+86 17813235971) QQ(107644445)QQ咨询惜分飞

标题:ORA-600 [4000] [a]相关bug

作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]

ORA-600 [4000 ] [a]一般是这样的报错格式,其中[a] Undo segment number,类似错误主要bug以及对应的修复版本列表

Bug Fixed Description
26966120 18.18, 18.3, 19.1 PDML workload reports ORA-7445 [kdmsfree] / ORA-00600 [4000]
16761566 11.2.0.3.9, 11.2.0.3.BP22, 11.2.0.4, 12.1.0.2, 12.2.0.1 Instance fails to start with ORA-600 [4000] [usn#]
13910190 11.2.0.3.BP15, 11.2.0.4, 12.1.0.1 ORA-600 [4000] from plugged in tablespace in Exadata
37173201 Hitting ORA-600 [4000] during shutdown
36440495 19.26 SECURE FILE LOB CAUSING ORA-00600:[4000]
34547607 19.23, 23.4 [TXN MGMT LOCAL] ORA-600 [ktugct: corruption detected] w/ Compression & RAC DB Instances Crash
32800248 19.24, 23.4 DB:DISTRIB: Avoid ORA-600[4000]/ORA-600[4097] in the DB background RECO scenario.
35143304 19.24 consider converting ORA-600 [4000] to pdb-specific assert or soft assert
33343993 19.16 Convert ORA-600 [4000] to PDB Specific Assert and Crash Only the Affected PDB
32156194 19.12 ORA-600 [25027] during the select on x$ktcxb
32765471 aim:ORA-600 [4000] – kccpb_sanity_check
23030488 18.1 ORA-00600 [4000] During First Open of PDB After Undo Mode Switch
22610979 18.1 ORA-00600 [4000] On DB Close of STANDBY Due to MMON Process
21770222 12.2.0.1 ORA-600: [4000] in CDB
21379969 12.2.0.1 ORA-00600 [4000] after a tablespace is transported and plugged into another DB
20427315 12.2.0.1 ORA-600 [4000] While Performing DMLs In Freelist Segment
20407770 12.2.0.1 ORA-00600 [4000] error in CDB and DDL operations in PDBs
19352922 12.2.0.1 IMC: ORA-600[4000] may occur on HCC block
14741727 11.2.0.2.9, 11.2.0.2.BP19, 11.2.0.3.BP12, 11.2.0.3.BP13, 11.2.0.4, 12.1.0.1 Fixes for bug 12326708 and 14624146 can cause problems – backout fix
12619529 11.2.0.3.BP18, 11.2.0.4, 12.1.0.1 ORA-600[kdsgrp1] from SELECT on plugged in tablespace with FLASHBACK
10425010 11.2.0.3, 12.1.0.1 Stale data blocks may be returned by Exadata FlashCache
9145541 11.1.0.7.4, 11.2.0.1.2, 11.2.0.2, 12.1.0.1 OERI[25027]/OERI[4097]/OERI[4000]/ORA-1555 in plugged datafile after CREATE CONTROLFILE in 11g
12353983 11.2.0.1 ORA-600 [4000] with XA in RAC
7687856 11.2.0.1 ORA-600 [4000] from DML on transported ASSM tablespace
2917441 11.1.0.6 OERI [4000] during startup
3115733 9.2.0.5, 10.1.0.2 OERI[4000] / index corruption can occur during index coalesce
2959556 9.2.0.5, 10.1.0.2 STARTUP after an ORA-701 fails with OERI[4000]
1371820 8.1.7.4, 9.0.1.4, 9.2.0.1 OERI:4506 / OERI:4000 possible against transported tablespace
434596 7.3.4.2, 8.0.3.0 ORA-600[4000] from altering storage of BOOTSTRAP$

如何判断数据文件是否处于begin backup状态

联系:手机/微信(+86 17813235971) QQ(107644445)QQ咨询惜分飞

标题:如何判断数据文件是否处于begin backup状态

作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]

在数据库恢复中,经常会遇到由于某种原因对数据库执行了begin backup,但是没有执行end backup,然后导致库无法启动的例子,那么怎么判断当前的库是存在这种情况呢?有两种方法可以对其进行判断:
1. 通过查询v$backup表来确认

SQL> select * from v$version;

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

SQL> select * from v$backup;

     FILE# STATUS                CHANGE# TIME
---------- ------------------ ---------- ------------
         1 NOT ACTIVE         1.1210E+12 09-FEB-25
         2 NOT ACTIVE         1.1210E+12 04-JAN-25
         3 NOT ACTIVE         1.1210E+12 09-FEB-25
         4 NOT ACTIVE         1.1210E+12 09-FEB-25

SQL> alter tablespace users begin backup;

Tablespace altered.

SQL>  select * from v$backup;

     FILE# STATUS                CHANGE# TIME
---------- ------------------ ---------- ------------
         1 NOT ACTIVE         1.1210E+12 09-FEB-25
         2 NOT ACTIVE         1.1210E+12 04-JAN-25
         3 NOT ACTIVE         1.1210E+12 09-FEB-25
         4 ACTIVE             1.1210E+12 09-FEB-25

SQL>  alter tablespace users end backup;

Tablespace altered.

SQL> select * from v$backup;

     FILE# STATUS                CHANGE# TIME
---------- ------------------ ---------- ------------
         1 NOT ACTIVE         1.1210E+12 09-FEB-25
         2 NOT ACTIVE         1.1210E+12 04-JAN-25
         3 NOT ACTIVE         1.1210E+12 09-FEB-25
         4 NOT ACTIVE         1.1210E+12 09-FEB-25

v$backup.status=’ACTIVE’表示该文件处于begin backup状态

2. 通过bbed查看kcvfh.kcvfhsta值
确认所有数据文件都没有处于begin backup状态

SQL> select * from v$backup;

     FILE# STATUS                CHANGE# TIME
---------- ------------------ ---------- ------------
         1 NOT ACTIVE         1.1210E+12 09-FEB-25
         2 NOT ACTIVE         1.1210E+12 04-JAN-25
         3 NOT ACTIVE         1.1210E+12 09-FEB-25
         4 NOT ACTIVE         1.1210E+12 09-FEB-25

list内容列表

[oracle@iZbp11c0qyuuo1gr7j98upZ ~]$ cat /home/oracle/list.txt 
         1 /u01/app/oracle/oradata/xifenfei/system01.dbf
         2 /u01/app/oracle/oradata/xifenfei/sysaux01.dbf
         3 /u01/app/oracle/oradata/xifenfei/undotbs01.dbf
         4 /u01/app/oracle/oradata/xifenfei/users01.dbf

bbed查看kcvfh.kcvfhsta值

[oracle@iZbp11c0qyuuo1gr7j98upZ ~]$ bbed listfile=/home/oracle/list.txt
Password: 

BBED: Release 2.0.0.0.0 - Limited Production on Sun Feb 9 21:20:15 2025

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

************* !!! For Oracle Internal Use only !!! ***************

BBED> set file 1
        FILE#           1

BBED> p kcvfh.kcvfhsta
ub2 kcvfhsta                                @138      0x2004 (KCVFHOFZ)

BBED> set file 2
        FILE#           2

BBED> p kcvfh.kcvfhsta
ub2 kcvfhsta                                @138      0x0004 (KCVFHOFZ)

BBED> set file 3
        FILE#           3

BBED> p kcvfh.kcvfhsta
ub2 kcvfhsta                                @138      0x0004 (KCVFHOFZ)

BBED> set file 4
        FILE#           4

BBED> p kcvfh.kcvfhsta
ub2 kcvfhsta                                @138      0x0004 (KCVFHOFZ)

执行database begin backup

SQL> alter database begin backup;

Database altered.

SQL> select * from v$backup;

     FILE# STATUS                CHANGE# TIME
---------- ------------------ ---------- ------------
         1 ACTIVE             1.1210E+12 09-FEB-25
         2 ACTIVE             1.1210E+12 09-FEB-25
         3 ACTIVE             1.1210E+12 09-FEB-25
         4 ACTIVE             1.1210E+12 09-FEB-25

再次bbed查看kcvfh.kcvfhsta值

BBED> set file 1
        FILE#           1

BBED> p kcvfh.kcvfhsta
ub2 kcvfhsta                                @138      0x2001 (KCVFHHBP)

BBED> set file 2
        FILE#           2

BBED>  p kcvfh.kcvfhsta
ub2 kcvfhsta                                @138      0x0001 (KCVFHHBP)

BBED> set file 3
        FILE#           3

BBED>  p kcvfh.kcvfhsta
ub2 kcvfhsta                                @138      0x0001 (KCVFHHBP)

BBED> set file 4
        FILE#           4

BBED>  p kcvfh.kcvfhsta
ub2 kcvfhsta                                @138      0x0001 (KCVFHHBP)

对于非system文件kcvfh.kcvfhsta=0×0001表示begin backup状态
对于system文件kcvfh.kcvfhsta=0×2001表示begin backup状态

_gc_undo_affinity=FALSE触发ORA-01558

联系:手机/微信(+86 17813235971) QQ(107644445)QQ咨询惜分飞

标题:_gc_undo_affinity=FALSE触发ORA-01558

作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]

最近有客户遭遇非系统回滚段报ORA-01558的故障,类似:ORA-01558: out of transaction ID’s in rollback segment _SYSSMU4_1254879796$,在之前的恢复case中遇到两次system rollback报ORA-01558而不能正常启动的案例.(ORA-01092 ORA-00604 ORA-01558故障处理ORA-01558: out of transaction ID’s in rollback segment SYSTEM),这次是业务回滚段,出来起来相对比较简单,直接重建该回滚段所在undo表空间即可.遭遇该问题的主要原因是由于19c rac中由于禁用drm,设置了_gc_undo_affinity=FALSE参数导致.
gc_undo_affinity_ora-1558


还有一个类似bug,需要注意:Bug 19700135 ORA-600 [4187] when the undo segment wrap# is close to the max value of 0xffffffff,主要影响版本为:
1

关于该bug的描述

ORA-600 [4187] can occur for undo segments where wrap# is close to the max value of 0xffffffff (KSQNMAXVAL).
This normally affects databases with high transaction rate that have existed for a relatively long time.
 
To identify undo segments causing the above error and others that may potentially cause it 
in the future, run the next query:
 
 select b.segment_name, b.tablespace_name 
         ,a.ktuxeusn "Undo Segment Number"
         ,a.ktuxeslt "Slot"
         ,a.ktuxesqn "Wrap#"
   from  x$ktuxe a, dba_rollback_segs b
   where a.ktuxesqn > -429496730 and a.ktuxesqn < 0
       and a.ktuxeusn = b.segment_id;
 
Then drop the undo segments or the undo tablespace from the output above.
 
With this fix in place an error ORA-1558 is eventually produced for the affected undo segment
which still requires dropping the undo segment:
  ORA-1558 "out of transaction ID's in rollback segment %s"
   Cause: All the available transaction id's have been used
   Action: Shutdown the instance and restart using other rollback segment(s),
                then drop the rollback segment that has no more transaction id's.

public授权语句

联系:手机/微信(+86 17813235971) QQ(107644445)QQ咨询惜分飞

标题:public授权语句

作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]

在上一篇文章中写到数据泵迁移导致sys授权丢失(impdp导入数据丢失sys授权问题分析),这次进一步完善在有些系统中,会出现对部分权限授权给public的操作,使用逻辑方式(exp/imp,expdp/impdp)进行迁移,可能会导致这个部分权限丢失,从而使得系统部分功能异常,可以通过类似sql查询出来授权语句,在新库上执行

select 'grant ' || privilege || ' on ' || '"' || OWNER || '"."' ||
       table_name || '"' || ' to ' || grantee || ';' "GRANTS"
  from dba_tab_privs
 where privilege not in ('READ', 'WRITE')
   and table_name not like '%/%'
   and owner not in ('SYSTEM',
                     'WMSYS',
                     'XDB',
                     'CTXSYS',
                     'MDSYS',
                     'EXFSYS',
                     'APEX_030200',
                     'ORDSYS',
                     'ORDPLUGINS',
                     'DBSNMP',
                     'OLAPSYS',
                     'ORDDATA')
   and grantee in ('PUBLIC')
 order by 1;

中文环境显示AR8MSWIN1256(阿拉伯语字符集)

联系:手机/微信(+86 17813235971) QQ(107644445)QQ咨询惜分飞

标题:中文环境显示AR8MSWIN1256(阿拉伯语字符集)

作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]

最近恢复了一个阿拉伯语的Oracle数据库,参见案例:.pzpq扩展名勒索恢复,在客户验证数据的环节,出现了阿拉伯语显示乱码的问题.通过几个方法进行了验证,确认数据恢复没有问题
1. 通过dul工具对于有阿拉伯语的表恢复成文本文件,然后使用阿拉伯编码进行查看(可以正常显示阿拉伯语)
dul-alb


2. 在cmd中设置编码为阿拉伯编码,nls_lang也设置和数据库一致(可以正常显示阿拉伯语)[在win 10 系统中此方法可行,2003 系统依然显示有乱码]
AR8MSWIN1256

chcp-1256

win 10 操作系统显示
alb

win 2003操作系统显示
2003

3.设置了在cmd中设置NLS_LANG=american_america.AR8MSWIN1256,然后启动plsql dev(无法正常显示阿拉伯语【乱码】)
plsql-dev

目前没有找到有效方式使得plsql dev在中文操作系统环境中正常显示阿拉伯语,后续继续关注该问题,如果有新发现及时更新

处理 Oracle 块损坏

联系:手机/微信(+86 17813235971) QQ(107644445)QQ咨询惜分飞

标题:处理 Oracle 块损坏

作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]

本文章介绍了许多类型的错误,很多其他地方也可能引用到本文章。重要的是,您需要知道关于每个坏块的以下信息:

  • 包含坏块的文件的绝对文件编号 (FILE NUMBER)。
    本文中称为“&AFN”。
  • 包含坏块的文件的名称。
    本文中称为“&FILENAME”。
    如果您知道文件编号,但不知道文件名,则可以使用 V$DATAFILE 来获取文件名:

SELECT name FROM v$datafile WHERE file#=&AFN;

如果文件号未显示在 Oracle8i 的 V$DATAFILE 中,且 &AFN 大于 DB_FILES 参数值,则该文件可能是临时文件。在这种情况下,可以使用以下查询找到文件名:

SELECT name FROM v$tempfile WHERE file#=(&AFN – &DB_FILES_value);

  • 文件中坏块的块编号。
    本文中称为“&BL”。
  • 包含受影响块的表空间编号和名称。
    本文中称为“&TSN”(表空间编号)和“&TABLESPACE_NAME”。
    如果您不知道这些信息,请使用以下查询找到它们:

SELECT ts# “TSN” FROM v$datafile WHERE file#=&AFN;
SELECT tablespace_name FROM dba_data_files WHERE file_id=&AFN;

  • 表空间中的坏块大小。
    本文中称为“&TS_BLOCK_SIZE”。

SELECT block_size FROM dba_tablespaces
WHERE tablespace_name =
(SELECT tablespace_name FROM dba_data_files WHERE file_id=&AFN);

对于 Oracle 7、8.0 和 8.1,数据库中所有表空间使用相同的块大小。
对于这些版本,使用命令”SHOW PARAMETER DB_BLOCK_SIZE” 返回的值作为 “ &TS_BLOCK_SIZE”

例如:对于 ORA-1578 错误:

ORA-01578: ORACLE data block corrupted (file # 7, block # 12698)
ORA-01110: data file 22: ‘<path>/<datafilename>.dbf’
那么:

&AFN      为 “22″     (从错误 ORA-1110 部分获得)
&RFN      为 “7″      (从错误 ORA-1578 的”file #”部分获得)
&BL       为 “12698″  (从错误 ORA-1578 的”block #”部分获得)
&FILENAME 为 ‘<path>/<datafilename>.dbf’
&TSN 及其他信息可以从上面提到的 SQL 语句获得

对于其他错误(ORA-600、ORA-1498 等),上述值应由 Oracle Support 提供给您,或从涵盖相关错误的文章中获取。

对于某些错误,如 ORA-1410“invalid ROWID(无效 ROWID)”、ORA-12899“value too large for column(列值过大)”等,未给出损坏的文件/块的详细信息。对于此类情况, Note:869305.1 可以帮助您定位损坏的行。

{go to content}

概述处理坏块的步骤

有多种原因可能导致坏块,包括:

    • 坏的 IO 硬件/固件
    • OS 问题
    • Oracle 问题
    • 对于执行过“UNRECOVERABLE”或“NOLOGGING”操作的数据库进行恢复
      (在这种情况下可能产生 ORA-1578 错误 – 如下方所示)

产生 Oracle 错误的时间点可能要比最初发生任何块损坏的时间点晚得多。

在遇到坏块时,我们通常无从了解根本原因,并且在大多数情况下,当下最迫切的需求是重新启动数据库并使其运行起来,正因如此,本文将介绍用于解决坏块问题的步骤,如下所列:

  1. 确定坏块问题的范围,并确定这些问题是持久性问题还是暂时性问题。

如果问题涉及范围很大,或错误不稳定,则关键在于先识别原因(检查硬件等)。这点很重要,因为如果是底层硬件出现错误,恢复系统便毫无意义。

 

  1. 更换或拆下任何有问题的或可疑的硬件。
  2. 确定哪些数据库对象受到影响。
  3. 选择最合适的数据库恢复/数据抢救选项。

对于上述所有步骤,最好应收集证据并详细记录所采取的措施。本文中的“证据>>”标签列出了应收集的信息,以帮助您识别问题的根本原因。

由于 NOLOGGING 或 UNRECOVERABLE 操作导致的坏块

如果对某个对象执行了 NOLOGGING(或 UNRECOVERABLE)操作,随后又恢复了包含该对象的数据文件,则受到 NOLOGGING 操作影响的数据块将被标记为“坏块”,当您访问该数据块时将显示 ORA-1578 错误。
从Oracle8i开始报错ORA-26040(“ORA-26040: Data block was loaded using the NOLOGGING option”),此时原因一目了然,而较早版本中则没有附件这条错误消息。如果坏块是由于对执行过 NOLOGGING 操作的数据文件进行恢复而产生的,则可以使用本文中从  Section 3 “Information to Record for Each Corruption” 开始之后介绍的内容,但请注意以下问题:

 

    1. 恢复操作无法找回受 NOLOGGING 操作影响的数据
    2. 块内的数据无法抢救
    3. 解决方法请参考Note:794505.1


(1) 确定坏块问题的范围

请参考Note 836658.1查找坏块的范围。使用 RMAN或者DBVERIFY 扫描受影响的文件(以及一切重要的文件)也是不错的办法,这样可以检查是否有其他坏块,从而确定问题的范围。有关使用 DBVERIFY 的详细信息,请参阅 Note:35512.1

每次发生坏块错误时,都应记下完整的错误消息,并查看该实例的告警日志和跟踪文件,以了解任何相关的错误。首先进行这些步骤非常重要,这可以评估该损坏是单个块,还是由于 UNRECOVERABLE 操作产生的错误,抑或是更严重的问题。

一旦确定了损坏的文件/块组合列表,即可使用以下步骤来帮助确定应采取何种措施。

证据:

  • 完整记录初始错误,以及发生错误的应用程序的详细信息。
  • 及时地保存从告警日志中首次 (FIRST) 记录到问题前数小时到当前时间点所提取的内容。
  • 保存告警日志中提到的任何跟踪文件。
  • 记录最近遇到的任何 OS 问题。
  • 记录是否正在使用任何特殊功能,例如:ASYNC IO、快速写入磁盘选项等。
  • 记录当前的备份位置(日期、类型等)
  • 记录数据库是否处于 ARCHIVELOG 模式,
    例如:在SQL*Plus(或 Server Manager)中运行“ARCHIVE LOG LIST”

(2) 更换或拆下可疑硬件

大多数坏块问题是由故障硬件导致的。
如果出现硬件错误或可疑组件,最好进行修复,或者在执行恢复操作之前,确保在单独的磁盘子系统上有足够的可用空间用于恢复。

您可以使用以下步骤移动数据文件:

    • 确保要迁移的文件已离线或数据库实例处于 MOUNT 状态(未打开)
    • 将该数据文件物理还原(或复制)到新位置
      例如:/newlocation/myfile.dbf
    • 将该文件的新位置告知 Oracle。
      例如:ALTER DATABASE RENAME FILE ‘/oldlocation/myfile.dbf’ TO ‘/newlocation/myfile.dbf’;
      (请注意,您不能对临时文件进行重命名,而应删除临时文件并在新位置重新创建)

重要信息:  如果存在多个错误(不是由于 NOLOGGING操作导致的)
或 受影响文件所在的 OS 层面出现错误
或 错误是暂时性的且游离不定,
那么,如果不解决底层问题或准备另外的磁盘空间,那么进行任何操作都是毫无意义的。
与硬件供应商联系,以全面检查系统,并联系 Oracle Support,告知所有错误详情。
请注意: 如果硬件检查失败,即表明存在硬件问题,但硬件检查成功通过却并不能证明没有硬件相关问题 — 硬件测试报告成功但确实存在底层错误,这种情况也是经常发生。

如果使用了任何特殊 IO 选项,例如 direct IO、async IO 或类似的选项,最好将其禁用,以消除这些选项成为潜在问题原因的可能性。

(3) 每次坏块需记录的信息

在决定如何恢复之前,最好先确定哪些对象受到了影响,因为坏块可能发生在那些容易被重新创建的对象中。
例如:对于只有 5 行数据的表中发生的坏块,删除并重新创建表可能要比执行恢复快得多。

对于每个坏块,请收集下表中的信息。
进行此操作的步骤如下所述。

针对每次坏块需记录的信息
初始错误 绝对文件号

&AFN

相关文件号 

&RFN

块编号 

&BL

表空间 段类型
所有者.名称
相关对象 恢复选项

下列说明将有助于您针对每个坏块填写此表。

  1.  “初始错误”最初报告的错误。例如:ORA-1578/ORA-1110、ORA-600 和所有参数等。
  2. “绝对文件号”, “相关文件号”和”块号”文件号和块号应该已在错误中显示,或由 Oracle Support 提供,或在指引您参考本文章的其他文章的步骤中提供。
    在 Oracle8/8i/9i/10g 中: 绝对文件号和相关文件号通常是一样的,但也可能不同(尤其是在数据库是由 Oracle7 迁移而来的情况下)。请务必获得正确的 &AFN 和 &RFN 编号,否则您可能最终抢救的是错误的对象!!
    ORA-1578 报告相关文件号,绝对文件号在伴随的 ORA-1110 错误中显示。对于 ORA-600 错误,您应该会被告知绝对文件号。
    下列查询将显示数据库中数据文件的绝对和相关文件号:

SELECT tablespace_name, file_id “AFN”, relative_fno “RFN” FROM dba_data_files;[Insert code here. Use 'Paste from Word' to retain layout.]

在 Oracle8i/9i/10g 中:
除了上述关于 Oracle8 的说明外,从 Oracle8i 开始将拥有临时文件。下列查询将显示数据库中临时文件的绝对和相关文件号:

SELECT tablespace_name, file_id+value “AFN”, relative_fno “RFN” FROM dba_temp_files, v$parameter WHERE name=’db_files’;

在 Oracle7 中: “绝对文件号”和“相关文件号”使用相同的文件号

  1. “段类型”, “所有者”, “名称”和”表空间”
    在给定坏块的绝对文件号“&AFN”和块编号“&B”的情况下,下列查询将显示对象的段类型、所有者和名称,数据库必须打开才能使用此查询:

SELECT * FROM dba_extents
WHERE file_id = &AFN
and &BL between block_id AND block_id + blocks – 1;

  1. 如果坏块位于临时文件中,则上述查询将不会返回任何数据。
    对于临时文件,“段类型”应为“TEMPORARY”。

    如果上述查询未返回行,也可能是因为坏块是本地管理表空间 (Locally Managed Tablespace, LMT) 中的段头。当坏块为 LMT 中的段头块时,上述查询将在 alert.log 中生成一个坏块消息,但查询不会失败。在这种情况下,请使用以下查询:

SELECT owner, segment_name, segment_type, partition_name
FROM dba_segments
WHERE header_file = &AFN
and header_block = &BL;

{go to content}


(4) Which Object is affected and 可能的恢复选项:

相关对象和能够使用的恢复选项取决于 SEGMENT_TYPE。对于各种最常见的段类型,其他查询和可能的恢复选项如下所列。

CACHE
CLUSTER
INDEX PARTITION
INDEX
LOBINDEX
LOBSEGMENT
ROLLBACK
TABLE PARTITION
TABLE
TEMPORARY

IOT
TYPE2 UNDO
Some other Segment Type
“no rows” from the query


CACHE

如果段类型为 CACHE,请再次检查您是否输入了正确的 SQL语句和参数。

解决方法:修复数据块采用块级恢复方法

{Continue}  {Back to Segment List}

CLUSTER

如果段类型为 CLUSTER,则应确定它包含哪些表。

例如:  SELECT owner, table_name fROM dba_tables WHERE owner=’&OWNER’ AND cluster_name=’&SEGMENT_NAME’;

解决方法:
修复数据块采用块级恢复方法

{Collect TABLE information}  {Back to Segment List}

 

INDEX PARTITION

如果段类型为 INDEX PARTITION,请记录名称和所有者,然后确定哪些分区受到影响:

SELECT partition_name
FROM dba_extents
WHERE file_id = &AFN AND &BL BETWEEN block_id AND block_id + blocks – 1

 解决方法:

修复数据块采用块级恢复方法

或者
使用下列语句可以重建索引分区:
ALTER INDEX xxx REBUILD PARTITION ppp;
(请注意下方“重建索引”中所述的 REBUILD 选项)

{Continue}  {Back to Segment List}

INDEX

确定索引位于哪个表中:

SELECT table_owner, table_name
FROM dba_indexes
WHERE owner=’&OWNER’ AND index_name=’&SEGMENT_NAME’;

CONSTRAINT_TYPE 的可能值包括:
-  P    索引支持主键约束。
-  U    索引支持唯一约束。
如果索引支持主键约束(类型“P”),则确认主键是否被任何外键约束引用:

SELECT owner, constraint_name, constraint_type, table_name
FROM dba_constraints
WHERE r_owner=’&TABLE_OWNER’ AND r_constraint_name=’&INDEX_NAME’;

  解决方法:
修复数据块采用块级恢复方法

或  重建索引(任何相关联的约束会随之禁用/启用)
(请注意下方”重建索引“中所述的 REBUILD 选项)。如果对象owner是sys用户,那么请联系oracle技术支持。

{Continue}  {Back to Segment List}

ROLLBACK

如果段类型为 ROLLBACK,请联系 Oracle Support,因为 ROLLBACK 段坏块需要特殊处理。

解决方法:
修复数据块采用块级恢复方法

{Continue}  {Back to Segment List}

TYPE2 UNDO

TYPE2 UNDO 是系统管理的 undo 段,它是 rollback 段的一种特殊形式。这些段的坏块需要特殊处理。

解决方法:
修复数据块采用块级恢复方法

{Continue}  {Back to Segment List}

TABLE PARTITION

如果段类型为 TABLE PARTITION,请记录名称和所有者,然后确定哪些分区受到影响:

SELECT partition_name
FROM dba_extents
WHERE file_id = &AFN
AND &BL BETWEEN block_id AND block_id + blocks – 1;

然后按照处理 TABLE 段的步骤继续下面的操作。

解决方法:

修复数据块采用块级恢复方法

或者
如果所有坏块均位于同一个分区,则此时可以采取的一个做法是用一个空表 EXCHANGE 坏块所在的分区,这可以让应用程序继续运行(无法访问坏块所在的分区中的数据),然后可以从之前的空表中提取任何未损坏的数据。
有关其他选项,请参见下面的 TABLE 选项。

{Continue}  {Back to Segment List}

TABLE

如果所有者为“SYS”,则联系 Oracle Support 并上传所有详细信息。
可能需要恢复数据库。

对于非字典 TABLE 或 TABLE PARTITION,确定表中存在哪些索引:

例如: SELECT owner, index_name, index_type
FROM dba_indexes
WHERE table_owner=’&OWNER’
AND table_name=’&SEGMENT_NAME’;

并确定表中是否存在任何主键:

例如:SELECT owner, constraint_name, constraint_type, table_name
FROM dba_constraints
WHERE owner=’&OWNER’
AND table_name=’&SEGMENT_NAME’
AND constraint_type=’P’;

如果存在主键,则确认它是否被任何外键约束引用:

例如:
SELECT owner, constraint_name, constraint_type, table_name
FROM dba_constraints
WHERE r_owner=’&OWNER’
AND r_constraint_name=’&CONSTRAINT_NAME’;

解决方法:
修复数据块采用块级恢复方法

或者

如果所有者为“SYS”,则联系 Oracle Support 并上传所有详细信息。

对于非字典表,可能的选项包括:
恢复
或  抢救表(或分区)中的数据
然后 重新创建表(或分区)
或  忽略坏块
(例如:使用 DBMS_REPAIR 标记需要跳过的问题块)

{Continue}  {Back to Segment List}

IOT(索引组织表)

IOT 表中的坏块应按照表或分区表中的处理方式来处理。
唯一的例外是如果 PK 损坏。
IOT 表的 PK 就是表本身,它不能被删除和重新创建。

解决方法:
修复数据块采用块级恢复方法  或者 参考下面的“从坏块表中提取坏块周围数据的方法” 来抽取数据。

或者

如果所有者为“SYS”,则联系 Oracle Support 并上传所有详细信息。

对于非字典表,可能的选项包括:
恢复
或  抢救表(或分区)中的数据
然后 重新创建表(或分区)
或  忽略坏块
(DBMS_REPAIR 不适用于 IOT)

{Continue}  {Back to Segment List}

LOBINDEX

确定 LOB 属于哪个表:

SELECT table_name, column_name
fROM dba_lobs
wHERE owner=’&OWNER’
AND index_name=’&SEGMENT_NAME’;

不可以重建 LOB 索引,因此您必须将该问题作为受影响的表中 LOB 列上的坏块来处理。
使用 ”TABLE“ 部分中的 SQL 语句获取包含损坏的 LOB 索引的表的索引和约束信息,然后返回此处。

解决方法

修复数据块采用块级恢复方法

或者

移动LOG 段

alter table &table_owner.&table_with_lob move LOB (&&lob_column) store as (tablespace &tablespace_name);

如果所有者为“SYS”,则联系 Oracle Support 并上传所有详细信息。
{Continue}  {Back to Segment List}

LOBSEGMENT

确定 LOB 属于哪个表:

例如:
SELECT table_name, column_name
FROM dba_lobs
WHERE owner=’&OWNER’
AND segment_name=’&SEGMENT_NAME’;

对于非字典表 …

使用 ”TABLE“ 部分中的 SQL 语句获取包含坏块的 LOB 数据的表的索引和约束信息,然后返回此处查找具体受影响的行的详细信息。

要查找引用损坏的 LOB 块的具体行可能比较困难,因为报告的错误中不会显示表中的哪一行数据包含损坏的 LOB 数据。

Typically one can refer to application logs or any SQL_TRACE or 10046 trace of a session hitting the error (if available) or see if having

event “1578 trace name errorstack level 3″

set in the session helps identify the current SQL/binds/row.

例如:
ALTER SYSTEM SET EVENTS ’1578 trace name errorstack level 3′;

然后等待应用程序触发该错误,并查找跟踪文件。

如果没有任何线索,您可以构建 PLSQL 块,逐行扫描问题表以提取 LOB 列数据,扫描将一直循环进行,直至发生错误。此方法可能需要一段时间,但它应该可以找到引用了损坏的 LOB 块的数据行的主键或 ROWID。

例如:
set serverout on
exec dbms_output.enable(100000);
declare
error_1578 exception;
pragma exception_init(error_1578,-1578);
n number;
cnt number:=0;
badcnt number:=0;
begin
for cursor_lob in
(select rowid r, &LOB_COLUMN_NAME L from &OWNER..&TABLE_NAME)
loop
begin
n:=dbms_lob.instr(cursor_lob.L,hextoraw(‘AA25889911′),1,999999) ;
exception
when error_1578 then
dbms_output.put_line(‘Got ORA-1578 reading LOB at ‘||cursor_lob.R);
badcnt:=badcnt+1;
end;
cnt:=cnt+1;
end loop;
dbms_output.put_line(‘Scanned ‘||cnt||’ rows – saw ‘||badcnt||’ errors’);
end;
/

another script more generic:

set serverout on
exec dbms_output.enable(100000);
declare
pag    number;
len    number;
c      varchar2(10);
charpp number := 8132/2;

begin
for r in (select rowid rid, dbms_lob.getlength (<your_clob_column>) len
from   <your_table_with_clcob_column>) loop
if r.len is not null then
for page in 0..r.len/charpp loop
begin
select dbms_lob.substr (<your_clob_column>, 1, 1+ (page * charpp))
into   c
from   <your_table_with_clcob_column>
where  rowid = r.rid;

exception
when others then
dbms_output.put_line (‘Error on rowid ‘ ||R.rid||’ page ‘||page);
dbms_output.put_line (sqlerrm);
end;
end loop;
end if;
end loop;
end;
/

 解决方法:


可能需要恢复数据库,如果所有者为“SYS”,则联系 Oracle Support 并上传所有详细信息。

对于非字典表,可能的选项包括:

恢复

或者用empty_clob/empty_blob更新lob列,避免在出现ORA-1578;这样可以清理表里面的lob列:

SQL> set concat off
SQL> update &table_owner.&table_with_lob
set &lob_column = empty_blob()
where rowid in (‘list the identified rowids from the table from the plsql above’);

将损坏的lob设置为empty lob后,之前的数据块还会放回这个lob的freelist。这些空间以后可能会被重用,
当这些数据块再次被使用时,会出现ORA-1578 错误,因此在empty lob后,再将lob 段移动到新的段:

alter table &table_owner.&table_with_lob move LOB (&&lob_column) store as (tablespace &tablespace_name);

或  抢救表(及其 LOB 列)中的数据
然后 重新创建表
或  忽略坏块
(不可以在 LOB 段上使用 DBMS_REPAIR)

 

{Continue}  {Back to Segment List}

TEMPORARY

如果段类型为 TEMPORARY,则坏块不会影响永久对象。检查发生问题的表空间是否正在被用作 TEMPORARY 表空间:

SELECT count(*) FROM dba_users WHERE temporary_tablespace=’&TABLESPACE_NAME’;

解决方法:

参考Note 1332088.1

通常情况下,不需要进行任何还原,但如果磁盘可能有问题,且表空间包含有用数据,则最好对数据库中受影响的文件进行恢复。

 

{Continue}  {Back to Segment List}

其他一些段类型

如果返回的段类型未包含在上述类型中,则请联系 Oracle Support 并提供迄今为止收集的所有信息,以获得相关建议。

 

{Continue}  {Back to Segment List}

“无返回行”

如果没有包含坏块的 extent,则首先再次检查查询中使用的参数。如果您确定文件号和块编号是正确的,且不属于 DBA_EXTENTS 中的某个对象,则执行以下操作:

  • 再次检查相关文件是否为临时文件。
    请注意,临时文件的文件号取决于数据库初始化参数 DB_FILES,因此对该参数的任何更改都会改变错误中报告的绝对文件号。
  • DBA_EXTENTS 不包含本地管理表空间中用于本地空间管理的块。
  • 如果您在数据库运行查询语句的时间点与出错的时间点不相同,那么问题对象可能已经被删除,因此针对 DBA_EXTENTS 的查询可能不会显示任何行。
  • 如果您正在调查的错误由 DBVERIFY 报告,则 DBV 将检查所有块,而不管它们是否属于某个对象。因此,坏块可能存在于数据文件中,但却未被任何对象使用。

选项:

未使用的 Oracle 块(出现在dba_free_space的块)上的错误可以忽略,因为如果需要使用该块,oracle会在对这个块做DML操作时格式化。
注意,简单的extent的分配不会格式化这个块,而且DML操作必须去使用或者修改这个块
如果你想手工格式化这个块,你可以参考: How to Format Corrupted Block Not Part of Any Segment Document 336133.1

如果您怀疑该块可能是空间管理块,则可以使用 DBMS_SPACE_ADMIN 包来帮助您进行检查:

exec DBMS_SPACE_ADMIN.TABLESPACE_VERIFY(‘&TABLESPACE_NAME’);

以上命令会将不一致写入跟踪文件,但如果遇到致命的坏块,它将报告如下错误:

ORA-03216: Tablespace/Segment Verification cannot proceed

 

{Continue}  {Back to Segment List}

{go to content}

证据

对于每个坏块,如果需要尝试并确定实际坏块原因,则收集如下物理证据也是一个比较好的方法:

  1. 坏块及位于其任意一侧的块的操作系统 HEX 转储。

    在 UNIX 上:

dd if=&FILENAME bs=&TS_BLOCK_SIZE skip=&BL-1 count=3 of=BL.dd
^^^^^^^^      ^^^^^^^^^^^^^^         ^^^
例如:对于 BL=1224:

dd if=ts11.dbf bs=4k skip=1223 count=3 of=1223_1225.dd
在 VMS 上:

DUMP/BLOCKS=(start:XXXX,end:YYYY)/out=dump.out &FILENAME
其中 XXXX=操作系统块编号(512 字节块中)
要计算此值,用报告的块编号乘以“&TS_BLOCK_SIZE/512”。

  1. 处于 ARCHIVELOG 模式时,复制出错时间前后的归档日志文件的安全副本,最好包括报告错误前数小时的日志文件。并且,保存问题数据文件在出错前的所有副本,因为之前的数据文件映像以及 redo 记录有助于找出错误原因。
    (DBV 通常可用于检查问题是否存在于文件的备份副本中)。理想的情况是获得没有报告坏块的数据文件备份映像,以及从该时间点开始到首次报告坏块时间之后不久的时段内的所有 redo 记录。
  2. 获得问题块的 Oracle 转储:

ALTER SYSTEM DUMP DATAFILE ‘&FILENAME’ BLOCK &BL;

(DUMP将生成到 USER_DUMP_DEST 下的跟踪文件)。

 

{Continue}  {Back to Segment List}

{go to content}

(5) 选择恢复选项

现在,最佳的恢复选项取决于受影响的对象。前面第 (3) 部分中的说明应该已经重点介绍了针对每个受影响对象的主要可用选项。选择的实际恢复方法可能包含以下一种或多种混合方法:

是否需要进行任何恢复操作?

表空间中,或位于不再属于任何数据库对象的块中,则无需进行任何操作,尽管将问题表空间重定位到其他存储设备中可能较为明智。

请参阅警告

可以使用完全恢复吗?

要选用完全恢复,必须满足如下条件:

  • 数据库处于 ARCHIVELOG 模式

(“ARCHIVE LOG LIST”命令显示 Archivelog 模式)

  • 拥有受影响文件的完好备份。请注意,在某些情况下,坏块可能已经存在,但在很长一段时间内未被发现。如果最近的数据文件备份仍包含坏块,那么只要您拥有所 有必需的归档日志,就可以尝试使用更早的备份。
    (通常可以使用 DBV START= / END= 选项来检查位于某个备份文件的恢复副本中的特定块是否损坏)
  • 从备份时间开始到当前时间点的所有归档日志均可用
  • 当前的在线日志均可用且完好无缺
  • 错误不是由运行 NOLOGGING 操作之后执行的恢复所导致的

如果满足上述条件,完全恢复通常是首选方法

*但请注意*

  1. 如果事务回滚已发现坏块位于对象上,而非 rollback 段本身,则 undo 操作可能已被放弃。在这种情况下,可能需要在恢复完成后重建索引/检查数据完整性。
  2. 如果要恢复的文件包含自上次备份以来执行的 NOLOGGING 操作的数据,在使用了数据文件或数据库恢复的情况下,这些块将被标记为“坏块”。在某些情况下,这会使情况更加糟糕。

如果执行数据库恢复后坏块仍然存在,则表示所有备份都包含坏块,底层错误仍存在,或问题通过 redo 重现。在这些情况下,需要选择其他一些恢复选项。

请参阅 “(4A) 完全恢复” ,以了解完全恢复步骤。

{go to content}

如果不需要从对象本身提取任何数据,能否删除或重新创建该对象?

您可以删除对象或从脚本/最近导出的副本重新创建对象。一旦删除一个对象后,该对象中的块将被标记为“空闲”,并且该块在被分配到新对象时将被重新格式化。明智的做法是,对表进行重命名,而不是删除,除非您完全确定不再需要其中的数据。

对于表分区,只需要删除受影响的分区。

例如: ALTER TABLE … DROP PARTITION …

如果坏块影响到分区段头,或者包含分区头的文件处于离线状态,则 DROP PARTITION 可能会失败。在这种情况下,首先将其更换为具有相同定义的表,之后仍然可以删除该分区。

例如: ALTER TABLE .. EXCHANGE PARTITION .. WITH TABLE ..;

最常见的可重建对象为索引。始终在处理表中的索引问题之前处理表坏块。
有关详细信息,请参阅”(4B) 重建索引” 。

对于任何段,如果您拥有坏块的绝对文件号和块号,则可使用以下快速提取对象 DDL 的方法:

set long 64000
select dbms_metadata.get_ddl(segment_type, segment_name, owner)
FROM dba_extents
WHERE file_id=&AFN
AND &BL BETWEEN block_id AND block_id + blocks -1;

{go to content}

是否需要在重新创建对象之前抢救数据?

如果问题位于定期更新的关键应用表上,则可能需要尽可能多地抢救表中数据,然后重新创建该表。

有关详细信息,请参阅”(5C) 抢救表中数据” 。

{go to content}

当前忽略坏块是否可取?

在某些情况下,最直接的选项可能就是忽略坏块,并阻止应用程序对它进行访问。

有关详细信息,请参阅 “(5D) 忽略坏块“。

{go to content}

最后的选项

下列选项是否可行?

将数据库或表空间恢复到较早的时间点(通过时间点恢复)

或还原出现坏块前的冷备份

或使用现有导出文件

有关详细信息,请参阅”(5E) 最后的选项“。

{go to content}

 (5A) 完全恢复

如果数据库处于 ARCHIVELOG 模式下,且您拥有受影响文件的完好备份,则恢复通常为首选方法。
这不保证可以解决问题,但的确可以有效的解决大部分坏块问题。如果恢复再次引发问题,则返回到以上选项列表并选择其他方法。

如果使用的是 Oracle9i(或更高版本),则可以使用 RMAN BLOCKRECOVER 命令执行块级恢复。
如果使用的是较早版本的 Oracle,则可以执行数据文件恢复(数据库其他部分可以继续运行),或数据库恢复(需要关闭数据库)。

如果使用的是 Oracle 11g(或更高版本),则可以使用“Data Recovery Advisor(数据恢复指导)”.

块级恢复

自 Oracle9i 版本起,RMAN 允许恢复单个块,同时数据库的其他部分(包括数据文件中的其他块)仍可以进行正常访问。请注意,块级恢复只能将块完全恢复到当前时间点。

例如:

实际情况是,文件 6 的块 30 上发生 ORA-1578 错误,可能是由于介质问题导致的坏块,且您拥有该文件的完好冷备份映像,并已还原到“…/RESTORE/filename.dbf”。
假设所有归档日志均存在(位于默认位置),则可以通过 RMAN 使用以下命令序列执行块级恢复:

rman nocatalog
connect target
catalog datafilecopy ‘…/RESTORE/filename.dbf’;
run {blockrecover datafile 6 block 30;}

此操作将使用注册的数据文件备份映像和任何需要的归档日志来执行块恢复,仅将有问题的块恢复到当前时间点。

有关 RMAN BLOCKRECOVER 命令和限制的所有详细信息,请参阅文档 Note 144911.1

{go to content}

数据文件恢复

数据文件恢复包括下列步骤。如果有多个文件,则针对每个文件重复执行这些步骤,或参阅下面的“数据库恢复”。当数据库处于 OPEN 或 MOUNTED 状态时,均可使用这些步骤。

使受影响的数据文件离线

例如: ALTER DATABASE DATAFILE ‘name_of_file’ OFFLINE;

将文件复制到安全位置(以防备份损坏)

将文件的最新备份还原到完好的磁盘上

使用 DBVERIFY 检查还原的文件是否有坏块
有关使用 DBVERIFY 的详细信息,请参阅 Note:35512.1

假设还原的文件完好,则将数据文件重命名并保存到新位置(如果不是原来的位置)

例如: ALTER DATABASE RENAME FILE ‘old_name’ TO ‘new_name’;

恢复数据文件

例如: RECOVER DATAFILE ‘name_of_file’;

使数据文件上线

例如: ALTER DATABASE DATAFILE ‘name_of_file’ ONLINE;

{Continue}

{go to content}

数据库恢复

数据库恢复通常包含以下步骤:

关闭数据库(使用选项 immediate 或 abort)

将待恢复的所有文件的当前副本复制到安全位置

将备份文件还原到完好的磁盘上
请勿还原控制文件或在线 REDO 日志文件

使用 DBVERIFY 检查还原的文件。有关使用 DBVERIFY 的详细信息,请参阅 Note:35512.1

启动数据库到MOUNT状态(startup mount)

对任何需要重新定位的数据文件进行重命名

例如: ALTER DATABASE RENAME FILE ‘old_name’ TO ‘new_name’;

确保所有必需的文件在线

例如: ALTER DATABASE DATAFILE ‘name_of_file’ ONLINE;

恢复数据库

例如: RECOVER DATABASE

打开数据库

例如: ALTER DATABASE OPEN;

{go to content}

完全恢复后

一旦执行了完全恢复,最好在允许使用之前先检查数据库:

针对每个问题对象运行:

“ANALYZE <table_name> VALIDATE STRUCTURE CASCADE”

检查表/索引是否存在不匹配。

如果有任何 undo 操作曾被放弃,此命令可能会显示不匹配,此时需要重建索引。

在应用程序级别检查表中数据的逻辑完整性。

{go to content}

(5B) 重建索引

损坏对象为用户索引时,如果底层表没有损坏,则可以删除并重建该索引。
如果底层表也已经损坏,则应在重建任何索引之前先解决该表的坏块。

如果收集的信息表示索引有从属外键约束,则需要执行以下操作:

  • 对于每个外键

ALTER TABLE <table> DISABLE CONSTRAINT <pk_constraint>;

  • 使用以下命令重建主键

ALTER TABLE <table> DISABLE CONSTRAINT <pk_constraint>;
DROP INDEX <index_name>;
CREATE INDEX <index_name> .. with appropriate storage clause
ALTER TABLE <table> ENABLE CONSTRAINT <pk_constraint>;

  • 启用外键约束

ALTER TABLE <child_table> ENABLE CONSTRAINT <fk_constraint>;

对于索引分区,可以执行以下命令:

ALTER INDEX … REBUILD PARTITION …;

注意:

  1. 不要使用“ALTER INDEX ..  REBUILD”命令重建损坏的非分区索引,这一点非常重要,因为此操作通常会尝试从包含坏块的现有索引段中构建新索引。

“ALTER INDEX … REBUILD ONLINE” and “ALTER INDEX … REBUILD PARTITION …”
不会从旧索引段中构建新索引,因此可以使用。

  1. 如果新索引包含的列为现有索引的子集,则 Create INDEX 可以使用现有索引中的数据。因此,如果您有两个损坏的索引,应在重建之前将两个都删除。
  2. 重建索引时,请确保使用正确的存储选项。

{go to content}

(5C) 抢救表中数据

如果损坏的对象为 TABLE 或 CLUSTER 或 LOBSEGMENT,则您必须明白,坏块内的数据已经丢失。
部分数据可能可以从块的 HEX 转储中,或从索引涵盖的列中抢救回来。

重要信息:
由于可能需要从索引中抢救坏块中的数据,因此最好不要删除任何现有索引,直至所有需要的数据提取完成。

从包含坏块的表中提取数据有多种方法。选择最恰当的方法,详细信息如下所述。这些方法的目的是从可访问的表块中提取尽可能多的数据。通常,将损坏的表重命名是一个比较好的方法,这样就可以使用正确的名称创建新对象。

例如: RENAME <emp> TO <emp_corrupt>;

从坏块表中提取坏块周围数据的方法

  1. 从 Oracle 7.2 开始(包括 Oracle 8.0、8.1 和 9i),可以跳过表中的坏块。
    这是到目前为止最简单的提取表数据的方法,此方法在以下文档中做了讨论:

    Extracting data using DBMS_REPAIR.SKIP_CORRUPT_BLOCKS or Event 10231  Note:33405.1
    如果坏块位于 IOT overflow 段,则应使用相同的方法,不同的是使用 Event 10233 和全索引扫描或者在10.2.0.4/10.2.0.5 使用event:43810; 在11g之后,使用参数:_index_scan_check_skip_corrupt=TRUE。请参考文档:Note:1527738.1 中的“SKIP ORA-600 in IOT”部分。

    请注意,此方法只适用于块的“包装”已被标记为“坏块”的情况。例如:如果块报告 ORA-1578 错误。
    如果问题为 ORA-600 或其他非ORA-1578 错误,则通常可以使用 DBMS_REPAIR 将表中坏块标记为“软坏块”。这样在您访问该数据块时,系统将显示 ORA-1578 错误,从而可以使用 DBMS_REPAIR.SKIP_CORRUPT_BLOCKS。

    注意:被“FIX_CORRUPT_BLOCKS”程序标记为“坏块”的块在任何还原/恢复操作之后还将被标记为“坏块”.

    有关使用 DBMS_REPAIR 进行此操作的全部详细信息,请参阅相关文档,但概括起来说,步骤如下:

- 使用 DBMS_REPAIR.ADMIN_TABLES 创建管理表
- 使用 DBMS_REPAIR.CHECK_OBJECT 找到问题块
- 在损坏问题块之前将其中所有完好的数据导出。
- 使用 DBMS_REPAIR.FIX_CORRUPT_BLOCKS 将找到的问题块标记为“坏块”,然后它们就会显示 ORA-1578
- 如果需要,使用 DBMS_REPAIR.SKIP_CORRUPT_BLOCKS 跳过表中的坏块。

  1. 从 Oracle 7.1 开始,可以使用 ROWID 范围扫描。
    此功能的语法较为复杂,但可以使用 ROWID 提示选择坏块周围的数据。
    由于 Oracle7 和 Oracle8 中的 ROWID 格式有所不同,故有两篇文章分别介绍此功能:

    Using ROWID Range Scans to extract data in Oracle8 and higher Note:61685.1
    Using ROWID Range Scans to extract data in Oracle7 Note:34371.1

  2. 如果存在主键,则可以通过此索引选择表数据。
    也可以通过任何其他索引选择一些数据。
    此方法较慢,花费时间较长,通常只有 Oracle 7.0 版本才使用。此方法在 Note:34371.1 中进行了介绍(此外,还介绍了 ROWID 范围扫描)。
  3. 有多种抢救程序/PLSQL 脚本可用于抢救表中的数据。与上述方法相比,这些方法在设置和使用方面需要花费更长的时间,但常常能够处理除 ORA-1578 之外的各类坏块。
    由于这些方法通常需要由技术支持人员给予大量的亲身指导,因此客户可能看不到关于这些方法的部分文章。

    要使用以下程序,需要使用 Pro*C,且需要了解如何构建 Pro*C 可执行文件:

    SALVAGE.PC for Oracle8.1 Note:97357.1

    要使用以下程序,需要手动交互:

    SALVAGE.SQL for Oracle7/8 Note:2064553.4
    SALVAGE.SQL for Oracle7/8 Note:28308.1
    The following is only possible in Oracle8i and 9i. The aim is to mark the block as corrupt and then use the SKIP_CORRUPT table attribute to extract the table data:

    Use DBMS_REPAIR to mark the block corrupt Note:68013.1
    For corruption in a LONG column: Recreating a Table with a corruption in a LONG Note:876493.1

{go to content}

从包含损坏的 LOBSEGMENT 块的表中提取数据的方法

在 LOB 段上不可以使用 DBMS_REPAIR。

如果坏块 LOB 块未被表中的任何行引用,则应该可以使用 CREATE TABLE as SELECT (CTAS) 来按选择创建表,或按原样导出/删除/导入该表。

如果坏块 LOB 块被某个行引用,则应该可以使用不包括问题行的 WHERE 谓词进行选择或导出。

警告:
可以将问题行的 LOB 列值更新为 NULL,从而使 SELECT 操作不再返回ORA-1578 错误 *但是* 坏块将等待被重新使用,随着对行中的 LOB 列进行 INSERT 或 UPDATE 操作,当有问题的块被重新使用时,最后还是会报ORA-1578错误,那时的情况比已知行出现坏块更糟糕。
因此,只有您打算立刻重新创建表,才应该将 LOB 列设为 NULL。

从坏块本身提取数据

由于坏块本身已经“损坏”,则从该块中提取的任何数据都应被视为可疑数据。从坏块本身获取数据行的主要方法包括:

  • 对于 TABLE 的块,Oracle Support 可以使用一款尝试解释块内容的工具。
    “Convert HEX or BLOCKDUMP to Readable form” Note:47419.1
  • 使用表中现有索引,利用落在坏块内的ROWID 来提取索引所涵盖的列数据,上文提到的 ROWID 范围扫描文章在接近结束时对此内容有所介绍:
    对于 Oracle8/8i,请参阅 Note:61685.1
    对于 Oracle7,请参阅 Note:34371.1
  • 在 redo 流上可以使用 LogMiner 来查找向问题块加载数据的初始插入/更新操作。此处的主要因素是数据实际被放入问题块的时间。
    例如,行 2 可能在昨天已插入,而行 1 可能在 5 年前已插入。

{go to content}

(5D) 忽略坏块

出错时可以忽略坏块并接受报告的错误,或在应用程序级别阻止对出问题的块行进行访问。

例如:如果问题块/行位于子表中,则可以在应用程序级别阻止对父表中对应行的访问,从而子行就永不会被访问。(但要注意级联类约束)

这样做可能不利于批量访问数据的报告和其他任务,因此,为了阻止块在被访问时报错,前面 4C 中所述的 DBMS_REPAIR 选项也不失为一个可取的方法。使用这种方法标记并跳过坏块提供了一种短期的解决方案,从而在计划停机时可以尝试进行完全数据抢救和/或恢复,或留出更多时 间在第二个(克隆)数据库上尝试其他恢复选项。但请注意,使用 DBMS_REPAIR.FIX_CORRUPT_BLOCKS 标记块坏块将导致标记的块在恢复后还是“坏块”。

忽略坏块对于快速老化且即将被清除的数据而言是比较好的选择(例如,在按日期分区的表中,较老的分区将在某时间点被删除)。

忽略 LOB 段上的坏块

在应用程序级别,可以忽略损坏的 LOB 列,直到可以重新构建该表。

确保不出现上述“警告”中的情形的一种方法是,确保应用程序只能通过表上的包含WHERE 谓词的视图来访分表中的数据。
例如:假设表 MYTAB(a number primary key,b clob)有一行或多行指向损坏的 LOB 数据。

ALTER TABLE MYTAB ADD ( BAD VARCHAR2(1) );
CREATE VIEW MYVIEW AS SELECT a,b FROM MYTAB WHERE BAD is null;

对任何问题行设置 BAD=’Y’

如果只通过 MYVIEW 访问 MYTAB,该行将永不可见,因此也无法更新,从而实现了坏块条目隔离,直到问题解决。

很明显,此示例更多的是一个设计时解决方案,但某些应用程序可能已有类似机制,且可能只通过某个视图(或通过 RLS 策略)访问数据,从而提供某些选项来隐藏问题行。

{go to content}

针对忽略坏块的警告

虽然可以忽略坏块,但需要注意的是,坏块在运行 DBVERIFY、RMAN 备份时仍然会以警告/错误等形式出现。

请务必仔细记录您将在这些工具中看到的任何坏块,尤其是您期望在使用 RMAN 时跳过的任何块(例如,设置了 MAX_CORRUPT),并确保在清除坏块后移除任何对错误的“接受”选项。

例如:假设坏块已处理为忽略坏块,并在应用程序级别跳过问题行。
RMAN 可能被配置为在备份时接受坏块。
然后在稍后的表重组期间重新创建表。
如果 RMAN 配置未及时更新以反映目前已无任何错误,则 RMAN 可能会忽略稍后出现的某些其他坏块。

此外,还有重要的一点需要注意,忽略 table 段中的坏块可能导致查询返回不一致的结果。
例如:设置了 SKIP_CORRUPT 的表可能出现不同的结果,具体取决于是使用了了索引扫描还是表访问。
其他报告可能只是报错。

请注意,如果忽略坏块但使用 DBMS_REPAIR.FIX_CORRUPT_BLOCKS 标记,系统会向坏块中写入 redo 信息,这可能会限制后续的恢复选项。

{go to content}

(5E) 最后的选项

如果你有 standby 环境(物理或逻辑),请首先对其进行检查。
无论问题发生在何种类型的块上,均可使用一种可能的选项,即将数据库或问题表空间恢复到出现坏块之前的某个时间点。此选项的困难之处在于,并不总能知道问题首次出现的时间。

DBVERIFY 通常可用于检查还原的文件是否存在坏块。
有关使用 DBVERIFY 的详细信息,请参阅Note:35512.1 。尤其是,START= / END= DBV 选项可用于在还原的备份映像上快速进行首次测试,以检查问题块本身是否出错。

 

本部分列出了一些可用于进行恢复操作的最终选项。
如果您看到这里,则必定发生了以下一种或多种情况:

  • 您丢失了非常重要的数据文件(或数据文件出现坏块),而没有问题文件的正常备份(无坏块)
  • 既不处于 ARCHIVELOG 模式,也没有自文件创建以来的全部归档日志
  • 完全恢复后仍重复出现问题

最后的机会:

请注意,如果您丢失了数据文件的所有副本,但仍具有自文件创建以来的全部归档日志,则仍有可能恢复该文件。

例如:
ALTER DATABASE CREATE DATAFILE ‘….’ [as '...'] ;
RECOVER DATAFILE ‘….’
ALTER DATABASE DATAFILE ‘….’ ONLINE;

如果您遇到这种情况,请在继续下面的操作之前先尝试使用这些步骤来恢复数据文件。

如果您到达这一步,就说明没有其他办法可以将文件恢复到当前时间点。此时最好关闭实例,并对当前数据库进行备份,以便在选用的措施失败后仍然能够回退到当前时间点。(例如:如果发现备份坏块)。

可用的一些选项概述如下:

恢复到早期的冷备份
- 例如:如果处于 NOARCHIVELOG 模式

从冷备份建立克隆数据库,并提取(导出)问题表,或传输问题表空间。

使用基于时间点的恢复将数据库恢复到一致的时间点

  • 需要完好备份和任何所需的归档日志
  • 必须还原所有文件且将整个数据库前滚到恰当的时间点。
  • 可以在克隆数据库中执行基于时间点的恢复,然后将问题表空间传输到问题数据库,或将问题表利用导出/导入工具从克隆数据库导入到问题数据库。

表空间基于时间点的恢复
- 可以仅对受影响的表空间执行基于时间点的恢复。许多文档均对表空间基于时间点的恢复做了介绍,如 Note:223543.1.

从逻辑导出/副本重新创建数据库
- 需要具有完好的数据库逻辑备份
- 注意:要使用此选项,必须重新创建数据库。
- 与其他选项一样,可以在克隆数据库中进行重新创建,只为获得问题表的完好映像。

如果已具有完好备份,使用 DB_BLOCK_CHECKING=TRUE 进行前滚将有助于找到首次出错的时间点。在调查恢复选项时,通常不需要关闭问题数据库。

例如:可以只将系统表空间和问题表空间数据文件还原到完全不同的位置和/或机器,作为不同的实例,以便于调查可以前滚到多久以前的时间点等。
自 Oracle9i 起,您还可以使用“试验恢复”选项来让自己摆脱一边研究选项一边必须不断还原备份的情形。

转载:处理 Oracle 块损坏 (Doc ID 1526911.1)

Oracle各种类型坏块说明和处理

联系:手机/微信(+86 17813235971) QQ(107644445)QQ咨询惜分飞

标题:Oracle各种类型坏块说明和处理

作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]

 

CORRUPTION EXPLANATION
What is a corruption?
Note 840978.1 : Physical and Logical block corruption

How to force reformat a corrupted block?
Note 336133.1 : How to Format Corrupted Block Not Part of Any Segment

How to identify corruptions in a database?
Note 472231.1 : How to identify all the Corrupted Objects in the Database reported by RMAN
Note 819533.1 : How to identify the corrupt Object reported by ORA-1578 / RMAN / DBVERIFY

Known corruptions caused by OS/HW Issues
Note 1323649.1 : Known Corruption issues caused by 3rd party Software Provider

TYPES OF CORRUPTIONS
SEGMENT CORRUPTED  How to handle Segment Corruptions (Table, Index, LOB, Long, IOT, Temporary This section refers to BLOCK CORRUPTION affecting database segments.
CONTROLFILE CORRUPTION Note 48808.1 : OERR: ORA-00227 corrupt block detected in controlfile: (block %s, # blocks %s) Primary Note / Troubleshooting, Diagnostic and Solution
UNDO CORRUPTION Note 1950230.1 : Solving UNDO Corruption

Note 281429.1 : Basic Steps to be Followed While Solving ORA-00600 [4194]/[4193] Errors Without Using Unsupported parameter
Note 39283.1   : ORA-600 [4194] “Undo Record Number Mismatch While Adding Undo Record”
Note 431652.1 : How to Change the Existing Undo Tablespace to a New Undo Tablespace

DICTIONARY INCONSISTENCY It refers to inconsistencies between Data Dictionary tables. These tables are owned by the user SYS and are stored in the SYSTEM tablespace to keep track of the users, tables, indexes, etc that are created in the database.

Example of this inconsistency is:

‘Problem: OBJ$.OWNER# not in USER$” which refers to a user in table OBJ$ that does not exist in USER$. To identify known Data Dictionary inconsistencies run script hcheck:

Note 136697.1 : “hcheck.sql” Script to Check for Known Problems in Oracle8i, Oracle9i, Oracle10g, Oracle 11g and Oracle 12c

REDO CORRUPTION Note 332672.1 : ORA-354 ORA-353 and ORA-312 on Redo Log Group members

Note 1031381.6 : How to Dump Redo Log File Information.

ROW & COLUMN CORRUPTION It means that a column does not contain a valid value corresponding to its declaration; example: column was declared as date but the stored date is invalid.  If the block structure is ok; example, dbverify nor rman with the check logical option detect any issue then this is not a block corruption but it is included here for completeness.

Note 428526.1 : Baddata Script To Check Database For Corrupt column data
Note 976591.1 : How To validate a date/timestamp column
Note 869305.1 : How To identify a ‘corrupt’ row when error is raised but no row information provided
Note 136620.1 : Sanity Check of Oracle NUMBERS, How to Find and Patch

TABLE/INDEX INCONSISTENCY Table / Index inconsistencies is when an entry in the Table does not exist in the Index or vice versa. The common errors are ORA-8102, ORA-600 [kdsgrp1], ORA-1499 by “analyze validate structure cascade”.

See section “Identify TABLE / INDEX Mismatch” in:

Note 836658.1 : Identify the Corruption Extension for Block Corruption, Table/Index Inconsistency, Data Dictionary and Lost Writes

HOW TO HANDLE SEGMENT CORRUPTIONS
TABLE CORRUPTION Note 28814.1 : Handling Oracle Block Corruptions in Oracle7/8/8i/9i/10g/11g
INDEX CORRUPTION Note 28814.1 : Handling Oracle Block Corruptions in Oracle7/8/8i/9i/10g/11g
Note 438143.1 : Use of dbms_metadata.get_ddl() to extract Index DDL
Note 394143.1 : How Could I Format The Output From Dbms_metadata.Get_ddl Utility?
LOB / LOBSEGMENT Note 28814.1 : Handling Oracle Block Corruptions in Oracle7/8/8i/9i/10g/11g

Note 452341.1 : How to detect Lob Corruption
Note 293515.1 : ORA-1578 ORA-26040 in a LOB segment – Script to solve the errors

LONG ** Contact Oracle Support **  –>> Generic notes about these objects: * None Public*
Index Organized Table IOT Reference the IOT section in:

Note 28814.1 : Handling Oracle Block Corruptions in Oracle7/8/8i/9i/10g/11g

Also reference section “SKIP ORA-600 in IOT” in:

Note 1527738.1 : SCRIPT to skip ORA-8103 ORA-1410 ORA-1578 ORA-600 [kdsgrp1] when reading a TABLE

TEMPORARY Note 1332088.1 : How to clear a block corruption in a TEMPORARY segment
PACKAGE INFORMATION AND EXAMPLES
DBMS_REPAIR Note 556733.1 : DBMS_REPAIR script
Note 68013.1: DBMS_REPAIR example
DBMS_METADATA Note 438143.1 : Use of dbms_metadata.get_ddl() to extract Index DDL
Note 394143.1 : Q How Could I Format The Output From Dbms_metadata.Get_ddl Utility?
Note 332077.1 : Why Does DBMS_METADATA.GET_DDL Not Show All Lines?
Note 188838.1 : Using DBMS_METADATA To Get The DDL For Objects
TOOLS
DBV Note 35512.1   : DBVERIFY – Database file Verification Utility (7.3.2 – 10.2)
Note 269028.1 : DBV Reports Corruption Even After Drop/Recreate Object
Note 336133.1 : How to Format Corrupted Block Not Part of Any Segment
EXPORT Note 214369.1 : Using The Export Utility To Check For Database Corruption
RMAN Note 472231.1 : How to identify all the Corrupted Objects in the Database with RMAN
TRANSPORTABLE TABLESPACE Note 733824.1 : How To Recreate a database using TTS
DATA RECOVERY ADVISOR Note 1579579.1 : Primary Note For Oracle Data Recovery Advisor (DRA)
ORA600/7445 Error Lockup tool Note 153788.1 : ORA-600/ORA-7445 Error Look-up Tool
GENERIC LINKS
PATCHSET UPDATES (PSU) & CRITICAL PATCH UPDATES (CPU) Note 268895.1 : Oracle Database Server Patchset Information, Versions: 8.1.7 to 11.2.0
Note 1061295.1 : Patch Set Updates – One-off Patch Conflict Resolution
Note 161549.1 : Oracle Database, Networking and Grid Agent Patches for Microsoft Platforms
Note 756671.1 : Oracle Recommended Patches — Oracle Database
Note 742060.1 : Release Schedule of Current Database Releases
Note 161818.1 : Oracle Database (RDBMS) Releases Support Status Summary
COMMON ERRORS
ORA-1578 ORA-1578 The data block indicated was corrupt.  This was a physical corruption, also called a media corruption. The cause is unknown but is most likely external to the database. If ORA-26040 is also signaled, the corruption is due to NOLOGGING or UNRECOVERABLE operations.
ORA-1410 This error is raised when an operation refers to a ROWID in a table for which there is no such row.
The reference to a ROWID may be implicit from a WHERE CURRENT OF clause or directly from a WHERE ROWID=… clause.
ORA-1410 indicates the ROWID is for a BLOCK that is not part of this table.
ORA-8103 The object has been deleted by another user since the operation began; example: another session truncated or dropped the segment while the SQL statement was still active.
If the error is reproducible, following may be the reasons:
a.) The header block has an invalid block type.
b.) The data_object_id (seg/obj) stored in the block is different than the data_object_id stored in the segment header. See dba_objects.data_object_id and compare it to the decimal value stored in the block (field seg/obj).
ORA-8102 An ORA-08102 indicates that there is a mismatch between the key(s) stored in the index and the values stored in the table. What typically happens is the index is built and at some future time, some type of corruption occurs, either in the table or index, to cause the mismatch.
ORA-1498 Generally this is a result of an ANALYZE … VALIDATE … command.
This error generally manifests itself when there is inconsistency in the data/Index block. Some of the block check errors that may be found:-
a.) Row locked by a non-existent transaction
b.) The amount of space used is not equal to block size
c.) Transaction header lock count mismatch.
While support are processing the tracefile it may be worth the re-running the ANALYZE after restarting the database to help show if the corruption is consistent or if it ‘moves’.
Send the tracefile to support for analysis.
If the ANALYZE was against an index you should check the whole object. Eg: Find the tablename and execute:
ANALYZE TABLE xxx VALIDATE STRUCTURE CASCADE;
ORA-1499 An error occurred when validating an index or a table using the ANALYZE command.
One or more entries does not point to the appropriate cross-reference.
ORA-752 or ORA-600 [3020] Media recovery detected a lost write of a data block.  A data block write to storage was lost during normal database operation on the primary database.

This is reporting a lost write during media recovery.

Reference the next article:

Note 1265884.1 : Resolving ORA-00752 or ORA-600 [3020] During Standby Recovery

ORA-26040 Trying to access data in block that was loaded without redo generation using the NOLOGGING/UNRECOVERABLE option.
This Error raises always together with ORA-1578
ORA-600 [12700] Oracle is trying to access a row using its ROWID, which has been obtained from an index.
A mismatch was found between the index rowid and the data block it is pointing to. The rowid points to a non-existent row in the data block. The corruption can be in data and/or index blocks.
ORA-600 [12700] can also be reported due to a consistent read (CR) problem.
ORA-600 [3020] This is called a ‘STUCK RECOVERY’.
There is an inconsistency between the information stored in the redo and the information stored in a database block being recovered.

This error indicates a lost write or a lost change in the database

ORA-600 [4194] A mismatch has been detected between Redo records and rollback (Undo) records.
Oracle is validating the Undo record number relating to the change being applied against the maximum undo record number recorded in the undo block.
This error is reported when the validation fails.
ORA-600 [4193] A mismatch has been detected between Redo records and Rollback (Undo) records.
Oracle is validating the Undo block sequence number in the undo block against the Redo block sequence number relating to the change being applied.
This error is reported when this validation fails.
ORA-600 [4137] While backing out an undo record (i.e. at the time of rollback) Oracle found a transaction id mismatch indicating either a corruption in the rollback segment or corruption in an object which the rollback segment is trying to apply undo records on.
This would indicate a corrupted rollback segment.
ORA-600 [6101] Not enough free space was found when inserting a row into an index leaf block during the application of undo.
ORA-600 [2103] Oracle is attempting to read or update a generic entry in the control file.
If the entry number is invalid, ORA-600 [2130] is logged.
ORA-600 [4512] Oracle is checking the status of transaction locks within a block.
If the lock number is greater than the number of lock entries, ORA-600 [4512] is reported followed by a stack trace, process state and block dump.
This error possibly indicates a block corruption.
ORA-600 [2662] A data block SCN is ahead of the current SCN.
The ORA-600 [2662] occurs when an SCN is compared to the dependent SCN identified by the process that is normally close to the database scn.
If the SCN is less than the dependent SCN then ORA-600 [2662] is signaled.
ORA-600 [4097] Oracle is accessing a rollback segment header to review if a transaction has been committed.
However, the xid given is in the future of the transaction table.
This could be due to a rollback segment corruption issue.
ORA-600 [4000] It means that Oracle has tried to find an undo segment number in the data dictionary and this undo segment number was not found.
ORA-600 [6006] Oracle is undoing an index leaf key operation. If the key is not found, ORA-00600 [6006] is logged.
ORA-600[6006] is usually caused by a media corruption problem related to either a lost write to disk or a corruption on disk.
ORA-600 [4552] This assertion is raised because Oracle is trying to unlock the rows in a block, but receive an incorrect block type.
The second argument is the block type received.
ORA-600[6856] Oracle is checking that the row slot that is about to be freed is not already on the free list.
This internal error is raised when this check fails.
ORA-600[13011] During a delete operation Oracle is deleting from a view via an instead-of trigger or an Index organized table and have exceeded a 5000 pass count
ORA-600[13013] During the execution of an UPDATE statement, after several attempts (Arg [a] passcount) Oracle is unable to get a stable set of rows that conform to the WHERE clause.

Note 816784.1 : How to resolve ORA-00600 [13013], [5001]

ORA-600[13030]  
ORA-600[25012] Oracle is trying to generate the absolute file number given a tablespace number and relative file number and cannot find a matching file number or the file number is zero.
ORA-600[25026] Looking up/checking a tablespace invalid tablespace ID and/or rdba found
ORA-600[25027] Invalid tsn and/or relative file number found
ORA-600 [kcbz_check_objd_typ_3] An object block buffer in memory is checked and is found to have the wrong object id. This is most likely due to corruption.
ORA-600 [kdsgrp1] Error may be caused by:

Case 1. A row referenced in an index that does not exist in the table

ORA-1499 may be produced by analyze:

analyze table <table name> validate structure cascade online;
Case 2. An non-existent rowid pointed to by a chained row

Run an export (exp) or Full Table Scan to identify if there is a permanent invalid chained row.

ORA-600[kddummy_blkchk] 

ORA-600[kdblkcheckerror]

ORA-600 [kdbBlkCheckError]
ORA-600 [ktfBlkCheckError]
ORA-600 [ktfBlkCheckError]
ORA-600 [ktsBlkChekError]
ORA-600 [ktspBlkCheckError]
ORA-600 [ktfbnBlkCheckError]
ORA-600 [ktuBlkCheckError]
ORA-600 [kdliBlkCheckError]
ORA-600 [kdxdBlkCheckError]
ORA-600 [kdiBlkCheckError]

ORA-600 [kddummy_blkchk] is for 10g and ORA-600[kdblkcheckerror] for 11g onward.

These errors report a Logical Block Corruption

If the error is raised in a data guard physical standby database, follow the next article:

Note 2821699.1 : Resolving Logical Block Corruption Errors in a Physical Standby Database

ORA-600[ktadrprc-1] Orphan segment or invalid rdba in Index,Table,Partition etc.  Example:  An entry in sys.ind$ does not exist in sys.seg$

Note 136697.1 : “hcheck.sql” Script to Check for Known Problems in Oracle8i, Oracle9i, Oracle10g, Oracle 11g and Oracle 12c

ORA-600[ktsircinfo_num1] This exception occurs when there are problems obtaining the row cache information correctly from sys.seg$. In most cases there is no information in sys.seg$.

Note 136697.1 : “hcheck.sql” Script to Check for Known Problems in Oracle8i, Oracle9i, Oracle10g, Oracle 11g and Oracle 12c

ORA-600[qertbfetchbyrowid] This error might be that a row was not found in an Index.  Perform the check in section “Identify TABLE / INDEX Mismatch” in:

Note 836658.1 : Identify the Corruption Extension for Block Corruption, Table/Index Inconsistency, Data Dictionary and Lost Writes

ORA-600[ktbdchk1-bad dscn] This exception is raised when Oracle is performing a sanity check on the dependent SCN and fail.
The dependent scn is greater than the current scn.

参考:Primary Note for Handling Oracle Database Corruption Issues (Doc ID 1088018.1)

ORA-742 写丢失常见bug记录

联系:手机/微信(+86 17813235971) QQ(107644445)QQ咨询惜分飞

标题:ORA-742 写丢失常见bug记录

作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]

我们经常会遇到数据库异常down,然后启动的时候报ORA-00742错误,一般是在recover或者open的过程中遇到

SQL> RECOVER DATABASE;
ORA-00283: 恢复会话因错误而取消
ORA-00742: 日志读取在线程 1 序列 2097 块 296728 中检测到写入丢失情况
ORA-00312: 联机日志 3 线程 1: 'D:\APP\ADMINISTRATOR\ORADATA\HIS\REDO03.LOG'
SQL> recover database;
Media recovery complete.

SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-00742: Log read detects lost write in thread %d sequence %d block %d
ORA-00312: online log 3 thread 1: '/oradata/shrdh/redo03.log'

关于该错误,Oracle官方解释:由于操作系统或者存储或者Oracle导致redo发生写丢失

[oracle@www.xifenfei.com:/home/oracle]$ oerr ora 742
00742, 00000, "Log read detects lost write in thread %s sequence %s block %s"
// *Cause:  Either a write issued by Oracle was lost by the underlying
//          operating system or storage system or an Oracle internal error
//          occurred.
// *Action: The trace file shows the lost write location. Dump the problematic
//          log file to see whether it is a real lost write. Contact Oracle
//          Support Services.

Oracle官方关于ORA-00742的主要bug有:
ORA-742-BUG-1
ORA-742-BUG-2
由于redo写丢失已经发生,一般发生这种情况,有备份使用备份进行不完全恢复,没有备份考虑强制拉库,如果是dg库问题,可以考虑从主库把日志重新传过去

避免 19c 数据库性能问题需要考虑的事项 (Doc ID 3050476.1)

联系:手机/微信(+86 17813235971) QQ(107644445)QQ咨询惜分飞

标题:避免 19c 数据库性能问题需要考虑的事项 (Doc ID 3050476.1)

作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]

适用于:

Oracle Cloud Infrastructure – Exadata Cloud Service
Gen 2 Exadata Cloud at Customer
Gen 1 Exadata Cloud at Customer (Oracle Exadata Database Cloud Machine) – 版本 N/A 和更高版本
Oracle Database – Enterprise Edition – 版本 19.0.0.0 到 19.14.0.0.0 [发行版 19]
Oracle Database Cloud Exadata Service
本文档所含信息适用于所有平台
用途

本文档的目的是发布一些推荐的修复措施,以期避免 19c 中与数据库性能相关的问题。这也包括一些影响性能的 ORA-600/ORA-7445 及其他错误。

关于 SQL 性能,请参考以下文档:

Document 2773715.1 Things to Consider to Avoid SQL Performance Problems on 19c

适用范围

本文档列出了部分影响数据库性能的已知问题。一些问题的修复包含在数据库发布更新(DBRU)中,但有些尚未包含。

提醒: 数据库发布更新(RU)具有累积性。例如,2021 年 4 月的发布更新补丁包含之前所有发布更新的内容。因此,建议始终使用包含大多数已知问题修复的最新 DBRU(数据库发布更新)。
Patch 33515361 - Database Jan 2022 Release Update (19.14) - Latest

请参考以下文档获取最新的数据库发布更新(DBRU)信息。

Document 2521164.1 Oracle Database 19c Proactive Patch Information

对于尚未包含在发布更新(RU)中的错误,请下载并安装适用于您的数据库版本和操作系统的单独补丁。如果在MOS上找不到适用于您特定版本和操作系统的补丁,请提交服务请求,提供所需补丁的详细信息。请附上已应用补丁的列表(使用 opatch lsinventory -detail 命令),以及您打算应用的其他补丁。

有关自助升级和最佳实践,请参考以下内容:-

Document 1919.2 19c Database Self-Guided Upgrade with Best Practices
Document 555.1 Oracle Database 19c Important Recommended One-off Patches

详细信息

19c 数据库性能已知 Bug 修复列表:

Bug            描述 是否包含在RU? 备注
Document 30329209.8 High wait on row cache mutex after upgrading to 12.2.0.1 and above 是,从 19.8 起 应用 19.8 或以上
Document 31933451.8 High row cache mutex contention 是,从 19.13 起 应用 19.13 或以上
Document 29523216.8 Major performance bug for dc_users row cache 是,从 19.7 起 应用 19.7 或以上
Document 30712670.8 High row cache mutex contention for queries with dblink (dc_props / dc_cdbprops) 是,从 19.10 起 应用 19.10 或以上
Document 30431274.8 High row cache mutex contention (ktatminextsz) – regression of 22909260 是,从 19.7 起 应用 19.7 或以上
Document 29628647.8 High CPU for DESCRIBE command due to contention in dc_users rowcache 是,从 19.10 起 应用 19.10 或以上
Document 32043701.8 row cache lock for sequences in RAC due to S-optimization feature for dc_sequences 申请临时性补丁
Document 30489582.8 Hanganalyze trace unable to identify the blocker of “row cache lock” in RAC 是,从 19.10 起 应用 19.10 或以上
Document 30327149.8 GEN0 process in RAC waiting on ktatminextsz while reading rowcache 是,从 19.7 起 应用 19.7 或以上
Document 30720844.8 CLMN process waits on ‘library cache: mutex X’ and/or might cause ORA-600 [kglrfcl_1] 是,从 19.8 起 应用 19.8 或以上
Document 30384121.8 LCK process in RAC holds mutex in kglHandleMessage causing database hang 是,从 19.7 起 应用 19.7 或以上
Document 32356628.8 Huge waits on ‘library cache: mutex X’ with audit enabled for ‘select any table’ privilege 是,从 19.12 起 应用 19.12 或以上
Document 28889389.8 High waits on ‘cursor:mutex X’ after upgrade 是,从 19.10 起 应用 19.10 或以上
Document 31211220.8Document 33163187.8 High version count (cursor leaks) due to BIND_EQUIV_FAILURE mismatchChild Cursor Increase Due To “Bind Mismatch” Even When Using Same Bind Values 被替换是,从 19.14 起 应用 19.14 或以上
Document 34304965.8Document 35778398.8

Document 35925654.8

[ROW CACHE] 19c Tracking Bug for Row Cache Bug Fixes – RegressedFURTHER FIXES FOR ROW CACHE ON TOP OF 34304965 – Regressed & replaced with

SESSIONS DEADLOCK ON ROW CACHE MUTEX AND SHARED POOL LATCH

N/AN/A

是,从 19.24 起

N/AN/A

应用 19.24 或以上

Document 20319830.8 Latch Get and Free Functions Available for Shared Parent-Child Latches 是,从 19.11 起 应用 19.11 或以上
Document 31602782.8 ORA-12850/ORA-12872 or huge waits on ‘cursor: pin S wait on X’ with parallel execution 是,从 19.14 起 应用 19.14 或以上
Document 31753692.8 High waits on ‘cursor: pin S wait on X’ and ‘cursor: mutex X’ with PX_MISMATCH 是,从 19.10 起 应用 19.10 或以上
Document 30293345.8 Waits for latch: MGA Shared Context Latch After Migration to 18c 或以上 是,从 19.8 起 应用 19.8 或以上
Document 30614411.8 Huge delay in LGWR BOC (Broadcast-on-commit) processing in RAC 是,从 19.8 起 应用 19.8 或以上
Document 31827912.8 High waits for ‘log file sync’ & ‘remote write sync’ in RAC ADG with Fast-Start Failover (FSFO) 是,从 19.10 起 应用 19.10 或以上
Document 31176502.8 LGWR Hangs during log switch after Upgrade to 19c in RAC due to Cache Fusion Write Hang 是,从 19.11 起 应用 19.11 或以上
Document 31331038.8 ORA-600 error in ADG SYNC mode on Exadata with PMEMlog 如果是 Exadata 申请临时补丁
Document 32249371.8 High ‘log file parallel write’ waits on Exadata due to single HCA bottleneck 是,从 19.13 起 应用 19.13 或以上
Document 32498752.8 ORA-600 [ksu_get_available_pso: numa mismatch] signaled when using parallel LGWR 是,从 19.14 起 应用 19.14 或以上
Document 30978554.8 GC hang on read-mostly object or ORA-481 in RAC 是,从 19.9 起 应用 19.9 或以上
Document 32035536.8 Sessions Blocked by ‘gc current request’ in RAC 是,从 19.11 起 应用 19.11 或以上
Document 28697526.8 Session Hangs On ‘gc cr request’ And Other Sessions Wait On ‘cr request retry’ 是,从 19.9 起 应用 19.9 或以上
Document 32227352.8 High CPU with set role command 是,从 19.11 起 应用 19.11 或以上
Document 31812824.8 Slow performance with set role command 是,从 19.12 起 应用 19.12 或以上
Document 28889730.8 “Insert As Select” or a “Create Table As Select” command consume huge space 是,从 19.4 起 应用 19.4 或以上
Document 32379140.8 LCK process in RAC crashes due to ORA-07445 [kjcvmsn()+128] [SIGSEGV] 是,从 19.12 起 应用 19.12 或以上
Document 30240930.8 Scheduler Jobs Time Classified as Background Instead of Foreground 是,从 19.9 起 应用 19.9 或以上
Document 29932310.8 AWR Report Generation Takes Long time in 19c 是,从 19.10 起 应用 19.10 或以上
Document 31489731.8 ORA-600/ORA-7445 While Shared Pool Memory is Being Freed 是,从 19.18 起 应用 19.18 或以上
Document 31892767.8 Improvement to Temp Space Shrink (Affects on Cloud 19c) 申请临时补丁 (仅影响 Cloud 19c)
Document 32465193.8 ORA-4031 Due to high SQL Monitoring allocations in Shared Pool 是,从 19.13 起 应用 19.13 或以上
Document 31820859.8 ORA-4025 Due To 65535 Active Locks Limit Reached On Select NLS_CHARSET_ID 是,从 19.9 起 应用 19.9 或以上
Document 30887989.8 ORA-00001 While Generating AWR Snapshot in non-CDB with Resource Manager enabled 是,从 19.13 起 应用 19.13 或以上
Document 29423227.8 Drop Partition with global indexes hangs on library cache lock 是,从 19.11 起 应用 19.11 或以上
Document 32234161.8 Performance Slow due to High CPU post July 2020 DBRU (19.8) caused by Space Management slave processes (Wnnn) 是,从 19.10 起 应用 19.10 或以上
Document 29454450.8 High waits on “latch: cache buffers chains” in RAC 是,从 19.9 起 应用 19.9 或以上
Document 31563138.8 Securefile mutex waits when many inserts occurring on Securefile compressed LOB 是,从 19.11 起 应用 19.11 或以上
Document 32103628.8 High Latch Free Waits While Flushing Top Segment Statistics in AWR 是,从 19.15 起 应用 19.15 或以上
Document 33123985.8 DBW0 Process Generate Huge Traces With Dumping DBWR Process State After DBRU 19.11 是,从 19.13 起 应用 19.13 或以上
Document 32936537.8 Significant Contention on “library cache: mutex X” While accessing Interval or Auto-List Partitioned table Concurrently 是,从 19.16 起 应用 19.16 或以上
Document 32148419.8 High Row Cache Lock Waits on Alter Table Exchange Partition in RAC Environment 是,从 19.12 起 应用 19.12 或以上
Document 30662963.8Document 34284147.8 High contention for “latch: MGA shared context root latch” When Many Sessions are Logging outHigh contention for “latch: MGA shared context root latch” When Many Sessions are Logging out 被替换是,从 19.17 起 N/A应用 19.17 或以上
Document 32550751.8 ONLY FOR AIX: Performance issues due to MGA related operations in AIX 是,从 19.12 起 应用 19.12 或以上
Document 33352794.8 ONLY FOR AIX: High waits on ‘latch: MGA shared context root latch’ and ‘latch: MGA shared context latch’ even with Fix 32550751 是,从 19.13 起 应用 19.13 或以上
Document 32117253.8 High “enq: RO – fast object reuse” waits & active checkpoint queue latch gets 是,从 19.12 起 应用 19.12 或以上
Document 30710917.8 Cursor: mutex S waits due to High Version Count For SQL Statements using Bind variables and DBLINK From 12.2 是,从 19.14 起 应用 19.14 或以上
Document 33025005.8 Waits on ‘latch: cache buffers chains’ after Database Upgrade from 12.1.0.2 to 19c 是,从 19.15 起 应用 19.15 或以上
Document 31387123.8 High Waits on ‘enq: IV – contention’ observed in RAC Standby environment 是,从 19.13 起 应用 19.13 或以上
Document 32225742.8 Gathering Statistics in Primary DB Results in ORA-4061/ORA-4065 in Secondary DB 是,从 19.13 起 应用 19.13 或以上
Document 32069508.8 High Latch: Cache Buffers Chains Contention in Standby Database 是,从 19.13 起 应用 19.13 或以上
Document 33803836.8 Regression in 19.14 Due to Bug Fix 32119144 是,从 19.18 起 应用 19.18 或以上
Document 33163187.8 High Version Count due To “Bind Mismatch” Even When Using Same Bind Values 是,从 19.14 起 应用 19.14 或以上
Document 32755517.8 High Version count with USER_BIND_PEEK_MISMATCH for SQLs with bind peeking disabled 是,从 19.13 起 应用 19.13 或以上
Document 33121934.8 Library cache lock / load lock / mutex x during connection storm due to update user$ 是,从 19.16 起 应用 19.16 或以上
Document 36587533.8 RESULT CACHE: GLOBAL FLUSH SHOULD ALWAYS CLEAR BYPASS FLAG EVEN IF THE RESULT CACHE IS UNINITIALIZED 是,从 19.24 起 应用 19.24 或以上

常见已知问题

问题 1: 在 19c AWR 报告中缺少表空间级别的 IO 统计数据

解决方案: 该 Bug Document 25416731.8 已在 19.8 版本及以上修复。请应用 19.8 或更高版本,并执行以下步骤。

要在 19.X 版本的 AWR 报告中恢复表空间 IO 统计数据,请以 SYS 身份运行以下命令:

$ sqlplus / as sysdba

exec dbms_workload_repository.modify_table_settings(table_name => ‘WRH$_FILESTATXS’, flush_level => ‘TYPICAL’);
exec dbms_workload_repository.modify_table_settings(table_name => ‘WRH$_DATAFILE’, flush_level => ‘TYPICAL’);
exec dbms_workload_repository.modify_table_settings(table_name => ‘Tempfile Group’, flush_level => ‘TYPICAL’);
exec dbms_workload_repository.modify_table_settings(table_name => ‘WRH$_TEMPSTATXS’, flush_level => ‘TYPICAL’);
exec dbms_workload_repository.modify_table_settings(table_name  => ‘WRH$_TEMPFILE’, flush_level => ‘TYPICAL’);

当新的 AWR 快照生成时,您将开始获得用于检查 IO 性能的表空间 IO 统计数据。

供您参考:如果您在 PDB 层级生成 AWR 快照并且在 AWR 报告中缺少表空间 IO 统计数据,您可能还需要在 PDB 中运行这些命令。

该 Bug Document 34733173.8 从 19.22RU 起被修复了. 如果您应用了补丁 34733173 这些命令就不需要了。

Document 25416731.8 - Bug 25416731 – Tablespace IO Statistics Missing From AWR Report
Document 34733173.8 - Bug 34733173 – Tablespace IO Stats and File IO Stats Data Must Be Included in AWR Reports From Oracle 19C, 21C and 23ai
Document 3008056.1 - AWR Report Under File IO Stats Shows No Data Exists For This Section Of The Report.

问题 2: SQL 子游标的高版本计数持续超过 1024

解决方案:请参考以下文档以控制 SQL 子游标的版本计数,该计数持续超过 1024。

Document 2431353.1 High Version Counts For SQL Statements (>1024) Post Upgrade To 12.2 and Above Causing Database Slow Performance

问题 3: SQL 语句中列数过多导致的高 CPU 使用率。short stack 显示在 qosdGetOptDir、qosdInitDirCtx 和 qosdUpdExprExecStatsRws 上存在函数旋转。可能会出现高锁等待,包括 RAC 中的 GES 锁。

解决方案:在系统级别设置 _column_tracking_level=1。该参数是动态的。这样做是为了避免大量列使用跟踪,这可能会导致更高的 CPU 使用率。默认值在 11.2 和 12.1 中为 1,从 12.2 开始更改为 21 及以上。

问题 4: 如果数据库从 11.2 升级到 19c,那么从 12c 开始,LGWR 的架构发生了变化,采用了并行自适应 LGWR。这可能会导致 LGWR 吞吐量变慢,有时会在 19c 中导致前台会话出现“log file sync”等待。这是由于并行 LGWR 的自适应行为与串行 LGWR 之间存在一些缺陷所导致的。

解决方案:在生产环境之前,在用户验收测试(UAT)中评估新的 LGWR 架构(默认启用)。要使用旧的 LGWR 架构,请设置以下参数:

_use_single_log_writer=TRUE /* default value: ADAPTIVE */

注意:这不是一个动态参数。它需要重启数据库。

问题 5: 在19c数据库中进行分区维护时,高库缓存锁等待。

解决方案: Document 2619066.1 High Library Cache Lock Waits After Upgrading To 19C During Partition Index Maintenance

请参阅以下文档以排查与库缓存相关的等待问题:-

Document 444560.1 Troubleshooting Library Cache: Lock, Pin and Load Lock
Document 1353015.1 How to Identify Hard Parse Failures Causing Library Cache contention
Document 2746493.1 How To Trace Overall Library Cache Objects Invalidation Happening At Particular Period

19c 最佳实践

1. Database Testing

Oracle Real Application Testing 选项使您能够在进行生产环境升级之前,在开发或用户验收测试(UAT)中对 Oracle 数据库进行真实世界的测试。通过捕获生产工作负载并在生产部署之前评估系统更改对这些工作负载的影响,Oracle 实际应用测试最大限度地降低了与升级后系统更改相关的不稳定性风险。SQL 性能分析器和数据库重放是 Oracle 实际应用测试的关键组件。.

Documentation: https://docs.oracle.com/en/database/oracle/oracle-database/19/ratug/introduction-to-oracle-database-testing.html
Document 1464274.1 Primary Note for Real Application Testing Option

2. 使用 Performance Hub

EM Express 的性能中心(Performance Hub)功能提供了一个活跃报告,汇总了指定时间段内的所有性能数据。该报告是完全交互式的,其内容保存在 HTML 文件中,您可以通过网页浏览器离线访问。有关性能中心的更多信息,请参考以下教程。

使用 EM Express 的性能中心(Perf Hub): https://docs.oracle.com/en/database/oracle/oracle-database/tutorial-monitor-perf/index.html?opt-release-19c#UsePerformanceHub
不使用 EM Express 的性能中心(Perf Hub): Document 2436566.1 Monitoring Database Performance Using Performance Hub Report

3. 实时监控 ADDM

一种预测工具,用于主动预见 19c 生产环境中的性能问题,并采取纠正措施以避免任何系统停机情况。

Document 2763576.1 Proactively Detecting Database Performance Problem Using Real-Time ADDM

4. 下载最新的 ORAchk / EXAchk

建议下载并安装最新的 AHF 或 ORAchk/EXAchk,这可以用于检查任何异常并采取纠正措施。

Document 2550798.1 Autonomous Health Framework (AHF) – Including TFA and ORAchk/EXAChk

5. 安装 OS Watcher

建议在升级后安装最新版本的 OS Watcher,以便在需要时收集与操作系统相关的信息。

Document 301137.1 OS Watcher User Guide
Document 461053.1 OS Watcher Analyzer User Guide

有关数据库性能的更多信息:-

Document 402983.1 Primary Note: Database Performance Overview
Document 1306791.2 Information Center: Oracle Exadata Database Machine

免责声明: 为了避免在打补丁或打完补丁后出现任何问题,建议在 UAT 环境中应用上述补丁并进行验证,然后再应用到生产环境。本文件将在每个季度(在发布季度 RU/RUR 期间)与新的候选补丁进行修订。

转载:避免 19c 数据库性能问题需要考虑的事项 (Doc ID 3050476.1)