Oracle数据库诊断文件(日志)查看

Diagnostic File(诊断文件)

1:诊断文件的作用

Diagnostic files :
包含了后台遇见重大事件的信息。
被用于解析问题,
被用于日常管理日志文件。

2:诊断文件日志的分类

分为两类:

   1: alterSID.log

                               -----background trace files (后台进程跟踪文件)

    2: trace files ---

                               -----user trace file (用户trace 文件)

 1:对于Background trace files文件的命名:

命名方式: SID_processname_PID.trc  对应解释  SID_进程名_进程号.trc


2:   对于user trace files 的文件命名为:

SID_ora_PID.trc  解释: SID_ora_进程号.trc


3:对于 alertSID.log 说明:

 这个文件是为了记录: 1:记录一些操作命令
                                      2:记录主要事件的结果
                                      3:以及日常的操作信息
                                      4:被用于诊断数据库错误

每一个entry 都有一个time stamp(时间戳)和它关联

该文件必须被ORACLE DBA管理

这个文件的位置在:  BACKGROUND_DUMP_DEST

通过 show parameter dump 查看这个文件的位置:


这个文件中也包含数据库的启动信息相当于pfile或者spfile的内容。
用管理员登录: 


2:下面是实战操作:

首先用sysdba登录后执行:

SQL> show parameter dump

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
background_core_dump                 string      partial
background_dump_dest                 string      d:\app\topwqp\diag\rdbms\orcl\
                                                 orcl\trace
core_dump_dest                       string      d:\app\topwqp\diag\rdbms\orcl\
                                                 orcl\cdump
max_dump_file_size                   string      unlimited
shadow_core_dump                     string      none
user_dump_dest                       string      d:\app\topwqp\diag\rdbms\orcl\
                                                 orcl\trace                     
可以看到这些文件的路径信息。

根据显式的信息我找到我的文件位置:

目录结构如下:

Oracle数据库诊断文件(日志)查看_第1张图片

下面说一下如何才能记录信息到这些日志文件,需要一些开关,如果不开,记录的只是

一点点信息而已:

两种方式 能够让用户tracing


1:session 级别的:
使用如下命令:
ALTER SESSSION SET SQL_TRACE = TRUE
第二种是执行如下存储过程:
dbms_system.SET_SQL_TRACE_IN_SESSION


第二个方式是 instance级别的:
设置初始化参数:  SQL_TRACE = TRUE


一般采用session级别的。因为设置instance级别的容易造成log文件过大;


可以通过alterSID.log文件中的信息制作pfile 或者spfile文件启动
数据库。


下面采用session级别的修改sql_trace为true即可在user_dump_dest中对应文件中看到相应的信息。

SQL> conn /as  sysdba
已连接。
SQL> alter session set sql_trace = true;

会话已更改。

执行过后:查看

orcl_ora_7188.trc文件信息 PS:如果不知道哪个文件就把这个目录下的全部删除,再执行sql就会看到生成的文件:

查看这个文件信息如下:

很详细的执行信息:

比如一个语句为:select * from dual

这个文件中会生成如下信息:

*** 2013-06-13 22:58:20.776
=====================
PARSING IN CURSOR #1 len=18 dep=0 uid=0 oct=3 lid=0 tim=9184375464 hv=942515969 ad='232363f8' sqlid='a5ks9fhw2v9s1'
select * from dual
END OF STMT
PARSE #1:c=0,e=32,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,tim=9184375458
EXEC #1:c=0,e=50,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,tim=9184376205
FETCH #1:c=0,e=109,p=0,cr=3,cu=0,mis=0,r=1,dep=0,og=1,tim=9184376423
STAT #1 id=1 cnt=1 pid=0 pos=1 obj=115 op='TABLE ACCESS FULL DUAL (cr=3 pr=0 pw=0 time=0 us cost=2 size=2 card=1)'
FETCH #1:c=0,e=2,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=0,tim=9184376893

是对这个sql的执行的详细解读分析


下面贴上今天的部分执行的信息:

*** 2013-06-13 22:58:20.776
=====================
PARSING IN CURSOR #1 len=18 dep=0 uid=0 oct=3 lid=0 tim=9184375464 hv=942515969 ad='232363f8' sqlid='a5ks9fhw2v9s1'
select * from dual
END OF STMT
PARSE #1:c=0,e=32,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,tim=9184375458
EXEC #1:c=0,e=50,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,tim=9184376205
FETCH #1:c=0,e=109,p=0,cr=3,cu=0,mis=0,r=1,dep=0,og=1,tim=9184376423
STAT #1 id=1 cnt=1 pid=0 pos=1 obj=115 op='TABLE ACCESS FULL DUAL (cr=3 pr=0 pw=0 time=0 us cost=2 size=2 card=1)'
FETCH #1:c=0,e=2,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=0,tim=9184376893

*** 2013-06-13 23:15:15.474
=====================
PARSING IN CURSOR #1 len=289 dep=0 uid=0 oct=3 lid=0 tim=10199053291 hv=2462394820 ad='232017e0' sqlid='7cfz5wy9caaf4'
SELECT NAME NAME_COL_PLUS_SHOW_PARAM,DECODE(TYPE,1,'boolean',2,'string',3,'integer',4,'file',5,'number',        6,'big integer', 'unknown') TYPE,DISPLAY_VALUE VALUE_COL_PLUS_SHOW_PARAM FROM V$PARAMETER WHERE UPPER(NAME) LIKE UPPER(:NMBIND_SHOW_OBJ) ORDER BY NAME_COL_PLUS_SHOW_PARAM,ROWNUM
END OF STMT
PARSE #1:c=0,e=438,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=1,tim=10199053285
=====================
PARSING IN CURSOR #2 len=210 dep=1 uid=0 oct=3 lid=0 tim=10199056088 hv=864012087 ad='29162590' sqlid='96g93hntrzjtr'
select /*+ rule */ bucket_cnt, row_cnt, cache_cnt, null_cnt, timestamp#, sample_size, minimum, maximum, distcnt, lowval, hival, density, col#, spare1, spare2, avgcln from hist_head$ where obj#=:1 and intcol#=:2
END OF STMT
PARSE #2:c=0,e=568,p=0,cr=0,cu=0,mis=1,r=0,dep=1,og=3,tim=10199056084
EXEC #2:c=0,e=1024,p=0,cr=0,cu=0,mis=1,r=0,dep=1,og=3,tim=10199057412
FETCH #2:c=0,e=30,p=0,cr=2,cu=0,mis=0,r=0,dep=1,og=3,tim=10199057533
STAT #2 id=1 cnt=0 pid=0 pos=1 obj=411 op='TABLE ACCESS BY INDEX ROWID HIST_HEAD$ (cr=2 pr=0 pw=0 time=0 us)'
STAT #2 id=2 cnt=0 pid=1 pos=1 obj=413 op='INDEX RANGE SCAN I_HH_OBJ#_INTCOL# (cr=2 pr=0 pw=0 time=0 us)'
=====================
PARSING IN CURSOR #2 len=210 dep=1 uid=0 oct=3 lid=0 tim=10199057848 hv=864012087 ad='29162590' sqlid='96g93hntrzjtr'
select /*+ rule */ bucket_cnt, row_cnt, cache_cnt, null_cnt, timestamp#, sample_size, minimum, maximum, distcnt, lowval, hival, density, col#, spare1, spare2, avgcln from hist_head$ where obj#=:1 and intcol#=:2
END OF STMT
EXEC #2:c=0,e=25,p=0,cr=0,cu=0,mis=0,r=0,dep=1,og=3,tim=10199057844
FETCH #2:c=0,e=13,p=0,cr=2,cu=0,mis=0,r=0,dep=1,og=3,tim=10199058128
EXEC #1:c=0,e=7034,p=0,cr=4,cu=0,mis=1,r=0,dep=0,og=1,tim=10199060756
FETCH #1:c=15600,e=13882,p=0,cr=0,cu=0,mis=0,r=1,dep=0,og=1,tim=10199075783
FETCH #1:c=0,e=21,p=0,cr=0,cu=0,mis=0,r=5,dep=0,og=1,tim=10199076326
STAT #1 id=1 cnt=6 pid=0 pos=1 obj=0 op='SORT ORDER BY (cr=0 pr=0 pw=0 time=0 us cost=2 size=2115 card=1)'
STAT #1 id=2 cnt=6 pid=1 pos=1 obj=0 op='COUNT  (cr=0 pr=0 pw=0 time=8 us)'
STAT #1 id=3 cnt=6 pid=2 pos=1 obj=0 op='HASH JOIN  (cr=0 pr=0 pw=0 time=6 us cost=1 size=2115 card=1)'
STAT #1 id=4 cnt=35 pid=3 pos=1 obj=0 op='FIXED TABLE FULL X$KSPPI (cr=0 pr=0 pw=0 time=70 us cost=0 size=81 card=1)'
STAT #1 id=5 cnt=1915 pid=3 pos=2 obj=0 op='FIXED TABLE FULL X$KSPPCV (cr=0 pr=0 pw=0 time=19 us cost=0 size=203400 card=100)'


关于alter_SID.log中的内容如下: 今天的:

注意这个文件中包含Oracle启动的参数信息:可以利用这些信息配置spfile或者pfile文件尝试用这个配置的文件启动数据库也可以的

Thu Jun 13 22:13:43 2013
Starting ORACLE instance (normal)
LICENSE_MAX_SESSION = 0
LICENSE_SESSIONS_WARNING = 0
Picked latch-free SCN scheme 2
Using LOG_ARCHIVE_DEST_1 parameter default value as D:\app\topwqp\product\11.1.0\db_1\RDBMS
Using LOG_ARCHIVE_DEST_10 parameter default value as USE_DB_RECOVERY_FILE_DEST
Autotune of undo retention is turned on. 
IMODE=BR
ILAT =18
LICENSE_MAX_USERS = 0
SYS auditing is disabled
Starting up ORACLE RDBMS Version: 11.1.0.6.0.
Using parameter settings in server-side spfile D:\APP\TOPWQP\PRODUCT\11.1.0\DB_1\DATABASE\SPFILEORCL.ORA
System parameters with non-default values:
  processes                = 150
  memory_target            = 412M
  control_files            = "D:\APP\TOPWQP\ORADATA\ORCL\CONTROL01.CTL"
  control_files            = "D:\APP\TOPWQP\ORADATA\ORCL\CONTROL02.CTL"
  control_files            = "D:\APP\TOPWQP\ORADATA\ORCL\CONTROL03.CTL"
  db_block_size            = 8192
  compatible               = "11.1.0.0.0"
  db_recovery_file_dest    = "D:\app\topwqp\flash_recovery_area"
  db_recovery_file_dest_size= 2G
  fast_start_mttr_target   = 0
  undo_tablespace          = "UNDOTBS1"
  remote_login_passwordfile= "EXCLUSIVE"
  db_domain                = ""
  dispatchers              = "(PROTOCOL=TCP) (SERVICE=orclXDB)"
  audit_file_dest          = "D:\APP\TOPWQP\ADMIN\ORCL\ADUMP"
  audit_trail              = "DB"
  db_name                  = "orcl"
  open_cursors             = 300
  diagnostic_dest          = "D:\APP\TOPWQP"
Thu Jun 13 22:13:46 2013
PMON started with pid=2, OS id=1888 
Thu Jun 13 22:13:46 2013
VKTM started with pid=3, OS id=4296 at elevated priority
Thu Jun 13 22:13:46 2013
DIAG started with pid=4, OS id=6804 
VKTM running at (20)ms precision
Thu Jun 13 22:13:46 2013
DBRM started with pid=5, OS id=7360 
Thu Jun 13 22:13:46 2013
PSP0 started with pid=6, OS id=648 
Thu Jun 13 22:13:46 2013
DSKM started with pid=7, OS id=7460 
Thu Jun 13 22:13:46 2013
DIA0 started with pid=8, OS id=1592 
Thu Jun 13 22:13:46 2013
MMAN started with pid=7, OS id=4512 
Thu Jun 13 22:13:46 2013
DBW0 started with pid=9, OS id=6920 
Thu Jun 13 22:13:46 2013
LGWR started with pid=10, OS id=3712 
Thu Jun 13 22:13:46 2013
CKPT started with pid=11, OS id=6512 
Thu Jun 13 22:13:46 2013
SMON started with pid=12, OS id=7992 
Thu Jun 13 22:13:46 2013
RECO started with pid=13, OS id=7056 
Thu Jun 13 22:13:46 2013
MMON started with pid=14, OS id=7844 
starting up 1 dispatcher(s) for network address '(ADDRESS=(PARTIAL=YES)(PROTOCOL=TCP))'...
Thu Jun 13 22:13:46 2013
MMNL started with pid=15, OS id=6284 
starting up 1 shared server(s) ...
ORACLE_BASE from environment = D:\app\topwqp
Thu Jun 13 22:13:46 2013
alter database mount exclusive
Setting recovery target incarnation to 2
Successful mount of redo thread 1, with mount id 1345846942
Database mounted in Exclusive Mode
Lost write protection disabled
Completed: alter database mount exclusive
alter database open
Beginning crash recovery of 1 threads
 parallel recovery started with 3 processes
Started redo scan
Thu Jun 13 22:13:56 2013
Completed redo scan
 4095 redo blocks read, 510 data blocks need recovery
Started redo application at
 Thread 1: logseq 434, block 67636
Recovery of Online Redo Log: Thread 1 Group 2 Seq 434 Reading mem 0
  Mem# 0: D:\APP\TOPWQP\ORADATA\ORCL\REDO02.LOG
Completed redo application
Completed crash recovery at
 Thread 1: logseq 434, block 71731, scn 5101264
 510 data blocks read, 510 data blocks written, 4095 redo blocks read
Thu Jun 13 22:14:00 2013
Thread 1 advanced to log sequence 435
Thread 1 opened at log sequence 435
  Current log# 3 seq# 435 mem# 0: D:\APP\TOPWQP\ORADATA\ORCL\REDO03.LOG
Successful open of redo thread 1
MTTR advisory is disabled because FAST_START_MTTR_TARGET is not set
Thu Jun 13 22:14:01 2013
SMON: enabling cache recovery
Successfully onlined Undo Tablespace 2.
Verifying file header compatibility for 11g tablespace encryption..
Verifying 11g file header compatibility for tablespace encryption completed
SMON: enabling tx recovery
Database Characterset is ZHS16GBK
Opening with internal Resource Manager plan
Starting background process FBDA
Starting background process SMCO
Thu Jun 13 22:14:06 2013
FBDA started with pid=22, OS id=4524 
Thu Jun 13 22:14:06 2013
SMCO started with pid=23, OS id=6344 
Thu Jun 13 22:14:07 2013
replication_dependency_tracking turned off (no async multimaster replication found)
Starting background process QMNC
Thu Jun 13 22:14:09 2013
QMNC started with pid=25, OS id=7168 
Thu Jun 13 22:14:20 2013
db_recovery_file_dest_size of 2048 MB is 0.00% used. This is a
user-specified limit on the amount of space that will be used by this
database for recovery-related files, and does not reflect the amount of
space available in the underlying filesystem or ASM diskgroup.
Thu Jun 13 22:14:30 2013
Completed: alter database open
Thu Jun 13 22:18:50 2013
Starting background process CJQ0
Thu Jun 13 22:18:50 2013
CJQ0 started with pid=28, OS id=5912 
Setting Resource Manager plan SCHEDULER[0x2C0C]:DEFAULT_MAINTENANCE_PLAN via scheduler window
Setting Resource Manager plan DEFAULT_MAINTENANCE_PLAN via parameter
Thu Jun 13 22:19:07 2013
Thu Jun 13 22:19:07 2013
Logminer Bld: Lockdown Complete.  DB_TXN_SCN is   UnwindToSCN (LockdownSCN) is 5102149
Thu Jun 13 22:19:11 2013
Begin automatic SQL Tuning Advisor run for special tuning task  "SYS_AUTO_SQL_TUNING_TASK"
Thu Jun 13 22:20:29 2013
End automatic SQL Tuning Advisor run for special tuning task  "SYS_AUTO_SQL_TUNING_TASK"

oracle的启动参数信息如下:

System parameters with non-default values:
  processes                = 150
  memory_target            = 412M
  control_files            = "D:\APP\TOPWQP\ORADATA\ORCL\CONTROL01.CTL"
  control_files            = "D:\APP\TOPWQP\ORADATA\ORCL\CONTROL02.CTL"
  control_files            = "D:\APP\TOPWQP\ORADATA\ORCL\CONTROL03.CTL"
  db_block_size            = 8192
  compatible               = "11.1.0.0.0"
  db_recovery_file_dest    = "D:\app\topwqp\flash_recovery_area"
  db_recovery_file_dest_size= 2G
  fast_start_mttr_target   = 0
  undo_tablespace          = "UNDOTBS1"
  remote_login_passwordfile= "EXCLUSIVE"
  db_domain                = ""
  dispatchers              = "(PROTOCOL=TCP) (SERVICE=orclXDB)"
  audit_file_dest          = "D:\APP\TOPWQP\ADMIN\ORCL\ADUMP"
  audit_trail              = "DB"
  db_name                  = "orcl"
  open_cursors             = 300
  diagnostic_dest          = "D:\APP\TOPWQP"

这些信息可以用于pfile或者spfile内容。



你可能感兴趣的:(Oracle数据库诊断文件(日志)查看)