您好,登錄后才能下訂單哦!
本篇內容介紹了“audit審計方法是什么”的有關知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠學有所成!
audit_trail 的value值為NONE表示不開啟;
和審計相關的兩個主要參數:
1.audit_sys_operations:默認為false,當設置為true時,審計管理用戶(sysdba/sysoper角色登陸)的操作都會被記錄,audit trail不會寫在aud$表中,這個很好理解,如果數據庫還未啟動aud$不可用,那么像conn /as sysdba這樣的連接信息,只能記錄在其它地方。如果是windows平臺,audti trail會記錄在windows的事件管理中,如果是linux/unix平臺則會記錄在audit_file_dest參數指定的文件中。
2.audit_trail:None:是10g默認值,不做審計;11g默認值DB,將審計結果記錄到aud$表中;
audit_trail 的value值為FALSE表示不開啟;
audit_trail 的value值為DB表示開啟;
audit_trail 的value值為TURE表示開啟;
audit_trail 的value值為OS表示審計記錄寫入一個操作系統文
3.oracle 審計日志清理
--進入審計日志目錄:
cd $ORACLE_BASE/admin/$ORACLE_SID/adump
--刪除3個月前的審計文件:
find ./ -type f -name "*.aud" -mtime +91|xargs rm -f
--一次清空所有審計文件
find ./ -type f -name "*.aud"|xargs rm-f
find ./ -mtime +7 -name "*.aud" -type f –delete
注意:
oracle在$ORACLE_BASE/admin/$ORACLE_SID/adump 目錄中記陸后綴為.aud的審計文件。
所以,開了DB功能,會同時將審計日志記在AUD$表中和操作系統aud文件中。設置為NONE,仍然會而且毫無其他辦法的將記錄在操作系統aud文件中。
*數據庫的表為:sys.aud$
*操作系統目錄為:$ORACLE_BASE/admin/實例名/adump/
4.審計:
4.1 強制性審計
啟停數據庫等動作,都記錄在了 alert 日志中,這些就是強制審計,是 oracle
自動開啟的。
4.2 標準數據庫審計
show parameter audit_trail
4.3 基于值審計
這個是通過我們自己編寫的觸發器來完成的。
4.4 細粒度審計 (FGA)
可以針對某一列進行更細致的審計
4.5 DBA 審計
安全管理員對 DBA 的審計
標準數據庫審計
- 審計語法:
audit sql_statement_clause by {session | access} whenever [not] successful;
by session,在一個會話中,同類型的操作只審計一條
by access,每個符合審計的操作全部審計
- 審計相關參數( audit_trail):
audit_trail = { none | os | db [, extended] | xml [, extended] }
none: 10g 默認值,不做審計;
os:將 audit trail 記錄在操作系統文件中,文件名由 audit_file_dest 參數指定;
db: 11g 默認值,將審計結果記錄到 aud$表中;
db,extended:將審計結果記錄到 aud$表中,同時包括綁定變量及 CLOB 字段;
xml:記錄 OS 文件的是 XML 格式的審計記錄;
xml,extended:記錄OS 文件的是 XML 格式的審計記錄,同時包括綁定變量及 CLOB 字段。
oracle10g:默認審計參數為 NONE,即未開啟
Oracle11g:默認審計參數為 DB
實驗一:審計開啟os
[oracle@wang ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Sun Aug 13 08:11:24 2017
Copyright (c) 1982, 2013, Oracle. All rights reserved.Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> show parameter audit
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
audit_file_dest string /u01/app/oracle/admin/DBdb/adump
audit_sys_operations boolean FALSE
audit_syslog_level string
audit_trail string DB
SQL>
SQL> alter system set audit_trail='OS' scope=spfile;
System altered.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 835104768 bytes
Fixed Size 2257840 bytes
Variable Size 549456976 bytes
Database Buffers 281018368 bytes
Redo Buffers 2371584 bytes
Database mounted.
Database opened.
SQL>
SQL> show parameter audit
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
audit_file_dest string /u01/app/oracle/admin/DBdb/adump
audit_sys_operations boolean FALSE
audit_syslog_level string
audit_trail string OS
SQL>
--查看os層的審計文件
[oracle@wang adump]$ cd /u01/app/oracle/admin/DBdb/adump
--進行相關操作
SQL> conn scott/tiger; Connected. SQL> alter session set nls_date_format='yyyy-mm-dd hh34:mi:ss'; Session altered. SQL> select sysdate from dual; SYSDATE ------------------- 2018-01-26 00:28:58
SQL> select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
BONUS TABLE
DEPT TABLE
EMP TABLE
JOBS TABLE
SQL> create table a as select * from user_objects;
Table created.
SQL> insert into a select * from a;
10 rows created.
SQL> commit;
Commit complete.
SQL> update a set object_id=1;
20 rows updated.
SQL> commit;
Commit complete.
SQL> delete a where rownum <10;
9 rows deleted.
SQL> commit;
Commit complete.
SQL> truncate table a;
Table truncated.
SQL> drop table a purge;
Table dropped.
--查看審計文件:
[oracle@wang adump]$ pwd
/u01/app/oracle/admin/DBdb/adump
[oracle@wang adump]$
[oracle@wang adump]$
[oracle@wang adump]$ ll
total 24
-rw-r----- 1 oracle oinstall 772 Jan 26 00:22 DBdb_ora_27579_20180126002238441832143795.aud
-rw-r----- 1 oracle oinstall 755 Jan 26 00:26 DBdb_ora_27630_20180126002622032142143795.aud
-rw-r----- 1 oracle oinstall 762 Jan 26 00:26 DBdb_ora_27630_20180126002623437420143795.aud
-rw-r----- 1 oracle oinstall 768 Jan 26 00:26 DBdb_ora_27669_20180126002623481070143795.aud
-rw-r----- 1 oracle oinstall 772 Jan 26 00:26 DBdb_ora_27674_20180126002627838313143795.aud
-rw-r----- 1 oracle oinstall 877 Jan 26 00:28 DBdb_ora_27722_20180126002816963203143795.aud
[oracle@wang adump]$
--查看審計日志
[oracle@wang adump]$
more DBdb_ora_27722_20180126002816963203143795.aud
Audit file /u01/app/oracle/admin/DBdb/adump/DBdb_ora_27722_20180126002816963203143795.aud
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1
System name: Linux
Node name: wang
Release: 3.10.0-327.el7.x86_64
Version: #1 SMP Thu Oct 29 17:29:29 EDT 2015
Machine: x86_64
Instance name: DBdb
Redo thread mounted by this instance: 1
Oracle process number: 29
Unix process pid: 27722, image: oracle@wang (TNS V1-V3)
Fri Jan 26 00:28:16 2018 +08:00
LENGTH: "266"
SESSIONID:[7] "7450116" ENTRYID:[1] "1" STATEMENT:[1] "1" USERID:[5] "SCOTT" USERHOST:[4] "wang" TERMINAL:[5] "pts/1" ACTION:[3] "100" RETURNCODE:[1] "0" COMMENT$TEXT:
[26] "Authenticated by: DATABASE" OS$USERID:[6] "oracle" DBID:[10] "3282897732" PRIV$USED:[1] "5"
[oracle@wang adump]$
實驗證明os層不記錄數據庫相關操作,只有一些登入登出數據庫操作實驗二:
SQL> show parameter audit
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
audit_file_dest string /u01/app/oracle/admin/DBdb/adump
audit_sys_operations boolean FALSE
audit_syslog_level string
audit_trail string OS
SQL>
SQL> alter system set audit_trail='DB' scope=spfile;
System altered.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
SQL> startup
ORACLE instance started.
Total System Global Area 835104768 bytes
Fixed Size 2257840 bytes
Variable Size 549456976 bytes
Database Buffers 281018368 bytes
Redo Buffers 2371584 bytes
Database mounted.
Database opened.
SQL>
SQL> show parameter audit
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
audit_file_dest string /u01/app/oracle/admin/DBdb/adump
audit_sys_operations boolean FALSE
audit_syslog_level string
audit_trail string DB
SQL>
SQL>
--確認審計相關的表是否已經安裝
select * from sys.aud$; -- 沒有記錄返回
select * from dba_audit_trail; -- 沒有記錄返回
如果做上述查詢的時候發現表不存在,說明審計相關的表還沒有安裝,需要安裝。
@$ORACLE_HOME/rdbms/admin/cataudit.sql
審計表安裝在SYSTEM表空間。所以要確保SYSTEM表空間又足夠的空間存放審計信息。
--查詢審計表aud$情況:
SQL> col owner for a10
SQL> col table_name for a15
SQL> col TABLESPACE_NAME for a15
SQL> alter session set nls_date_format='yyyy-mm-dd hh34:mi:ss';
Session altered.
SQL> select OWNER,TABLE_NAME,TABLESPACE_NAME,STATUS,LAST_ANALYZED from dba_tables where table_name='AUD$';
OWNER TABLE_NAME TABLESPACE_NAME STATUS LAST_ANALYZED
---------- --------------- --------------- -------- -------------------
SYS AUD$ SYSTEM VALID 2018-01-24 22:01:31
SQL> col segment_name for a15
SQL> select OWNER,SEGMENT_NAME,PARTITION_NAME,TABLESPACE_NAME,BYTES/1024 size_k from dba_segments where SEGMENT_NAME='AUD$';
OWNER SEGMENT_NAME PARTITION_NAME TABLESPACE_NAME SIZE_K
---------- --------------- ------------------------------ --------------- ----------
SYS AUD$ SYSTEM 128
SQL> conn scott/tiger
Connected.
SQL> create table temp as select * from user_objects;
Table created.
SQL> insert into temp select * from temp;
10 rows created.
SQL> commit;
Commit complete.
SQL> update temp set object_name='WANG' where object_id=10;
0 rows updated.
SQL> update temp set object_name='WANG' where object_id=87107;
2 rows updated.
SQL> commit;
Commit complete.
SQL> delete temp where rownum <10;
9 rows deleted.
SQL> commit;
Commit complete.
SQL> truncate table temp;
Table truncated.
SQL> drop table temp purge;
Table dropped.
--查詢審計表aud$:
SQL> select os_username,
username,
obj_name,
action_name,
audit_option,
logoff_time,
sessionid,
os_process,
instance_number,
sql_text,
sql_bind
from dba_audit_trail
where sql_text like '%TEMP%';
no rows selected
實驗三:指定對t表進行更新審計
登錄 scott 用戶,創建 t 表并開啟 update 審計,使用 by access 子句,每次 update 都審計
SQL> conn scott/tiger;
Connected.
SQL> create table t(x int);
Table created.
SQL> insert into t values(9);
1 row created.
SQL> commit;
Commit complete. --在scott用戶下對t表進行access級別的審計
SQL> audit update on t by access;
Audit succeeded.
表示對t表的每次更新操作進行審計(by access,每個符合審計的操作全部審計;by session,在一個會話中,同類型的操作只審計一條)--使用綁定變量的 sql 進行 update 測試
SQL>var v_num number;
SQL>exec :v_num:=1000; (:v_num綁定變量,:v_num:=給綁定變量授予一個值)
PL/SQL procedure successfully completed.
SQL>update t set x=:v_num;
1 row updated.
SQL>commit;
commit complete.
--關閉審計
SQL> noaudit update on t;
Noaudit succeeded.
--查詢審計結果
set lines 200
col OS_USERNAME for a10
col USERNAME for a10
col OBJ_NAME for a10
col SQL_BIND for a10
col SQL_TEXT for a10
col OWNER for a10
col ACTION_NAME for a10
alter session set nls_date_format='yyyy-mm-dd hh34:mi:ss';
select os_username,
username,
timestamp,
owner,
obj_name,
action_name,
sessionid,
instance_number,
os_process,
transactionid,
sql_bind,
sql_text
from dba_audit_trail
where sql_text like '%T%';
結果說明開啟DB級的審計,必須指定對某個表或某個session(by access 或 by session),才會對相應操作進行審計并記錄在dba_audit_trail表中
“audit審計方法是什么”的內容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業相關的知識可以關注億速云網站,小編將為大家輸出更多高質量的實用文章!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。