10g初始化引數AUDIT_TRAIL變化(一)

yangtingkun發表於2010-12-06

9i中,初始化引數AUDIT_TRAIL只有NONEDBOS三個可選值,而在10g中,Oracle又增加了幾個新的選項。

這篇介紹XML選項。

 

 

資料庫版本和預設AUDIT_TRAIL引數設定:

SQL> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi
PL/SQL Release 10.2.0.3.0 - Production
CORE    10.2.0.3.0      Production
TNS for Linux: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production

SQL> show parameter audit_trail

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
audit_trail                          string      NONE

下面設定引數為XML,並重啟資料庫:

SQL> alter system set audit_trail = xml scope = spfile;

System altered.

SQL> conn / as sysdba
Connected.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area 2147483648 bytes
Fixed Size                  2074112 bytes
Variable Size             486541824 bytes
Database Buffers         1644167168 bytes
Redo Buffers               14700544 bytes
Database mounted.
Database opened.
SQL> show parameter audit

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
audit_file_dest                      string      /opt/ora10g/admin/primary/adump
audit_sys_operations                 boolean     FALSE
audit_syslog_level                   string
audit_trail                          string      XML

資料庫中開啟審計並觸發:

SQL> audit create table;

Audit succeeded.

SQL> conn test/test
Connected.
SQL> create table t_audit (id number);

Table created.

雖然XML引數設定會使得審計資訊寫到作業系統中,不過Oracle仍然提供了檢視可以訪問到所有的AUDIT記錄:

SQL> select audit_type, db_user, object_name, statement_type, sql_text, os_privilege
  2  from dba_common_audit_trail;

AUDIT_TYPE             DB_USER  OBJECT_NAME  STATEMENT_TYPE  SQL_TEXT             OS_PRIV
---------------------- -------- ------------ --------------- -------------------- -------
Mandatory XML Audit    /                                     CONNECT              SYSDBA
Mandatory XML Audit    /                                     CONNECT              SYSDBA
Standard XML Audit     TEST     T_AUDIT      CREATE TABLE

DBA_COMMON_AUDIT_TRAIL檢視提供了包括OSDBXML所有目的地的AUDIT_TRAIL,而V$XML_AUDIT_TRAIL則只包含XML格式的記錄。

SQL> select audit_type, db_user, object_name, statement_type, sql_text, os_privilege
  2  from v$xml_audit_trail;

AUDIT_TYPE DB_USER  OBJECT_NAME  STATEMENT_TYPE SQL_TEXT                       OS_PRIV
---------- -------- ------------ -------------- ------------------------------ -------
         8 /                                  0 CONNECT                        SYSDBA
         8 /                                  0 CONNECT                        SYSDBA
         1 TEST     T_AUDIT                   0

也可以在作業系統上檢查對應的AUDIT_TRAILXML檔案:

[oracle@yans1 ~]$ cd /opt/ora10g/admin/primary/adump/
[oracle@yans1 adump]$ more ora_3221182856.xml

     xmlns:xsi=""
   xsi:schemaLocation="">
   10.2
12000271tamp>2010-12-06T21:34:29.880932TESToracleyans1ocess>8655pts/20TEST>T_AUDIT110001E00030000000
0

 

 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/4227/viewspace-681035/,如需轉載,請註明出處,否則將追究法律責任。

相關文章