您好,登錄后才能下訂單哦!
使用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參數
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文件中。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。