[20190530]oracle Audit文件管理.txt
[20190530]oracle audit文件管理.txt
--//昨天听课,讲一些oracle相关安全的问题,对方提到audit file的管理,应该引入os audit,这样目的是仅仅root查看audit信息.
--//增加一定安全性,并且对方提到原来的目录就没有任何记录.自己测试看看.
--//像我们生产系统这个目录简直是暴涨,使用一些我自己都不知道的监测软件,感觉每15秒就使用sys用户登录一次.
--//参考链接:https://www.cnblogs.com/lfree/p/10475829.html
--//自己在测试环境测试看看.
1.环境:
sys@book> @ ver1
port_string version banner
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/linux 2.4.xx 11.2.0.4.0 oracle database 11g enterprise edition release 11.2.0.4.0 - 64bit production
sys@book> alter system set audit_sys_operations=true scope=spfile sid='*';
system altered.
sys@book> alter system set audit_syslog_level='local0.info' scope=spfile sid='*';
system altered.
--//修改/etc/syslog.conf加入如下,注意如果使用rsyslog,修改/etc/rsyslog.conf文件.
# vi /etc/syslog.conf
local0.info /var/log/oracleaudit.log
--//重启syslog服务.
# service syslog restart
shutting down kernel logger: [ ok ]
shutting down system logger: [ ok ]
starting system logger: [ ok ]
starting kernel logger: [ ok ]
sys@book> shutdown immediate ;
database closed.
database dismounted.
oracle instance shut down.
sys@book> startup
oracle instance started.
total system global area 643084288 bytes
fixed size 2255872 bytes
variable size 205521920 bytes
database buffers 427819008 bytes
redo buffers 7487488 bytes
database mounted.
database opened.
2.检查:
sys@book> show parameter audit_file_dest
name type value
--------------- ------ --------------------------------
audit_file_dest string /u01/app/oracle/admin/book/adump
$ rm -f /u01/app/oracle/admin/book/adump/*.aud */
$ ls -l /u01/app/oracle/admin/book/adump
total 0
--//以sys用户登录看看:
$ ls -l /u01/app/oracle/admin/book/adump
total 0
--//可以发现这样操作后根本不会在/u01/app/oracle/admin/book/adump目录建立文件.
$ ls -l /var/log/oracleaudit.log
-rw------- 1 root root 6894 2019-05-30 10:40:11 /var/log/oracleaudit.log
--//可以发现建立的/var/log/oracleaudit.log仅仅root用户可以查看.
sys@book> show sga
total system global area 643084288 bytes
fixed size 2255872 bytes
variable size 205521920 bytes
database buffers 427819008 bytes
redo buffers 7487488 bytes
--//查看/var/log/oracleaudit.log文件:
may 30 10:42:38 xxx oracle audit[38014]: length : '435' action :[281] 'select decode(null,'','total system global area','') name_col_plus_show_sga, sum(value), decode (null,'', 'bytes','') units_col_plus_show_sga from v$sga union all select name name_col_plus_show_sga , value, decode (null,'', 'bytes','') units_col_plus_show_sga from v$sga' database user:[1] '/' privilege :[6] 'sysdba' client user:[6] 'oracle' client terminal:[5] 'pts/7' status:[1] '0' dbid:[10] '1337401710'
--//可以发现执行的sql语句也有记录.才想起来以前也做过类似测试.
--//参考链接:http://blog.itpub.net/267265/viewspace-740683/=>[20120810]linux使用syslog审计数据库.txt
# tail -1 /var/log/oracleaudit.log | sed -e "s/' /'\n/g"
may 30 10:42:38 xxxx oracle audit[38014]: length : '435'
action :[281] 'select decode(null,'','total system global area','') name_col_plus_show_sga, sum(value), decode (null,'', 'bytes','') units_col_plus_show_sga from v$sga union all select name name_col_plus_show_sga , value, decode (null,'', 'bytes','') units_col_plus_show_sga from v$sga'
database user:[1] '/'
privilege :[6] 'sysdba'
client user:[6] 'oracle'
client terminal:[5] 'pts/7'
status:[1] '0'
dbid:[10] '1337401710'
--//语句格式化如下:
select decode(null,'','total system global area','') name_col_plus_show_sga, sum(value), decode (null,'',
'bytes','') units_col_plus_show_sga
from v$sga
union all
select name name_col_plus_show_sga, value, decode (null,'', 'bytes','') units_col_plus_show_sga
from v$sga
3.配置logrotate来管理syslog日志文件
--//这样生成多个文件变成仅仅存在1个文件,像我们生产系统我估计增加还是很快的,必须定时清理控制大小加入如下:
# cat /etc/logrotate.d/oracle
/var/log/oracleaudit.log {
weekly
rotate 4
compress
copytruncate
delaycompress
notifempty
}
--//个人建议修改如下:
/var/log/oracleaudit.log {
size=40m
rotate 4
copytruncate
delaycompress
notifempty
}
--//size大小根据业务修改,我建议至少保存1年的数据量.
--//我很奇怪为什么做等保时候,对方没有提出这么好的建议,提供的修改都是一些按照文档修改模板,许多根本不符合实际工作的需求...
--//看来以后要把这个作为安装配置oracle数据库的一个关键步骤,就像要配置hugepages一样.包括asm实例的审计也是一样.
上一篇: syslog命令