您好,登錄后才能下訂單哦!
本篇內(nèi)容主要講解“oracle審計(jì)功能的用法介紹”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實(shí)用性強(qiáng)。下面就讓小編來帶大家學(xué)習(xí)“oracle審計(jì)功能的用法介紹”吧!
1,開啟審計(jì):
show parameter audit
alter system set audit_trail = DB_EXTENDED; --詳細(xì)審計(jì)
注意,如果audit_trail=db,不記錄SQL_BIND和SQL_TEXT
DB:將審計(jì)結(jié)果放在數(shù)據(jù)庫表中,aud$,通常只記錄連接的信息.
DB_EXTENDED:將審計(jì)結(jié)果放在數(shù)據(jù)庫表中,記錄具體執(zhí)行語句
OS:將審計(jì)結(jié)果記錄在操作系統(tǒng)文件中,文件位置由audit_file_dest參數(shù)指定,(windows系統(tǒng)中將直接在事件查看器的系統(tǒng)日志中記錄)
XML:將審計(jì)結(jié)果記錄在audit_file_dest指定位置下的XML文件中。
2,重啟數(shù)據(jù)庫實(shí)例
startup force
3,指定審計(jì)內(nèi)容
1. 對(duì)表的審計(jì):可以單獨(dú)對(duì)表的create,alter進(jìn)行審計(jì),如果要對(duì)drop操作進(jìn)行審計(jì)需要對(duì)表加audit table(該命令包含有create table,drop table,truncate table).
2. 對(duì)視圖的審計(jì):可以單獨(dú)對(duì)視圖的create進(jìn)行審計(jì),如果要對(duì)drop操作進(jìn)行審計(jì)需要對(duì)視圖加audit view(該命令包含有create view,drop view).
3. 對(duì)程序包的審計(jì):可以對(duì)包(函數(shù),存儲(chǔ)過程等)的create進(jìn)行審計(jì),如果需要對(duì)drop操作進(jìn)行審計(jì)需要加audit procedure(該命令對(duì)CREATE FUNCTION, CREATE LIBRARY , CREATE PACKAGE, CREATE PACKAGE BODY, CREATE PROCEDURE, DROP FUNCTION, DROP LIBRARY, DROP PACKAGE, DROP PROCEDURE進(jìn)行審計(jì))
4. 對(duì)用戶的審計(jì):可以通過audit user(該命令包含 create user,alter user,drop user)進(jìn)行審計(jì),
例如要審計(jì)scott賬戶的所有操作
audit all by scott;
4,查看都有哪些內(nèi)容被審計(jì)
select * from dba_priv_audit_opts --where owner_name='SCOTT';
select * from dba_stmt_audit_opts
select * from dba_obj_audit_opts
1. 對(duì)表的審計(jì):可以單獨(dú)對(duì)表的create,alter進(jìn)行審計(jì),如果要對(duì)drop操作進(jìn)行審計(jì)需要對(duì)表加audit table(該命令包含有create table,drop table,truncate table).
2. 對(duì)視圖的審計(jì):可以單獨(dú)對(duì)視圖的create進(jìn)行審計(jì),如果要對(duì)drop操作進(jìn)行審計(jì)需要對(duì)視圖加audit view(該命令包含有create view,drop view).
3. 對(duì)程序包的審計(jì):可以對(duì)包(函數(shù),存儲(chǔ)過程等)的create進(jìn)行審計(jì),如果需要對(duì)drop操作進(jìn)行審計(jì)需要加audit procedure(該命令對(duì)CREATE FUNCTION, CREATE LIBRARY , CREATE PACKAGE, CREATE PACKAGE BODY, CREATE PROCEDURE, DROP FUNCTION, DROP LIBRARY, DROP PACKAGE, DROP PROCEDURE進(jìn)行審計(jì))
4. 對(duì)用戶的審計(jì):可以通過audit user(該命令包含 create user,alter user,drop user)進(jìn)行審計(jì),
DBA_AUDIT_TRAIL 列出所有審計(jì)跟蹤條目
USER_AUDIT_TRAIL USER視圖顯示與當(dāng)前用戶有關(guān)的審計(jì)跟蹤條目
5,查看審計(jì)信息
select * from dba_audit_trail where owner = 'SCOTT' order by timestamp;
視圖說明:
1. SYS.AUD$
審計(jì)功能的底層視圖,如果需要對(duì)數(shù)據(jù)進(jìn)行刪除,只需要對(duì)aud$視圖進(jìn)行刪除既可,其他視圖里的數(shù)據(jù)都是由aud$所得.
2. DBA_AUDIT_EXISTS
列出audit not exists和audit exists產(chǎn)生的審計(jì)跟蹤,我們默認(rèn)的都是audit exists.
3. DBA_AUDIT_TRAIL
可以在里面查處所有審計(jì)所跟蹤的信息.
4. DBA_AUDIT_OBJECT
可以查詢所有對(duì)象跟蹤信息.(例如,對(duì)grant,revoke等不記錄),信息完全包含于dba_audit_trail
5. DBA_AUDIT_SESSION
所得到的數(shù)據(jù)都是有關(guān)logon或者logoff的信息.
6. DBA_AUDIT_STATEMENT
列出grant ,revoke ,audit ,noaudit ,alter system語句的審計(jì)跟蹤信息.
7. DBA_PRIV_AUDIT_OPTS
通過系統(tǒng)和由用戶審計(jì)的當(dāng)前系統(tǒng)特權(quán)
8. DBA_OBJ_AUDIT_OPTS
可以查詢到所有用戶所有對(duì)象的設(shè)計(jì)選項(xiàng)
9. ALL_DEF_AUDIT_OPTS
10. AUDIT_ACTIONS
可以查詢出在aud$等視圖中actions列的含義
11. SYSTEM_PRIVILEGE_MAP
可以查詢出aud$等視圖中priv$used列的含義(注意前面加'-')
6 ,取消審計(jì)
全部取消是
noaudit all;
如果取消單獨(dú)的可以根據(jù)上面4條查看有上面權(quán)限直接noaudit 即可。
如:noaudit create session by user scott;
取消對(duì)SC表的一切審計(jì)可使用如下語句:
NOAUDIT ALL ON SC;
noaudit取消審計(jì)的操作對(duì)已經(jīng)連接著的session無用,但新開的session將不再審計(jì)。
-- 取消所有statement審計(jì)
NOAUDIT ALL;
-- 取消所有權(quán)限審計(jì)
NOAUDIT ALL PRIVILEGES;
-- 取消所有對(duì)象審計(jì)
NOAUDIT ALL ON DEFAULT;
7,關(guān)閉審計(jì)
SQL> alter system set audit_trail=none scope=spfile;
.audit_sys_operations:是否對(duì)sysdba用戶做審計(jì) ,關(guān)于sysdba用戶審計(jì)的結(jié)果,linux存放在audit_file_dest參數(shù)指定位置的aud文件中,windows存放在事件查看器的系統(tǒng)日志中
問題1:
確認(rèn)審計(jì)相關(guān)的表是否已經(jīng)安裝
SQLPLUS> connect / AS SYSDBA
SQLPLUS> select * from sys.aud$; -- 沒有記錄返回
SQLPLUS> select * from dba_audit_trail; -- 沒有記錄返回
如果做上述查詢的時(shí)候發(fā)現(xiàn)表不存在,說明審計(jì)相關(guān)的表還沒有安裝,需要安裝。
SQLPLUS> connect / as sysdba
SQLPLUS> @$ORACLE_HOME/rdbms/admin/cataudit.sql
問題2:
將審計(jì)相關(guān)的表移動(dòng)到其他表空間:
由于AUD$表等審計(jì)相關(guān)的表存放在SYSTEM表空間,因此為了不影響系統(tǒng)的性能,保護(hù)SYSTEM表空間,最好把AUD$移動(dòng)到其他的表空間上??梢允褂孟旅娴恼Z句來進(jìn)行移動(dòng):
sql>connect / as sysdba;
sql>alter table aud$ move tablespace <new tablespace>;
sql>alter index I_aud1 rebuild online tablespace <new tablespace>;
SQL> alter table audit$ move tablespace <new tablespace>;
SQL> alter index i_audit rebuild online tablespace <new tablespace>;
SQL> alter table audit_actions move tablespace <new tablespace>;
SQL> alter index i_audit_actions rebuild online tablespace <new tablespace>;
問題3:
audit的審計(jì)信息保留時(shí)間
(默認(rèn)一直保留)
手動(dòng)清理:
How to truncate or delete rows from audit trail table sys.aud$
1)Only appropriate privileged user can do delete operation on SYS.AUD$ table. The user must have either of the following privileges.
-SYS user.
-DELETE ANY TABLE system privilege. (If O7_DICTIONARY_ACCESSIBILITY=TRUE)
-A user to whom SYS has granted the object privilege DELETE on SYS.AUD$ table.
2)Before deleting any rows you may want to archive the table. You can achive this by creating a table from SYS.AUD$ and export that. Don't export SYS.AUD$ directly.
SQL>CREATE TABLE AUDIT_RECORD TABLESPACE users as select * from SYS.AUD$;
Now export the table as,
SQL> host exp tables=AUDIT_RECORD file=audit_record.dmp
3)To delete all records from audit trail table SYS.AUD$ issue,
SQL>DELETE FROM SYS.AUD$;
To delete all records of particular audited table from the audit trail issue,
SQL>DELETE FROM sys.aud$ WHERE obj$name='&table_nmae';
But deleting in this way will not reduce size on the system tablespace or aud$ table. In order to reduce size follow section 4.
4)Truncate audit table to reduce size.
SQL>CONN / as sysdba
SQL>TRUNCATE TABLE SYS.AUD$
自動(dòng)清理:
1.創(chuàng)建清理aud$表procedure:
create or replace procedure clear_aud
as
begin
delete aud$ where ntimestamp# <trunc(sysdate,'HH')- 1/24;
commit;
exception when others then
rollback;
end;
2.創(chuàng)建清理AUD$表JOB:
Variable job number ;
begin
dbms_job.submit(:job, 'clear_aud;' ,trunc( sysdate + 1 / 24 , 'hh34' ), 'trunc(sysdate+1/24,''hh34'')' );
commit ;
end ;
/
問題4:
查找AUD$表大小
select OWNER,SEGMENT_NAME,SEGMENT_TYPE,TABLESPACE_NAME,BYTES/1024/1024 MB from dba_segments where SEGMENT_TYPE='TABLE' and SEGMENT_NAME='AUD$';
到此,相信大家對(duì)“oracle審計(jì)功能的用法介紹”有了更深的了解,不妨來實(shí)際操作一番吧!這里是億速云網(wǎng)站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。