重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
使用syslog来管理Oracle ASM的审计文件
如果不对Oracle ASM实例的审计文件目录进行定期维护那么它将会包含大量的审计文件。如果存在大理审计文件可能会造成文件系统耗尽磁盘空间或indoes,或者由于文件系统扩展限制而造成Oracle运行缓慢,还有可能造成Oracle ASM实例在启动时hang住。这里将介绍如何使用Linux syslog工具来管理Oracle ASM审计记录,因此通过使用操作系统的syslog工具来代替单独的audit_dump_dest目录来记录Oracle ASM审计记录。下面将介绍具体的操作,而且这些操作必须对于RAC环境中的每个节点执行。
1.对Oracle ASM实例设置audit_syslog_level与audit_sys_operations参数
成都创新互联-专业网站定制、快速模板网站建设、高性价比清江浦网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式清江浦网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖清江浦地区。费用合理售后完善,十载实体公司更值得信赖。
SQL> show parameter audit_sys_ NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ audit_sys_operations boolean TRUE audit_syslog_level string SQL> alter system set AUDIT_SYSLOG_LEVEL='local0.info' scope=spfile sid='*'; System altered.
由于audit_sys_operations参数默认为启用所以不用进行设置了。
2.为Oracle ASM审计配置/etc/syslog.conf
通过执行以下两处改变来对Oracle ASM审计配置syslog的配置文件/etc/syslog.conf或/etc/rsyslog.conf:
2.1在/etc/syslog.conf或/etc/rsyslog.conf文件中增加以下内容
local0.info /var/log/oracle_asm_audit.log
2.2在/etc/syslog.conf或/etc/rsyslog.conf文件中的/var/log/messages这一行增加local0.none,修改后的配置如下:
*.info;mail.none;authpriv.none;cron.none;local0.none /var/log/messages
[root@cs1 ~]# vi /etc/rsyslog.conf ....省略.... # Log anything (except mail) of level info or higher. # Don't log private authentication messages! *.info;mail.none;authpriv.none;cron.none;local0.none /var/log/messages local0.info /var/log/oracle_asm_audit.log [root@cs2 ~]# vi /etc/rsyslog.conf ....省略.... # Log anything (except mail) of level info or higher. # Don't log private authentication messages! *.info;mail.none;authpriv.none;cron.none;local0.none /var/log/messages local0.info /var/log/oracle_asm_audit.log
3.配置logrotate来管理syslog日志文件
Linux的logrotate工具被用来管理Oracle ASM审计的syslog日志文件的大小与数量,创建文件/etc/logrotate.d/oracle_asm_audit,并向文件增加以下内容:
/var/log/oracle_asm_audit.log { weekly rotate 4 compress copytruncate delaycompress notifempty }
[root@cs1 ~]# cd /etc/logrotate.d/ [root@cs1 logrotate.d]# pwd /etc/logrotate.d [root@cs1 logrotate.d]# vi oracle_asm_audit /var/log/oracle_asm_audit.log { weekly rotate 4 compress copytruncate delaycompress notifempty } [root@cs2 ~]# cd /etc/logrotate.d/ [root@cs1 logrotate.d]# pwd /etc/logrotate.d [root@cs1 logrotate.d]# vi oracle_asm_audit /var/log/oracle_asm_audit.log { weekly rotate 4 compress copytruncate delaycompress notifempty }
4.重启Oracle ASM实例与rsyslog服务
为了使用这些改变生效必须重启Oracle ASM实例与rsyslog服务。可以使用crsctl stop cluster -all与crsctl start cluster -all在任何一个RAC节点上执行来重启Oracle ASM实例,这个操作会将数据库实例也关闭。
[root@cs1 bin]# /u01/app/product/12.2.0/crs/bin/crsctl stop cluster -all CRS-2673: Attempting to stop 'ora.crsd' on 'cs1' CRS-2673: Attempting to stop 'ora.crsd' on 'cs2' CRS-2790: Starting shutdown of Cluster Ready Services-managed resources on server 'cs2' CRS-2673: Attempting to stop 'ora.chad' on 'cs2' CRS-2790: Starting shutdown of Cluster Ready Services-managed resources on server 'cs1' CRS-2673: Attempting to stop 'ora.cs.db' on 'cs2' CRS-2673: Attempting to stop 'ora.cs.db' on 'cs1' CRS-2673: Attempting to stop 'ora.qosmserver' on 'cs1' CRS-2673: Attempting to stop 'ora.gns' on 'cs1' CRS-2677: Stop of 'ora.gns' on 'cs1' succeeded CRS-2677: Stop of 'ora.cs.db' on 'cs2' succeeded CRS-2673: Attempting to stop 'ora.CRS.dg' on 'cs2' CRS-2673: Attempting to stop 'ora.DATA.dg' on 'cs2' CRS-2673: Attempting to stop 'ora.LISTENER.lsnr' on 'cs2' CRS-2673: Attempting to stop 'ora.LISTENER_SCAN1.lsnr' on 'cs2' CRS-2677: Stop of 'ora.CRS.dg' on 'cs2' succeeded CRS-2677: Stop of 'ora.DATA.dg' on 'cs2' succeeded CRS-2673: Attempting to stop 'ora.asm' on 'cs2' CRS-2677: Stop of 'ora.LISTENER.lsnr' on 'cs2' succeeded CRS-2673: Attempting to stop 'ora.cs2.vip' on 'cs2' CRS-2673: Attempting to stop 'ora.chad' on 'cs1' CRS-2677: Stop of 'ora.chad' on 'cs2' succeeded CRS-2677: Stop of 'ora.LISTENER_SCAN1.lsnr' on 'cs2' succeeded CRS-2673: Attempting to stop 'ora.scan1.vip' on 'cs2' CRS-2677: Stop of 'ora.cs.db' on 'cs1' succeeded CRS-2673: Attempting to stop 'ora.LISTENER.lsnr' on 'cs1' CRS-2673: Attempting to stop 'ora.LISTENER_SCAN2.lsnr' on 'cs1' CRS-2673: Attempting to stop 'ora.LISTENER_SCAN3.lsnr' on 'cs1' CRS-2673: Attempting to stop 'ora.cvu' on 'cs1' CRS-2673: Attempting to stop 'ora.gns.vip' on 'cs1' CRS-2677: Stop of 'ora.LISTENER.lsnr' on 'cs1' succeeded CRS-2677: Stop of 'ora.LISTENER_SCAN2.lsnr' on 'cs1' succeeded CRS-2673: Attempting to stop 'ora.scan2.vip' on 'cs1' CRS-2677: Stop of 'ora.LISTENER_SCAN3.lsnr' on 'cs1' succeeded CRS-2673: Attempting to stop 'ora.scan3.vip' on 'cs1' CRS-2677: Stop of 'ora.asm' on 'cs2' succeeded CRS-2673: Attempting to stop 'ora.ASMNET1LSNR_ASM.lsnr' on 'cs2' CRS-2677: Stop of 'ora.cs2.vip' on 'cs2' succeeded CRS-2677: Stop of 'ora.gns.vip' on 'cs1' succeeded CRS-2677: Stop of 'ora.scan1.vip' on 'cs2' succeeded CRS-2677: Stop of 'ora.scan3.vip' on 'cs1' succeeded CRS-2677: Stop of 'ora.ASMNET1LSNR_ASM.lsnr' on 'cs2' succeeded CRS-2673: Attempting to stop 'ora.ons' on 'cs2' CRS-2677: Stop of 'ora.scan2.vip' on 'cs1' succeeded CRS-2677: Stop of 'ora.ons' on 'cs2' succeeded CRS-2673: Attempting to stop 'ora.net1.network' on 'cs2' CRS-2677: Stop of 'ora.net1.network' on 'cs2' succeeded CRS-2792: Shutdown of Cluster Ready Services-managed resources on 'cs2' has completed CRS-2677: Stop of 'ora.chad' on 'cs1' succeeded CRS-2673: Attempting to stop 'ora.mgmtdb' on 'cs1' CRS-2677: Stop of 'ora.crsd' on 'cs2' succeeded CRS-2673: Attempting to stop 'ora.ctssd' on 'cs2' CRS-2673: Attempting to stop 'ora.evmd' on 'cs2' CRS-2673: Attempting to stop 'ora.storage' on 'cs2' CRS-2677: Stop of 'ora.cvu' on 'cs1' succeeded CRS-2677: Stop of 'ora.storage' on 'cs2' succeeded CRS-2673: Attempting to stop 'ora.asm' on 'cs2' CRS-2677: Stop of 'ora.ctssd' on 'cs2' succeeded CRS-2677: Stop of 'ora.mgmtdb' on 'cs1' succeeded CRS-2673: Attempting to stop 'ora.MGMTLSNR' on 'cs1' CRS-2673: Attempting to stop 'ora.CRS.dg' on 'cs1' CRS-2673: Attempting to stop 'ora.DATA.dg' on 'cs1' CRS-2677: Stop of 'ora.CRS.dg' on 'cs1' succeeded CRS-2677: Stop of 'ora.DATA.dg' on 'cs1' succeeded CRS-2673: Attempting to stop 'ora.asm' on 'cs1' CRS-2677: Stop of 'ora.evmd' on 'cs2' succeeded CRS-2677: Stop of 'ora.qosmserver' on 'cs1' succeeded CRS-2677: Stop of 'ora.MGMTLSNR' on 'cs1' succeeded CRS-2673: Attempting to stop 'ora.cs1.vip' on 'cs1' CRS-2677: Stop of 'ora.cs1.vip' on 'cs1' succeeded CRS-2677: Stop of 'ora.asm' on 'cs2' succeeded CRS-2673: Attempting to stop 'ora.cluster_interconnect.haip' on 'cs2' CRS-2677: Stop of 'ora.cluster_interconnect.haip' on 'cs2' succeeded CRS-2673: Attempting to stop 'ora.cssd' on 'cs2' CRS-2677: Stop of 'ora.cssd' on 'cs2' succeeded CRS-2677: Stop of 'ora.asm' on 'cs1' succeeded CRS-2673: Attempting to stop 'ora.ASMNET1LSNR_ASM.lsnr' on 'cs1' CRS-2677: Stop of 'ora.ASMNET1LSNR_ASM.lsnr' on 'cs1' succeeded CRS-2673: Attempting to stop 'ora.ons' on 'cs1' CRS-2677: Stop of 'ora.ons' on 'cs1' succeeded CRS-2673: Attempting to stop 'ora.net1.network' on 'cs1' CRS-2677: Stop of 'ora.net1.network' on 'cs1' succeeded CRS-2792: Shutdown of Cluster Ready Services-managed resources on 'cs1' has completed CRS-2677: Stop of 'ora.crsd' on 'cs1' succeeded CRS-2673: Attempting to stop 'ora.ctssd' on 'cs1' CRS-2673: Attempting to stop 'ora.evmd' on 'cs1' CRS-2673: Attempting to stop 'ora.storage' on 'cs1' CRS-2677: Stop of 'ora.storage' on 'cs1' succeeded CRS-2673: Attempting to stop 'ora.asm' on 'cs1' CRS-2677: Stop of 'ora.evmd' on 'cs1' succeeded CRS-2677: Stop of 'ora.ctssd' on 'cs1' succeeded CRS-2677: Stop of 'ora.asm' on 'cs1' succeeded CRS-2673: Attempting to stop 'ora.cluster_interconnect.haip' on 'cs1' CRS-2677: Stop of 'ora.cluster_interconnect.haip' on 'cs1' succeeded CRS-2673: Attempting to stop 'ora.cssd' on 'cs1' CRS-2677: Stop of 'ora.cssd' on 'cs1' succeeded [root@cs1 bin]# /u01/app/product/12.2.0/crs/bin/crsctl start cluster -all CRS-2672: Attempting to start 'ora.cssdmonitor' on 'cs1' CRS-2672: Attempting to start 'ora.evmd' on 'cs1' CRS-2672: Attempting to start 'ora.evmd' on 'cs2' CRS-2672: Attempting to start 'ora.cssdmonitor' on 'cs2' CRS-2676: Start of 'ora.cssdmonitor' on 'cs2' succeeded CRS-2672: Attempting to start 'ora.cssd' on 'cs2' CRS-2672: Attempting to start 'ora.diskmon' on 'cs2' CRS-2676: Start of 'ora.cssdmonitor' on 'cs1' succeeded CRS-2672: Attempting to start 'ora.cssd' on 'cs1' CRS-2672: Attempting to start 'ora.diskmon' on 'cs1' CRS-2676: Start of 'ora.diskmon' on 'cs1' succeeded CRS-2676: Start of 'ora.evmd' on 'cs1' succeeded CRS-2676: Start of 'ora.diskmon' on 'cs2' succeeded CRS-2676: Start of 'ora.evmd' on 'cs2' succeeded CRS-2676: Start of 'ora.cssd' on 'cs2' succeeded CRS-2672: Attempting to start 'ora.ctssd' on 'cs2' CRS-2672: Attempting to start 'ora.cluster_interconnect.haip' on 'cs2' CRS-2676: Start of 'ora.cssd' on 'cs1' succeeded CRS-2672: Attempting to start 'ora.ctssd' on 'cs1' CRS-2672: Attempting to start 'ora.cluster_interconnect.haip' on 'cs1' CRS-2676: Start of 'ora.ctssd' on 'cs2' succeeded CRS-2676: Start of 'ora.ctssd' on 'cs1' succeeded CRS-2676: Start of 'ora.cluster_interconnect.haip' on 'cs1' succeeded CRS-2672: Attempting to start 'ora.asm' on 'cs1' CRS-2676: Start of 'ora.cluster_interconnect.haip' on 'cs2' succeeded CRS-2672: Attempting to start 'ora.asm' on 'cs2' CRS-2676: Start of 'ora.asm' on 'cs2' succeeded CRS-2672: Attempting to start 'ora.storage' on 'cs2' CRS-2676: Start of 'ora.asm' on 'cs1' succeeded CRS-2672: Attempting to start 'ora.storage' on 'cs1' CRS-2676: Start of 'ora.storage' on 'cs1' succeeded CRS-2672: Attempting to start 'ora.crsd' on 'cs1' CRS-2676: Start of 'ora.crsd' on 'cs1' succeeded CRS-2676: Start of 'ora.storage' on 'cs2' succeeded CRS-2672: Attempting to start 'ora.crsd' on 'cs2' CRS-2676: Start of 'ora.crsd' on 'cs2' succeeded
执行service rsyslog restart命令来重启rsyslog服务
[root@cs1 bin]# service rsyslog restart Redirecting to /bin/systemctl restart rsyslog.service [root@cs1 bin]# service rsyslog status Redirecting to /bin/systemctl status rsyslog.service rsyslog.service - System Logging Service Loaded: loaded (/usr/lib/systemd/system/rsyslog.service; enabled) Active: active (running) since Wed 2018-08-01 15:13:22 CST; 12s ago Main PID: 23011 (rsyslogd) CGroup: /system.slice/rsyslog.service 鈹斺攢23011 /usr/sbin/rsyslogd -n Aug 01 15:13:22 cs1.jy.net systemd[1]: Started System Logging Service. [root@cs2 logrotate.d]# service rsyslog restart Redirecting to /bin/systemctl restart rsyslog.service [root@cs2 logrotate.d]# service rsyslog status Redirecting to /bin/systemctl status rsyslog.service rsyslog.service - System Logging Service Loaded: loaded (/usr/lib/systemd/system/rsyslog.service; enabled) Active: active (running) since Wed 2018-08-01 15:13:54 CST; 7s ago Main PID: 9809 (rsyslogd) CGroup: /system.slice/rsyslog.service 鈹斺攢9809 /usr/sbin/rsyslogd -n Aug 01 15:13:54 cs2.jy.net systemd[1]: Started System Logging Service.
5.验证Oracle ASM审计记录是否被记录到/var/log/oracle_asm_audit.log中
[root@cs1 bin]# tail -f /var/log/oracle_asm_audit.log Aug 1 15:13:46 cs1 journal: Oracle Audit[23601]: LENGTH : '317' ACTION :[80] 'begin dbms_diskgroup.close(:handle); exception when others then raise; end; Aug 1 15:13:48 cs1 journal: Oracle Audit[23610]: LENGTH : '244' ACTION :[7] 'CONNECT' DATABASE USER:[1] '/' PRIVILEGE :[6] 'SYSDBA' CLIENT USER:[6] 'oracle' CLIENT TERMINAL:[0] '' STATUS:[1] '0' DBID:[0] '' SESSIONID:[10] '4294967295' USERHOST:[10] 'cs1.jy.net' CLIENT ADDRESS:[0] '' ACTION NUMBER:[3] '100' Aug 1 15:13:50 cs1 journal: Oracle Audit[23654]: LENGTH : '244' ACTION :[7] 'CONNECT' DATABASE USER:[1] '/' PRIVILEGE :[6] 'SYSDBA' CLIENT USER:[6] 'oracle' CLIENT TERMINAL:[0] '' STATUS:[1] '0' DBID:[0] '' SESSIONID:[10] '4294967295' USERHOST:[10] 'cs1.jy.net' CLIENT ADDRESS:[0] '' ACTION NUMBER:[3] '100' Aug 1 15:13:50 cs1 journal: Oracle Audit[23654]: LENGTH : '494' ACTION :[257] 'select name_kfgrp, number_kfgrp, incarn_kfgrp, compat_kfgrp, dbcompat_kfgrp, state_kfgrp, flags32_kfgrp, type_kfgrp, refcnt_kfgrp, sector_kfgrp, blksize_kfgrp, ausize_kfgrp , totmb_kfgrp, freemb_kfgrp, coldmb_kfgrp, hotmb_kfgrp, minspc_kfgrp, usable_kfgrp, ' DATABASE USER:[1] '/' PRIVILEGE :[6] 'SYSDBA' CLIENT USER:[6] 'oracle' CLIENT TERMINAL:[0] '' STATUS:[1] '0' DBID:[0] '' SESSIONID:[10] '4294967295' USERHOST:[10] 'cs1.jy.net' CLIENT ADDRESS:[0] '' ACTION NUMBER:[1] '3' Aug 1 15:13:50 cs1 journal: Oracle Audit[23654]: LENGTH : '308' ACTION :[071] 'offline_kfgrp, lflags_kfgrp , logical_sector_kfgrp from x$kfgrp_stat Aug 1 15:13:55 cs1 journal: Oracle Audit[23681]: LENGTH : '244' ACTION :[7] 'CONNECT' DATABASE USER:[1] '/' PRIVILEGE :[6] 'SYSDBA' CLIENT USER:[6] 'oracle' CLIENT TERMINAL:[0] '' STATUS:[1] '0' DBID:[0] '' SESSIONID:[10] '4294967295' USERHOST:[10] 'cs1.jy.net' CLIENT ADDRESS:[0] '' ACTION NUMBER:[3] '100' Aug 1 15:13:56 cs1 journal: Oracle Audit[23681]: LENGTH : '370' ACTION :[132] 'begin dbms_diskgroup.openpwfile(:NAME,:lblksize,:fsz,:handle,:pblksz,:fmode,:genfname); exception when others then raise; end; Aug 1 15:13:56 cs1 journal: Oracle Audit[23681]: LENGTH : '355' ACTION :[117] 'begin dbms_diskgroup.read(:handle,:offset,:length,:buffer,:reason,:mirr); exception when others then raise; end; Aug 1 15:13:56 cs1 journal: Oracle Audit[23681]: LENGTH : '355' ACTION :[117] 'begin dbms_diskgroup.read(:handle,:offset,:length,:buffer,:reason,:mirr); exception when others then raise; end; Aug 1 15:13:56 cs1 journal: Oracle Audit[23681]: LENGTH : '317' ACTION :[80] 'begin dbms_diskgroup.close(:handle); exception when others then raise; end; [root@cs2 logrotate.d]# tail -f /var/log/oracle_asm_audit.log Aug 1 15:14:46 cs2 journal: Oracle Audit[9928]: LENGTH : '299' ACTION :[51] 'BEGIN DBMS_SESSION.USE_DEFAULT_EDITION_ALWAYS; END;' DATABASE USER:[1] '/' PRIVILEGE :[6] 'SYSRAC' CLIENT USER:[6] 'oracle' CLIENT TERMINAL:[0] '' STATUS:[1] '0' DBID:[10] '1386528187' SESSIONID:[10] '4294967295' USERHOST:[10] 'cs2.jy.net' CLIENT ADDRESS:[0] '' ACTION NUMBER:[2] '47' Aug 1 15:14:46 cs2 journal: Oracle Audit[9928]: LENGTH : '287' ACTION :[39] 'ALTER SESSION SET "_notify_crs" = false' DATABASE USER:[1] '/' PRIVILEGE :[6] 'SYSRAC' CLIENT USER:[6] 'oracle' CLIENT TERMINAL:[0] '' STATUS:[1] '0' DBID:[10] '1386528187' SESSIONID:[10] '4294967295' USERHOST:[10] 'cs2.jy.net' CLIENT ADDRESS:[0] '' ACTION NUMBER:[2] '42' Aug 1 15:14:46 cs2 journal: Oracle Audit[9926]: LENGTH : '287' ACTION :[39] 'ALTER SESSION SET "_notify_crs" = false' DATABASE USER:[1] '/' PRIVILEGE :[6] 'SYSRAC' CLIENT USER:[6] 'oracle' CLIENT TERMINAL:[0] '' STATUS:[1] '0' DBID:[10] '1386528187' SESSIONID:[10] '4294967295' USERHOST:[10] 'cs2.jy.net' CLIENT ADDRESS:[0] '' ACTION NUMBER:[2] '42' Aug 1 15:14:47 cs2 journal: Oracle Audit[9928]: LENGTH : '292' ACTION :[45] 'SELECT value FROM v$parameter WHERE name = :1' DATABASE USER:[1] '/' PRIVILEGE :[6] 'SYSRAC' CLIENT USER:[6] 'oracle' CLIENT TERMINAL:[0] '' STATUS:[1] '0' DBID:[10] '1386528187' SESSIONID:[10] '4294967295' USERHOST:[10] 'cs2.jy.net' CLIENT ADDRESS:[0] '' ACTION NUMBER:[1] '3' Aug 1 15:14:47 cs2 journal: Oracle Audit[9928]: LENGTH : '292' ACTION :[45] 'SELECT value FROM v$parameter WHERE name = :1' DATABASE USER:[1] '/' PRIVILEGE :[6] 'SYSRAC' CLIENT USER:[6] 'oracle' CLIENT TERMINAL:[0] '' STATUS:[1] '0' DBID:[10] '1386528187' SESSIONID:[10] '4294967295' USERHOST:[10] 'cs2.jy.net' CLIENT ADDRESS:[0] '' ACTION NUMBER:[1] '3' Aug 1 15:14:47 cs2 journal: Oracle Audit[9928]: LENGTH : '292' ACTION :[45] 'SELECT value FROM v$parameter WHERE name = :1' DATABASE USER:[1] '/' PRIVILEGE :[6] 'SYSRAC' CLIENT USER:[6] 'oracle' CLIENT TERMINAL:[0] '' STATUS:[1] '0' DBID:[10] '1386528187' SESSIONID:[10] '4294967295' USERHOST:[10] 'cs2.jy.net' CLIENT ADDRESS:[0] '' ACTION NUMBER:[1] '3' Aug 1 15:14:47 cs2 journal: Oracle Audit[9928]: LENGTH : '292' ACTION :[45] 'SELECT value FROM v$parameter WHERE name = :1' DATABASE USER:[1] '/' PRIVILEGE :[6] 'SYSRAC' CLIENT USER:[6] 'oracle' CLIENT TERMINAL:[0] '' STATUS:[1] '0' DBID:[10] '1386528187' SESSIONID:[10] '4294967295' USERHOST:[10] 'cs2.jy.net' CLIENT ADDRESS:[0] '' ACTION NUMBER:[1] '3' Aug 1 15:15:01 cs2 journal: Oracle Audit[9944]: LENGTH : '244' ACTION :[7] 'CONNECT' DATABASE USER:[1] '/' PRIVILEGE :[6] 'SYSDBA' CLIENT USER:[6] 'oracle' CLIENT TERMINAL:[0] '' STATUS:[1] '0' DBID:[0] '' SESSIONID:[10] '4294967295' USERHOST:[10] 'cs2.jy.net' CLIENT ADDRESS:[0] '' ACTION NUMBER:[3] '100'
可以看到Oracle ASM审计记录已经被记录到了/var/log/oracle_asm_audit.log文件中。