Home Database Mysql Tutorial 深入了解Oracle跟踪事件:set events

深入了解Oracle跟踪事件:set events

Jun 07, 2016 pm 03:13 PM
events oracle set learn event go deep track

欢迎进入Oracle社区论坛,与200万技术人员互动交流 >>进入 一、Oracle跟踪文件 Oracle跟踪文件分为三种类型,一种是后台报警日志文件,记录数据库在启动、关闭和运行期间后台进程的活动情况,如表空间创建、回滚段创建、某些alter命令、日志切换、错误消息等

欢迎进入Oracle社区论坛,与200万技术人员互动交流 >>进入

        一、Oracle跟踪文件

        Oracle跟踪文件分为三种类型,一种是后台报警日志文件,记录数据库在启动、关闭和运行期间后台进程的活动情况,如表空间创建、回滚段创建、某些alter命令、日志切换、错误消息等。在数据库出现故障时,应首先查看该文件,但文件中的信息与任何错误状态没有必然的联系。后台报警日志文件保存BACKGROUND_DUMP_DEST参数指定的目录中,文件格式为SIDALRT.LOG。另一种类型是DBWR、LGWR、SMON等后台进程创建的后台跟踪文件。后台跟踪文件根据后台进程运行情况产生,后台跟踪文件也保存在BACKGROUND_DUMP_DEST参数指定的目录中,文件格式为siddbwr.trc、sidsmon.trc等。还有一种类型是由连接到Oracle的用户进程(Server Processes)生成的用户跟踪文件。这些文件仅在用户会话期间遇到错误时产生。此外,用户可以通过执行oracle跟踪事件(见后面)来生成该类文件,用户跟踪文件保存在USER_DUMP_DEST参数指定的目录中,文件格式为oraxxxxx.trc,xxxxx为创建文件的进程号(或线程号)。

        二、Oracle跟踪事件

        Oracle提供了一类命令,可以将Oracle各类内部结构中所包含的信息转储(dump)到跟踪文件中,以便用户能根据文件内容来解决各种故障。设置跟踪事件有两种方法,一种是在init.ora文件中设置事件,这样open数据库后,将影响到所有的会话。设置格式如下:

         EVENT="eventnumber trace name eventname [forever,] [level levelnumber] : ......."

        通过:符号,可以连续设置多个事件,也可以通过连续使用event来设置多个事件。

        另一种方法是在会话过程中使用alter session set events命令,只对当前会话有影响。设置格式如下:

         alter session set events '[eventnumber|immediate] trace name eventname [forever] [, level levelnumber] : .......'

        通过:符号,可以连续设置多个事件,也可以通过连续使用alter session set events 来设置多个事件。

        格式说明:eventnumber指触发dump的事件号,事件号可以是Oracle错误号(出现相应错误时跟踪指定的事件)或oralce内部事件号,内部事件号在10000到10999之间,不能与immediate关键字同用。

        immediate关键字表示命令发出后,立即将指定的结构dump到跟踪文件中,这个关键字只用在alter session语句中,并且不能与 eventnumber、forever关键字同用。

        trace name 是关键字。

        eventname指事件名称(见后面),即要进行dump的实际结构名。若eventname为context,则指根据内部事件号进行跟踪。

        forever关键字表示事件在实例或会话的周期内保持有效状态,不能与immediate同用。

        level为事件级别关键字。但在dump错误栈(errorstack)时不存在级别。

        levelnumber表示事件级别号,一般从1到10,1表示只dump结构头部信息,10表示dump结构的所有信息。

        1、buffers事件:dump SGA缓冲区中的db buffer结构

         alter session set events 'immediate trace name buffers level 1'; --表示dump缓冲区的头部。

        2、blockdump事件:dump数据文件、索引文件、回滚段文件结构

         alter session set events 'immediate trace name blockdump level 66666'; --表示dump块地址为6666的数据块。

        在Oracle 8以后该命令已改为:

         alter system dump datafile 11 block 9; --表示dump数据文件号为11中的第9个数据块。

        3、controlf事件:dump控制文件结构

         alter session set events 'immediate trace name controlf level 10'; --表示dump控制文件的所有内容。

        4、locks事件:dump LCK进程的锁信息

         alter session set events 'immediate trace name locks level 5';

        5、redohdr事件:dump redo日志的头部信息

         alter session set events 'immediate trace name redohdr level 1'; --表示dump redo日志头部的控制文件项。
        alter session set events 'immediate trace name redohdr level 2'; --表示dump redo日志的通用文件头。
        alter session set events 'immediate trace name redohdr level 10'; --表示dump redo日志的完整文件头。

        注意:redo日志的内容dump可以采用下面的语句:

         alter system dump logfile 'logfilename';

        6、loghist事件:dump控制文件中的日志历史项

        alter session set events 'immediate trace name loghist level 1'; --表示只dump最早和最迟的日志历史项。

        levelnumber大于等于2时,表示2的levelnumber次方个日志历史项。

        alter session set events 'immediate trace name loghist level 4'; --表示dump 16个日志历史项。

        7、file_hdrs事件:dump 所有数据文件的头部信息

         alter session set events 'immediate trace name file_hdrs level 1'; --表示dump 所有数据文件头部的控制文件项。
        alter session set events 'immediate trace name file_hdrs level 2'; --表示dump 所有数据文件的通用文件头。
        alter session set events 'immediate trace name file_hdrs level 10'; --表示dump 所有数据文件的完整文件头。

        8、errorstack事件:dump 错误栈信息,通常Oracle发生错误时前台进程将得到一条错误信息,但某些情况下得不到错误信息,可以采用这种方式得到Oracle错误。

         alter session set events '604 trace name errorstack forever'; --表示当出现604错误时,dump 错误栈和进程栈。

        9、systemstate事件:dump所有系统状态和进程状态

         alter session set events 'immediate trace name systemstate level 10'; --表示dump 所有系统状态和进程状态。

[1] [2] [3] [4] 

深入了解Oracle跟踪事件:set events

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to check tablespace size of oracle How to check tablespace size of oracle Apr 11, 2025 pm 08:15 PM

To query the Oracle tablespace size, follow the following steps: Determine the tablespace name by running the query: SELECT tablespace_name FROM dba_tablespaces; Query the tablespace size by running the query: SELECT sum(bytes) AS total_size, sum(bytes_free) AS available_space, sum(bytes) - sum(bytes_free) AS used_space FROM dba_data_files WHERE tablespace_

How to encrypt oracle view How to encrypt oracle view Apr 11, 2025 pm 08:30 PM

Oracle View Encryption allows you to encrypt data in the view, thereby enhancing the security of sensitive information. The steps include: 1) creating the master encryption key (MEk); 2) creating an encrypted view, specifying the view and MEk to be encrypted; 3) authorizing users to access the encrypted view. How encrypted views work: When a user querys for an encrypted view, Oracle uses MEk to decrypt data, ensuring that only authorized users can access readable data.

How to import oracle database How to import oracle database Apr 11, 2025 pm 08:06 PM

Data import method: 1. Use the SQLLoader utility: prepare data files, create control files, and run SQLLoader; 2. Use the IMP/EXP tool: export data, import data. Tip: 1. Recommended SQL*Loader for big data sets; 2. The target table should exist and the column definition matches; 3. After importing, data integrity needs to be verified.

How to create a table in oracle How to create a table in oracle Apr 11, 2025 pm 08:00 PM

Creating an Oracle table involves the following steps: Use the CREATE TABLE syntax to specify table names, column names, data types, constraints, and default values. The table name should be concise and descriptive, and should not exceed 30 characters. The column name should be descriptive, and the data type specifies the data type stored in the column. The NOT NULL constraint ensures that null values ​​are not allowed in the column, and the DEFAULT clause specifies the default values ​​for the column. PRIMARY KEY Constraints to identify the unique record of the table. FOREIGN KEY constraint specifies that the column in the table refers to the primary key in another table. See the creation of the sample table students, which contains primary keys, unique constraints, and default values.

How to uninstall Oracle installation failed How to uninstall Oracle installation failed Apr 11, 2025 pm 08:24 PM

Uninstall method for Oracle installation failure: Close Oracle service, delete Oracle program files and registry keys, uninstall Oracle environment variables, and restart the computer. If the uninstall fails, you can uninstall manually using the Oracle Universal Uninstall Tool.

How to view instance name of oracle How to view instance name of oracle Apr 11, 2025 pm 08:18 PM

There are three ways to view instance names in Oracle: use the "sqlplus" and "select instance_name from v$instance;" commands on the command line. Use the "show instance_name;" command in SQL*Plus. Check environment variables (ORACLE_SID on Linux) through the operating system's Task Manager, Oracle Enterprise Manager, or through the operating system.

How to get time in oracle How to get time in oracle Apr 11, 2025 pm 08:09 PM

There are the following methods to get time in Oracle: CURRENT_TIMESTAMP: Returns the current system time, accurate to seconds. SYSTIMESTAMP: More accurate than CURRENT_TIMESTAMP, to nanoseconds. SYSDATE: Returns the current system date, excluding the time part. TO_CHAR(SYSDATE, 'YYY-MM-DD HH24:MI:SS'): Converts the current system date and time to a specific format. EXTRACT: Extracts a specific part from a time value, such as a year, month, or hour.

How to read the oracle awr report How to read the oracle awr report Apr 11, 2025 pm 09:45 PM

An AWR report is a report that displays database performance and activity snapshots. The interpretation steps include: identifying the date and time of the activity snapshot. View an overview of activities and resource consumption. Analyze session activities to find session types, resource consumption, and waiting events. Find potential performance bottlenecks such as slow SQL statements, resource contention, and I/O issues. View waiting events, identify and resolve them for performance. Analyze latch and memory usage patterns to identify memory issues that are causing performance issues.

See all articles