sqlplus "/ as sysdba"

創(chuàng)新互聯(lián)致力于互聯(lián)網(wǎng)品牌建設(shè)與網(wǎng)絡(luò)營(yíng)銷,包括網(wǎng)站建設(shè)、成都做網(wǎng)站、SEO優(yōu)化、網(wǎng)絡(luò)推廣、整站優(yōu)化營(yíng)銷策劃推廣、電子商務(wù)、移動(dòng)互聯(lián)網(wǎng)營(yíng)銷等。創(chuàng)新互聯(lián)為不同類型的客戶提供良好的互聯(lián)網(wǎng)應(yīng)用定制及解決方案,創(chuàng)新互聯(lián)核心團(tuán)隊(duì)十余年專注互聯(lián)網(wǎng)開發(fā),積累了豐富的網(wǎng)站經(jīng)驗(yàn),為廣大企業(yè)客戶提供一站式企業(yè)網(wǎng)站建設(shè)服務(wù),在網(wǎng)站建設(shè)行業(yè)內(nèi)樹立了良好口碑。
show parameter audit
alter system set audit_sys_operations=TRUE scope=spfile;
alter system set audit_trail=DB scope=spfile;
shutdown immediate;
startup force;
Oracle 11g起audit是自動(dòng)開啟的。我很煩這個(gè)審計(jì)開啟,審計(jì)日志半個(gè)月10G,煩煩煩。我一把都關(guān)閉Oracle的審計(jì)功能,提高Oracle的空閑率。
1 、如何啟用審計(jì)?
修改數(shù)據(jù)庫(kù)的初始化參數(shù)audit_trail ,從none 修改為你需要的值。
它的可選項(xiàng)有很多,如下所示:
AUDIT_TRAIL = { none | os | db | db,extended | xml | xml,extended }
我們選擇db 值作為該參數(shù)值。使得審計(jì)功能處于打開狀態(tài),將審計(jì)記錄保存在數(shù)據(jù)庫(kù)sys.aud$表中。
修改初始化參數(shù)文件spfile 中的此參數(shù)配置值
ALTER SYSTEM SET audit_trail=db SCOPE=SPFILE sid='*';
注意,這個(gè)參數(shù)需要數(shù)據(jù)庫(kù)實(shí)例重啟之后才能生效。
2 、審計(jì)有哪些功能
可以審計(jì)數(shù)據(jù)庫(kù)對(duì)象的DML 和DDL 操作,以及查詢、執(zhí)行和一些系統(tǒng)事件如登錄和退出。
如下所示:
DDL (CREATE, ALTER DROP of objects)
DML (INSERT UPDATE, DELETE)
SELECT
EXECUTE
SYSTEM EVENTS (LOGON, LOGOFF etc)
每個(gè)功能還有選項(xiàng),如在每個(gè)會(huì)話還是每個(gè)訪問中審計(jì),是成功或不成功時(shí)審計(jì)。
完整的audit 的語(yǔ)法如下:
AUDIT
{ sql_statement_clause | schema_object_clause | NETWORK }
[ BY { SESSION | ACCESS } ]
[ WHENEVER [ NOT ] SUCCESSFUL ] ;
3 、如何審計(jì)某表的數(shù)據(jù)插入操作
現(xiàn)在的問題是找出什么應(yīng)用向表插入了記錄。在應(yīng)用程序的邏輯上,這個(gè)表的數(shù)據(jù)只會(huì)更新,不會(huì)插入。
因此,在審計(jì)功能打開后,使用這個(gè)下列命令審計(jì)某表的插入操作。
audit insert on table_name by access;
執(zhí)行成功后,此表上每一次插入操作都會(huì)被記錄在sys.aud$ 表中。
4 、如何查看審計(jì)結(jié)果
可以查詢dba_audit_trail 系統(tǒng)視圖,該視圖顯示就是sys.aud$ 表保存的審計(jì)結(jié)果。這個(gè)表的存儲(chǔ)空間是system ,如果你需要大量長(zhǎng)期審計(jì)某些操作,請(qǐng)注意維護(hù)這張表。
一般維護(hù)方法有兩個(gè),定期執(zhí)行truncate 操作和將表的存儲(chǔ)表空間移植到一個(gè)新建的獨(dú)立表空間上。
5 、如何取消審計(jì)
使用noaudit 代替audit 命令符就可, 如noaudit insert on table_name by access;
在oracle11g中,數(shù)據(jù)庫(kù)的審計(jì)功能是默認(rèn)開啟的(這和oracle10g的不一樣,10g默認(rèn)是關(guān)閉的),
oracle11gr2的官方文檔上寫的是錯(cuò)的,當(dāng)上說default是none,而且是審計(jì)到db級(jí)別的,這樣就會(huì)
往aud$表里記錄統(tǒng)計(jì)信息。
1.如果審計(jì)不是必須的,可以關(guān)掉審計(jì)功能;
sql
show
parameter
audit_trail;
name
type
value
------------------------------------
-----------
------------------------------
audit_trail
string
db
sql
alter
system
set
audit_trail=none
scope=spfile;
sql
shut
immediate;
sqlstartup
2.刪除已有的審計(jì)信息
可以直接truncate表aud$,
truncate
table
sys.aud$;
3.或者將aud$表移到另外一個(gè)表空間下,以減少system表空間的壓力和被撐爆的風(fēng)險(xiǎn)。
附:11g中有關(guān)audit_trail參數(shù)的設(shè)置說明:
audit_trail
property
description
parameter
type
string
syntax
audit_trail
=
{
none
|
os
|
db
[,
extended]
|
xml
[,
extended]
}
default
value
none
modifiable
no
basic
no
audit_trail
enables
or
disables
database
auditing.
values:
none
disables
standard
auditing.
this
value
is
the
default
if
the
audit_trail
parameter
was
not
set
in
the
initialization
parameter
file
or
if
you
created
the
database
using
a
method
other
than
database
configuration
assistant.
if
you
created
the
database
using
database
configuration
assistant,
then
the
default
is
db.
os
directs
all
audit
records
to
an
operating
system
file.
oracle
recommends
that
you
use
the
os
setting,
particularly
if
you
are
using
an
ultra-secure
database
configuration.
db
directs
audit
records
to
the
database
audit
trail
(the
sys.aud$
table),
except
for
records
that
are
always
written
to
the
operating
system
audit
trail.
use
this
setting
for
a
general
database
for
manageability.
if
the
database
was
started
in
read-only
mode
with
audit_trail
set
to
db,
then
oracle
database
internally
sets
audit_trail
to
os.
check
the
alert
log
for
details.
db,
extended
performs
all
actions
of
audit_trail=db,
and
also
populates
the
sql
bind
and
sql
text
clob-type
columns
of
the
sys.aud$
table,
when
available.
these
two
columns
are
populated
only
when
this
parameter
is
specified.
if
the
database
was
started
in
read-only
mode
with
audit_trail
set
to
db,
extended,
then
oracle
database
internally
sets
audit_trail
to
os.
check
the
alert
log
for
details.
xml
writes
to
the
operating
system
audit
record
file
in
xml
format.
records
all
elements
of
the
auditrecord
node
except
sql_text
and
sql_bind
to
the
operating
system
xml
audit
file.
xml,
extended
performs
all
actions
of
audit_trail=xml,
and
populates
the
sql
bind
and
sql
text
clob-type
columns
of
the
sys.aud$
table,
wherever
possible.
these
columns
are
populated
only
when
this
parameter
is
specified.
you
can
use
the
sql
audit
statement
to
set
auditing
options
regardless
of
the
setting
of
this
parameter.
1、什么是審計(jì)
審計(jì)(Audit)用于監(jiān)視用戶所執(zhí)行的數(shù)據(jù)庫(kù)操作,并且Oracle會(huì)將審計(jì)跟蹤結(jié)果存放到OS文件(默認(rèn)位置為$ ORACLE_BASE/admin/$ORACLE_SID/adump/)或數(shù)據(jù)庫(kù)(存儲(chǔ)在system表空間中的SYS.AUD$表中,可通過視圖 dba_audit_trail查看)中。默認(rèn)情況下審計(jì)是沒有開啟的。
不管你是否打開數(shù)據(jù)庫(kù)的審計(jì)功能,以下這些操作系統(tǒng)會(huì)強(qiáng)制記錄:用管理員權(quán)限連接Instance;啟動(dòng)數(shù)據(jù)庫(kù);關(guān)閉數(shù)據(jù)庫(kù)。
2、和審計(jì)相關(guān)的兩個(gè)主要參數(shù)
Audit_sys_operations:
默認(rèn)為false,當(dāng)設(shè)置為true時(shí),所有sys用戶(包括以sysdba,sysoper身份登錄的用戶)的操作都會(huì)被記錄,audit trail不會(huì)寫在aud$表中,這個(gè)很好理解,如果數(shù)據(jù)庫(kù)還未啟動(dòng)aud$不可用,那么像conn /as sysdba這樣的連接信息,只能記錄在其它地方。如果是windows平臺(tái),audti trail會(huì)記錄在windows的事件管理中,如果是linux/unix平臺(tái)則會(huì)記錄在audit_file_dest參數(shù)指定的文件中。
Audit_trail:
None:是默認(rèn)值,不做審計(jì);
DB:將audit trail 記錄在數(shù)據(jù)庫(kù)的審計(jì)相關(guān)表中,如aud$,審計(jì)的結(jié)果只有連接信息;
DB,Extended:這樣審計(jì)結(jié)果里面除了連接信息還包含了當(dāng)時(shí)執(zhí)行的具體語(yǔ)句;
OS:將audit trail 記錄在操作系統(tǒng)文件中,文件名由audit_file_dest參數(shù)指定;
XML:10g里新增的。
注:這兩個(gè)參數(shù)是static參數(shù),需要重新啟動(dòng)數(shù)據(jù)庫(kù)才能生效。
3、審計(jì)級(jí)別
當(dāng)開啟審計(jì)功能后,可在三個(gè)級(jí)別對(duì)數(shù)據(jù)庫(kù)進(jìn)行審計(jì):Statement(語(yǔ)句)、Privilege(權(quán)限)、object(對(duì)象)。
Statement:
按語(yǔ)句來審計(jì),比如audit table 會(huì)審計(jì)數(shù)據(jù)庫(kù)中所有的create table,drop table,truncate table語(yǔ)句,alter session by cmy會(huì)審計(jì)cmy用戶所有的數(shù)據(jù)庫(kù)連接。
Privilege:
按權(quán)限來審計(jì),當(dāng)用戶使用了該權(quán)限則被審計(jì),如執(zhí)行g(shù)rant select any table to a,當(dāng)執(zhí)行了audit select any table語(yǔ)句后,當(dāng)用戶a 訪問了用戶b的表時(shí)(如select * from b.t)會(huì)用到select any table權(quán)限,故會(huì)被審計(jì)。注意用戶是自己表的所有者,所以用戶訪問自己的表不會(huì)被審計(jì)。
Object:
按對(duì)象審計(jì),只審計(jì)on關(guān)鍵字指定對(duì)象的相關(guān)操作,如aduit alter,delete,drop,insert on cmy.t by scott; 這里會(huì)對(duì)cmy用戶的t表進(jìn)行審計(jì),但同時(shí)使用了by子句,所以只會(huì)對(duì)scott用戶發(fā)起的操作進(jìn)行審計(jì)。注意Oracle沒有提供對(duì)schema中所有對(duì)象的審計(jì)功能,只能一個(gè)一個(gè)對(duì)象審計(jì),對(duì)于后面創(chuàng)建的對(duì)象,Oracle則提供on default子句來實(shí)現(xiàn)自動(dòng)審計(jì),比如執(zhí)行audit drop on default by access;后,對(duì)于隨后創(chuàng)建的對(duì)象的drop操作都會(huì)審計(jì)。但這個(gè)default會(huì)對(duì)之后創(chuàng)建的所有數(shù)據(jù)庫(kù)對(duì)象有效,似乎沒辦法指定只對(duì)某個(gè)用戶創(chuàng)建的對(duì)象有效,想比 trigger可以對(duì)schema的DDL進(jìn)行“審計(jì)”,這個(gè)功能稍顯不足。
在oracle11g中,數(shù)據(jù)庫(kù)的審計(jì)功能是默認(rèn)開啟的(這和oracle10g的不一樣,10g默認(rèn)是關(guān)閉的),\x0d\x0aoracle11gR2的官方文檔上寫的是錯(cuò)的,當(dāng)上說default是none,而且是審計(jì)到DB級(jí)別的,這樣就會(huì)\x0d\x0a往aud$表里記錄統(tǒng)計(jì)信息。\x0d\x0a \x0d\x0a1.如果審計(jì)不是必須的,可以關(guān)掉審計(jì)功能;\x0d\x0a\x0d\x0aSQL show parameter audit_trail;\x0d\x0a\x0d\x0aNAME TYPE VALUE\x0d\x0a------------------------------------ ----------- ------------------------------\x0d\x0aaudit_trail string DB\x0d\x0a\x0d\x0aSQL alter system set audit_trail=none scope=spfile;\x0d\x0aSQL shut immediate;\x0d\x0aSQLstartup\x0d\x0a2.刪除已有的審計(jì)信息\x0d\x0a可以直接truncate表aud$,\x0d\x0atruncate table SYS.AUD$;\x0d\x0a\x0d\x0a3.或者將aud$表移到另外一個(gè)表空間下,以減少system表空間的壓力和被撐爆的風(fēng)險(xiǎn)。\x0d\x0a \x0d\x0a附:11g中有關(guān)audit_trail參數(shù)的設(shè)置說明:\x0d\x0aAUDIT_TRAIL\x0d\x0aProperty Description\x0d\x0aParameter type String\x0d\x0aSyntaxAUDIT_TRAIL = { none | os | db [, extended] | xml [, extended] }\x0d\x0aDefault valuenone\x0d\x0aModifiable No\x0d\x0aBasic No\x0d\x0aAUDIT_TRAIL enables or disables database auditing.\x0d\x0aValues:\x0d\x0anone\x0d\x0aDisables standard auditing. This value is the default if the AUDIT_TRAIL parameter was not set \x0d\x0ain the initialization parameter file or if you created the database using a method other than \x0d\x0aDatabase Configuration Assistant. If you created the database using Database Configuration \x0d\x0aAssistant, then the default is db.\x0d\x0aos\x0d\x0aDirects all audit records to an operating system file. Oracle recommends that you use the os \x0d\x0asetting, particularly if you are using an ultra-secure database configuration.\x0d\x0adb\x0d\x0aDirects audit records to the database audit trail (the SYS.AUD$ table), except for records \x0d\x0athat are always written to the operating system audit trail. Use this setting for a general \x0d\x0adatabase for manageability.\x0d\x0aIf the database was started in read-only mode with AUDIT_TRAIL set to db, then Oracle Database \x0d\x0ainternally sets AUDIT_TRAIL to os. Check the alert log for details.\x0d\x0adb, extended\x0d\x0aPerforms all actions of AUDIT_TRAIL=db, and also populates the SQL bind and SQL text CLOB-type \x0d\x0acolumns of the SYS.AUD$ table, when available. These two columns are populated only when this \x0d\x0aparameter is specified.\x0d\x0aIf the database was started in read-only mode with AUDIT_TRAIL set to db, extended, then Oracle \x0d\x0aDatabase internally sets AUDIT_TRAIL to os. Check the alert log for details.\x0d\x0axml\x0d\x0aWrites to the operating system audit record file in XML format. Records all elements of the \x0d\x0aAuditRecord node except Sql_Text and Sql_Bind to the operating system XML audit file.\x0d\x0axml, extended\x0d\x0aPerforms all actions of AUDIT_TRAIL=xml, and populates the SQL bind and SQL text CLOB-type columns\x0d\x0a of the SYS.AUD$ table, wherever possible. These columns are populated only when this parameter \x0d\x0ais specified.\x0d\x0aYou can use the SQL AUDIT statement to set auditing options regardless of the setting of this \x0d\x0aparameter.
新聞標(biāo)題:oracle如何審計(jì)功能,oracle打開審計(jì)功能
URL網(wǎng)址:http://chinadenli.net/article13/dsgsggs.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)建站、網(wǎng)站營(yíng)銷、靜態(tài)網(wǎng)站、微信公眾號(hào)、定制開發(fā)、網(wǎng)站設(shè)計(jì)公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)