白天和黑夜只交替没交换无法想像对方的世界
分类: oracle
2013-06-19 16:07:12
之前整理的一篇有关审计的说明:
在maclean 的blog上看到了2篇介绍oracle 11g 默认审计的文章,原文链接如下:
11g默认审计选项
find password cracker in 11g
根据这2篇文章重新整理一下。
在oracle 11g中默认启用审计选项,audit_trail参数的缺省值为db,而在oracle 10g中该参数默认值为none,即不启用审计。 关于这些参数的说明,可以参考我之前整理的审计的文章。
审计数据默认存放system 表空间下的aud$审计字典基表上。oracle官方宣称默认启用的审计日志不会对绝大多数产品数据库的性能带来过大的负面影响,同时oracle公司还推荐使用基于os文件的审计日志记录方式(os audit trail files)。
注意在oracle11g中create session将被作为受审计的权限来被记录,因此当system表空间因磁盘空间而无法扩展时将导致这部分审计记录无法生成,这将最终导致普通用户的新会话将无法正常创建,普通用户将无法登陆数据库。在这种场景中仍可以使用sysdba身份的用户创建会话,在将审计数据合适备份后删除一部分记录,或者干脆truncate aud$都可以解决上述问题。
当audit_trail设置为os时,审计记录文件将在audit_file_dest参数所指定的目录中生成。全部这些文件均可以随时被删除或复制。
注意在默认情况下会以autoextend on自动扩展选项创建system表空间,因此系统表空间在必要情况下还是会自动增长的,我们所需注意的是磁盘上的剩余空间是否能够满足其增长需求,以及数据文件扩展的上限,对于普通的8k smallfile表空间而言单个数据文件的最大尺寸是32g。
sql> select * from v$version whererownum=1;
banner
--------------------------------------------------------------------------------
oracle database 11g enterprise editionrelease 11.2.0.1.0 - production
dba_priv_audit_opts describescurrent system privileges being audited across the system and by user.
sql> select privilege,success,failurefrom dba_priv_audit_opts;
privilege success failure
-------------------------------------------------- ----------
create external job by access by access
create any job by access by access
grant any object privilege by access by access
exempt access policy by access by access
create any library by access by access
grant any privilege by access by access
drop profile by access by access
alter profile by access by access
drop any procedure by access by access
alter any procedure by access by access
create any procedure by access by access
privilege success failure
-------------------------------------------------- ----------
alter database by access by access
grant any role by access by access
create public database link by access by access
drop any table by access by access
alter any table by access by access
create any table by access by access
drop user by access by access
alter user by access by access
create user by access by access
create session by access by access
audit system by access by access
privilege success failure
-------------------------------------------------- ----------
alter system by access by access
23 rows selected.
sql>
dba_stmt_audit_opts describescurrent system auditing options across the system and by user.
sql> select audit_option,success,failurefrom dba_stmt_audit_opts;
audit_option success failure
-------------------------------------------------- ----------
alter system by access by access
system audit by access by access
create session by access by access
create user by access by access
alter user by access by access
drop user by access by access
public synonym by access by access
database link by access by access
role byaccess by access
profile byaccess by access
create any table by access by access
audit_option success failure
-------------------------------------------------- ----------
alter any table by access by access
drop any table by access by access
create public database link by access by access
grant any role by access by access
system grant by access by access
alter database by access by access
create any procedure by access by access
alter any procedure by access by access
drop any procedure by access by access
alter profile by access by access
drop profile by access by access
audit_option success failure
-------------------------------------------------- ----------
grant any privilege by access by access
create any library by access by access
exempt access policy by access by access
grant any object privilege by access by access
create any job by access by access
create external job by access by access
28 rows selected.
dba_audit_trail displaysall standard audit trail entries.
sql> select action_name,count(*) from dba_audit_trail group by action_name;
action_name count(*)
---------------------------- ----------
system revoke 1
logon 90
drop database link 5
logoff 59
alter system 5
create public synonym 2
alter database 3
drop public synonym 2
create database link 5
9 rows selected.
在用户的profile 属性里面有一个属性:failed_login_attempts, 该参数默认值是10. 即当我们用户连续10次输入错误密码,这个用户就会被锁住。用户连词失败次数是在表user$ 中的lcount字段记录的。 该值默认为0. 当失败一次,该值加1. 成功登录,该值清零。
一般在生产环境下,会根据具体情况设置这个参数,如果防止用户被锁,则将这个参数设置为unlimited。 这个是注意的地方。当然设置成无限也有它的弊端,比如不能防止暴力破解数据库密码。
有关profile 的更多内容参考:
在11g中默认启用了对登录注销操作logon/logoff的审计,那么如果我们发现用户被锁,那么可以应用11g的审计功能来查看从哪台机器上发来的链接失败导致用户被锁,可以帮助我们定位问题。
脚本如下:
sql> selectos_username,userhost,terminal,username,count(*)
2 from dba_audit_trail
3 where returncode = 1017
4 group byos_username,userhost,username,terminal;
os_username userhost terminal username count(*)
------------------------------------------------------------ ------------ ------------ ----------
daviddai\administrator workgroup\daviddai daviddai icd 7
daviddai\administrator workgroup\daviddai daviddai system 9
daviddai\administrator workgroup\daviddai daviddai sys 3
daviddai\administrator workgroup\daviddai daviddai exit 1
注意对于logon per second很高的数据库,如果应用程序配置文件中的数据库用户密码不正确,同时应用在短期内发起大量会话登录数据库的话可能引发频繁的dc_users字典缓存锁,用户登录无法成功,乃至整个实例hang住。这个问题直接参考maclean的blog:
row cache lock problem
-------------------------------------------------------------------------------------------------------
blog: http://blog.csdn.net/tianlesoftware
weibo:
email: dvd.dba@gmail.com
dba1 群:62697716(满); dba2 群:62697977(满) dba3 群:62697850(满)
dba 超级群:63306533(满); dba4 群: 83829929(满) dba5群: 142216823(满)
dba6 群:158654907(满) 聊天 群:40132017(满) 聊天2群:69087192(满)
--加群需要在备注说明oracle表空间和数据文件的关系,否则拒绝申请