
Oracle Audit 功能的使用和说明
审计(Audit) 用于监视用户所执行的数据库操作,审计记录可存在数据字典表(称为审计记录:存储在 system 表空间
中的 SYS.AUD$ 表中,可通过视图 dba_audit_trail 查看)或操作系统审计记录中(默认位置为
$ORACLE_BASE/admin/$ORACLE_SID/adump/).。默认情况下审计是没有开启的。
不管你是否打开数据库的审计功能,以下这些操作系统会强制记录:用管理员权限连接 Instance;启动数据库;关闭数
据库。
和审计相关的两个主要参数
1、audit_sys_operations
AUDIT_SYS_OPERATIONS enables or disables the auditing of top-level operations, which are SQL statements
directly issued by users when connecting with SYSDBA or SYSOPER privileges.(SQL statements run from within
PL/SQL procedures or functions are not considered top-level.) The audit records are written to the operating
system'saudit trail. The audit records will be written in XML format if the AUDIT_TRAIL initialization parameter is set to
xml or xml, extended.
On UNIX platforms, if the AUDIT_SYSLOG_LEVEL parameter has also been set, then it overrides the
AUDIT_TRAIL parameter and SYS audit records are written to the system audit log using the SYSLOG utility.
默认为 false,当设置为 true 时,所有 sys 用户(包括以 sysdba, sysoper 身份登录的用户)的操作都会被记录,audit
trail 不会写在 aud$表中,这个很好理解,如果数据库还未启动 aud$不可用,那么像 conn /as sysdba 这样的连接信息,
只能记录在其它地方。如果是 windows 平台,audti trail 会记录在 windows 的事件管理中,如果是 linux/unix 平台则会
记录在 audit_file_dest 参数指定的文件中。
2、audit_trail
AUDIT_TRAIL = { none | os | db | db,extended | xml | xml,extended }
none or false - Auditing is disabled. 是默认值,不做审计;
db or true - Auditing is enabled, with all audit records stored in the database audit trial (SYS.AUD$). 将 audit
trail 记录在数据库的审计相关表中,如 aud$,审计的结果只有连接信息;
db,extended - As db, but the SQL_BIND and SQL_TEXT columns are also populated. 审计结果里面除了连
接信息还包含了当时执行的具体语句;
xml- Auditing is enabled, with all audit records stored as XML format OS files. 10g 里新增的。
xml,extended - As xml, but the SQL_BIND and SQL_TEXT columns are also populated. 10g 里新增的。
os- Auditing is enabled, with all audit records directed to the operating system's audit trail. 将 audit trail 记录
在操作系统文件中,文件名由 audit_file_dest 参数指定;
注:这两个参数是 static 参数,需要重新启动数据库才能生效。
当开启审计功能后,可在三个级别对数据库进行审计:Statement(语句)、Privilege(权限)、object(对象)。
1、 Statement(语句审计)
对某种类型的 SQL 语句审计,不指定结构或对象。比如 audit table 会审计数据库中所有的 create table、drop table、
truncate table 语句,alter session by cmy 会审计 cmy 用户所有的数据库连接。
评论