oracle 12c-19c
rac数据库运行时间久了发现本地磁盘剩余空间下降到了预警值,此时需要删除历史相关日志以释放磁盘空间,保障系统稳定运行。
注:以下操作在rac多个节点都要执行。
1) 清理审计日志
审计日志位置
数据库实例审计日志位置:
可以登录数据库实例,show paramerter audit 查看audit_file_dest参数值
sys@orcl1>show parameter audit;
name type value
------------------------------------ ----------- ------------------------------
audit_file_dest string /u01/app/oracle/admin/orcl/adump
audit_sys_operations boolean true
audit_syslog_level string
audit_trail string db
unified_audit_common_systemlog string
unified_audit_sga_queue_size integer 1048576
unified_audit_systemlog string
asm实例审计日志位置:
可以登录asm实例,show paramerter audit 查看audit_file_dest参数值
sql> show parameter audit;
name type value
------------------------------------ ---------------------- ------------------------------
audit_file_dest string /u01/app/19.3.0/grid/rdbms/audit
audit_sys_operations boolean true
audit_syslog_level string
audit_trail string none
unified_audit_sga_queue_size integer 1048576
清理数据库审计日志
#使用root用户或者oracle用户执行,-mtime 3 是清理3天前的日志文件,如需保留更多天数,可修改该值
cd /u01/app/oracle/admin/orcl/adump/
ls |wc -l
ls -lrt|head -10
find . -mtime 3 -type f -name "*.aud" |xargs rm -rf
ls |wc -l
ls -lrt|head -10
示例:
[root@ora19crac1 audit]# cd /u01/app/oracle/admin/orcl/adump/
[root@ora19crac1 adump]# ls |wc -l
198
[root@ora19crac1 adump]# ls -lrt|head -10
total 13680
-rw-r----- 1 oracle asmadmin 867 apr 27 2020 orcl1_ora_27093_20200427150323625841608381.aud
-rw-r----- 1 oracle asmadmin 8210 apr 27 2020 orcl1_ora_28163_20200427150323944626945847.aud
-rw-r----- 1 oracle asmadmin 2678 apr 27 2020 orcl1_ora_30656_20200427150437063733912438.aud
-rw-r----- 1 oracle asmadmin 2678 apr 27 2020 orcl1_ora_30653_20200427150437065541988321.aud
-rw-r----- 1 oracle asmadmin 3046 apr 27 2020 orcl1_ora_30658_20200427150437067309947251.aud
-rw-r----- 1 oracle asmadmin 3046 apr 27 2020 orcl1_ora_30677_20200427150438739530264934.aud
-rw-r----- 1 oracle asmadmin 6933 apr 27 2020 orcl1_ora_30670_20200427150438402792242906.aud
-rw-r----- 1 oracle asmadmin 3042 apr 27 2020 orcl1_ora_554_20200427150526493620551772.aud
-rw-r----- 1 oracle asmadmin 3042 apr 27 2020 orcl1_ora_685_20200427150527979655761360.aud
[root@ora19crac1 adump]#
[root@ora19crac1 adump]# find . -mtime 3 -type f -name "*.aud" |xargs rm -rf
[root@ora19crac1 adump]#
[root@ora19crac1 adump]# ls |wc -l
14
清理asm审计日志
#使用root用户或者grid用户执行,-mtime 3 是清理3天前的日志文件,如需保留更多天数,可修改该值
cd /u01/app/19.3.0/grid/rdbms/audit/
ls |wc -l
ls -lrt|head -10
find . -mtime 3 -type f -name "*.aud" |xargs rm -rf
ls |wc -l
ls -lrt|head -10
示例:
[root@ora19crac1 ~]# cd /u01/app/19.3.0/grid/rdbms/audit/
[root@ora19crac1 audit]# ls |wc -l
8490
[root@ora19crac1 audit]# ls -lrt|head -10
total 33964
-rw-r----- 1 grid oinstall 816 apr 27 2020 asm1_ora_25395_20200427150209390706516328.aud
-rw-r----- 1 grid oinstall 850 apr 27 2020 asm1_ora_25395_20200427150225057374055964.aud
-rw-r----- 1 grid oinstall 857 apr 27 2020 asm1_ora_26023_20200427150225247909285932.aud
-rw-r----- 1 grid oinstall 857 apr 27 2020 asm1_ora_26290_20200427150235496955889812.aud
-rw-r----- 1 grid oinstall 857 apr 27 2020 asm1_ora_26295_20200427150235635170703067.aud
-rw-r----- 1 grid oinstall 857 apr 27 2020 asm1_ora_26300_20200427150235732891454289.aud
-rw-r----- 1 grid oinstall 857 apr 27 2020 asm1_ora_26328_20200427150237308635974561.aud
-rw-r----- 1 grid oinstall 857 apr 27 2020 asm1_ora_26330_20200427150237339497010358.aud
-rw-r----- 1 grid oinstall 857 apr 27 2020 asm1_ora_26542_20200427150244382973514557.aud
[root@ora19crac1 audit]#
[root@ora19crac1 audit]# find . -mtime 3 -type f -name "*.aud" |xargs rm -rf
[root@ora19crac1 audit]#
[root@ora19crac1 audit]# ls |wc -l
44
[root@ora19crac1 audit]# ls -lrt|head -10
total 176
-rw-r----- 1 grid oinstall 814 aug 20 11:10 asm1_ora_6525_20220820111021894623958065.aud
-rw-r----- 1 grid oinstall 848 aug 20 11:10 asm1_ora_6525_20220820111038056135557491.aud
-rw-r----- 1 grid oinstall 855 aug 20 11:10 asm1_ora_6733_20220820111038134165027400.aud
-rw-r----- 1 grid oinstall 855 aug 20 11:10 asm1_ora_6802_20220820111048347568507960.aud
-rw-r----- 1 grid oinstall 855 aug 20 11:10 asm1_ora_6809_20220820111048626520514941.aud
-rw-r----- 1 grid oinstall 855 aug 20 11:10 asm1_ora_6830_20220820111049858229622677.aud
-rw-r----- 1 grid oinstall 855 aug 20 11:10 asm1_ora_6835_20220820111050097486164720.aud
-rw-r----- 1 grid oinstall 855 aug 20 11:10 asm1_ora_6839_20220820111050289642832065.aud
-rw-r----- 1 grid oinstall 855 aug 20 11:10 asm1_ora_6855_20220820111051924704643995.aud
2) 清理trace日志
清理crs trace日志
su - grid
cd $oracle_base/diag/crs/$hostname/crs/trace/
ls |wc -l
ls -lrt|head -10
find . -mtime 3 -type f -name "*.trm" |xargs rm -rf
find . -mtime 3 -type f -name "*.trc" |xargs rm -rf
ls |wc -l
ls -lrt|head -10
示例:
[grid@ora19crac2 trace]$ cd
[grid@ora19crac2 ~]$ cd $oracle_base/diag/crs/$hostname/crs/trace/
[grid@ora19crac2 trace]$ ls |wc -l
513
[grid@ora19crac2 trace]$ ls -lrt|head -10
total 1266184
-rw-rw---- 1 root oinstall 2453379 apr 27 2020 ologgerd.trm
-rw-rw---- 1 root oinstall 14681557 apr 27 2020 ologgerd.trc
-rw-rw---- 1 grid oinstall 7266935 apr 30 2020 ocssd_1.trm
-rw-rw---- 1 grid oinstall 52438517 apr 30 2020 ocssd_1.trc
-rw-rw---- 1 root oinstall 4369015 apr 30 2020 ohasd_orarootagent_root_1.trm
-rw-rw---- 1 root oinstall 26215585 apr 30 2020 ohasd_orarootagent_root_1.trc
-rw-rw---- 1 grid oinstall 4528217 may 12 2020 crsd_oraagent_grid_1.trm
-rw-rw---- 1 grid oinstall 26215285 may 12 2020 crsd_oraagent_grid_1.trc
-rw-rw---- 1 grid oinstall 7365901 may 12 2020 ocssd_2.trm
[grid@ora19crac2 trace]$ find . -mtime 3 -type f -name "*.trm" |xargs rm -rf
[grid@ora19crac2 trace]$ find . -mtime 3 -type f -name "*.trc" |xargs rm -rf
[grid@ora19crac2 trace]$ ls |wc -l
189
[grid@ora19crac2 trace]$ ls -lrt|head -10
total 279236
-rw-rw---- 1 root oinstall 1507 aug 20 11:08 crsctl_4805.trm
-rw-rw---- 1 root oinstall 8169 aug 20 11:08 crsctl_4805.trc
-rw-rw---- 1 root oinstall 864 aug 20 11:09 acfsutil_5655.trm
-rw-rw---- 1 root oinstall 365 aug 20 11:09 acfsutil_5655.trc
-rw-rw---- 1 root oinstall 863 aug 20 11:09 acfsutil_5741.trm
-rw-rw---- 1 root oinstall 365 aug 20 11:09 acfsutil_5741.trc
-rw-rw---- 1 root oinstall 905 aug 20 11:09 crsctl_5913.trm
-rw-rw---- 1 root oinstall 2400 aug 20 11:09 crsctl_5913.trc
-rw-rw---- 1 root oinstall 905 aug 20 11:09 crsctl_5924.trm
清理数据库实例 trace日志
#使用root或者oracle 用户
cd $oracle_base/diag/rdbms/{dbname}/{oracle_sid}/trace
ls -lrt|head -10
find . -mtime 3 -type f -name "*.trm" |xargs rm -rf
find . -mtime 3 -type f -name "*.trc" |xargs rm -rf
ls |wc -l
示例:
[oracle@ora19crac2 ~]$ cd $oracle_base/diag/rdbms/orcl/orcl2/trace
[oracle@ora19crac2 trace]$ ls -lrt|head -10
total 22400
-rw-r----- 1 oracle asmadmin 878 aug 20 11:14 orcl2_vktm_16958.trm
-rw-r----- 1 oracle asmadmin 1131 aug 20 11:14 orcl2_vktm_16958.trc
-rw-r----- 1 oracle asmadmin 868 aug 20 11:14 orcl2_ofsd_17018_17031.trm
-rw-r----- 1 oracle asmadmin 966 aug 20 11:14 orcl2_ofsd_17018_17031.trc
-rw-r----- 1 oracle asmadmin 860 aug 20 11:14 orcl2_vkrm_17041.trm
-rw-r----- 1 oracle asmadmin 1086 aug 20 11:14 orcl2_vkrm_17041.trc
-rw-r----- 1 oracle asmadmin 875 aug 20 11:14 orcl2_dia0_17074.trm
-rw-r----- 1 oracle asmadmin 1212 aug 20 11:14 orcl2_dia0_17074.trc
-rw-r----- 1 oracle asmadmin 862 aug 20 11:14 orcl2_gen0_16980.trm
[oracle@ora19crac2 trace]$ find . -mtime 3 -type f -name "*.trm" |xargs rm -rf
[oracle@ora19crac2 trace]$ find . -mtime 3 -type f -name "*.trc" |xargs rm -rf
[oracle@ora19crac2 trace]$ ls |wc -l
243
3) 清理监听日志
检查监听数量
rac的每个节点会有多个监听
监听配置路径:
su - grid
$oracle_base/diag/tnslsnr/$hostname/{监听名}
[grid@12cdb01~]$ps -ef|grep lsnr|grep -v grep
grid 9722 1 0 apr25 ? 00:10:48 /u01/app/12c/grid/bin/tnslsnr asmnet1lsnr_asm -no_crs_notify -inherit
grid 9777 1 0 apr25 ? 00:10:05 /u01/app/12c/grid/bin/tnslsnr listener -no_crs_notify -inherit
[grid@12cdb01~]$lsnrctl status asmnet1lsnr_asm
lsnrctl for linux: version 12.2.0.1.0 - production on 24-may-2022 16:13:26
米乐app官网下载 copyright (c) 1991, 2016, oracle. all rights reserved.
connecting to (description=(address=(protocol=ipc)(key=asmnet1lsnr_asm)))
status of the listener
------------------------
alias asmnet1lsnr_asm
version tnslsnr for linux: version 12.2.0.1.0 - production
start date 25-apr-2022 16:36:11
uptime 28 days 23 hr. 37 min. 14 sec
trace level off
security on: local os authentication
snmp off
listener parameter file /u01/app/12c/grid/network/admin/listener.ora
listener log file /u01/app/grid/diag/tnslsnr/12cdb01/asmnet1lsnr_asm/alert/log.xml
listening endpoints summary...
(description=(address=(protocol=ipc)(key=asmnet1lsnr_asm)))
(description=(address=(protocol=tcp)(host=10.0.37.210)(port=1526)))
services summary...
service " asm" has 2 instance(s).
instance " asm1", status ready, has 2 handler(s) for this service...
instance " asm2", status ready, has 1 handler(s) for this service...
service " asm_datadg" has 2 instance(s).
instance " asm1", status ready, has 2 handler(s) for this service...
instance " asm2", status ready, has 1 handler(s) for this service...
service " asm_mgmtdg" has 2 instance(s).
instance " asm1", status ready, has 2 handler(s) for this service...
instance " asm2", status ready, has 1 handler(s) for this service...
service " asm_ocrdg" has 2 instance(s).
instance " asm1", status ready, has 2 handler(s) for this service...
instance " asm2", status ready, has 1 handler(s) for this service...
the command completed successfully
每个监听有两个监听日志文件
1).xml文件在alert目录下,会自动归档的,清理时只需要直接删除老的文件即可
如下最早的监听日志还是2020年的,每天一个.xml文件
[grid@12cdb01/u01/app/grid/diag/tnslsnr/12cdb01/asmnet1lsnr_asm/alert]$ls -lrth|head -10
total 5.4g
-rw-r----- 1 grid oinstall 11m nov 27 2020 log_1.xml
-rw-r----- 1 grid oinstall 11m nov 28 2020 log_2.xml
-rw-r----- 1 grid oinstall 11m nov 29 2020 log_3.xml
-rw-r----- 1 grid oinstall 11m nov 30 2020 log_4.xml
-rw-r----- 1 grid oinstall 11m dec 1 2020 log_5.xml
-rw-r----- 1 grid oinstall 11m dec 2 2020 log_6.xml
-rw-r----- 1 grid oinstall 11m dec 3 2020 log_7.xml
-rw-r----- 1 grid oinstall 11m dec 4 2020 log_8.xml
-rw-r----- 1 grid oinstall 11m dec 5 2020 log_9.xml
[grid@12cdb01/u01/app/grid/diag/tnslsnr/12cdb01/asmnet1lsnr_asm/alert]$ls -lrth|tail -10
-rw-r----- 1 grid oinstall 11m may 15 21:04 log_536.xml
-rw-r----- 1 grid oinstall 11m may 16 20:54 log_537.xml
-rw-r----- 1 grid oinstall 11m may 17 20:57 log_538.xml
-rw-r----- 1 grid oinstall 11m may 18 21:01 log_539.xml
-rw-r----- 1 grid oinstall 11m may 19 21:06 log_540.xml
-rw-r----- 1 grid oinstall 11m may 20 21:11 log_541.xml
-rw-r----- 1 grid oinstall 11m may 21 21:16 log_542.xml
-rw-r----- 1 grid oinstall 11m may 22 21:24 log_543.xml
-rw-r----- 1 grid oinstall 11m may 23 21:30 log_544.xml
-rw-r----- 1 grid oinstall 7.8m may 24 16:17 log.xml
进行清理:
清理一周前的.xml文件)
检查监听
[grid@12cdb01/u01/app/grid/diag/tnslsnr/12cdb01]$ll
total 0
drwxr-xr-x 14 grid oinstall 179 nov 26 2020 asmnet1lsnr_asm
drwxr-xr-x 14 grid oinstall 179 nov 26 2020 listener
drwxr-xr-x 14 grid oinstall 179 nov 26 2020 listener_scan1
drwxr-xr-x 14 grid oinstall 179 jan 18 2021 lsnr1523
drwxr-xr-x 14 grid oinstall 179 apr 11 19:05 mgmtlistener
drwxr-xr-x 14 grid oinstall 179 nov 26 2020 mgmtlsnr
清理asmnet1lsnr_asm
find /u01/app/grid/diag/tnslsnr/12cdb01/asmnet1lsnr_asm/alert -mtime 7 -type f -name "*.xml" |xargs rm -rf
[grid@12cdb01/u01/app/grid/diag/tnslsnr/12cdb01/asmnet1lsnr_asm/alert]$find /u01/app/grid/diag/tnslsnr/12cdb01/asmnet1lsnr_asm/alert -mtime 7 -type f -name "*.xml" |xargs rm -rf
[grid@12cdb01/u01/app/grid/diag/tnslsnr/12cdb01/asmnet1lsnr_asm/alert]$ls -lrth|head -10
total 89m
-rw-r----- 1 grid oinstall 11m may 16 20:54 log_537.xml
-rw-r----- 1 grid oinstall 11m may 17 20:57 log_538.xml
-rw-r----- 1 grid oinstall 11m may 18 21:01 log_539.xml
-rw-r----- 1 grid oinstall 11m may 19 21:06 log_540.xml
-rw-r----- 1 grid oinstall 11m may 20 21:11 log_541.xml
-rw-r----- 1 grid oinstall 11m may 21 21:16 log_542.xml
-rw-r----- 1 grid oinstall 11m may 22 21:24 log_543.xml
-rw-r----- 1 grid oinstall 11m may 23 21:30 log_544.xml
-rw-r----- 1 grid oinstall 8.0m may 24 16:38 log.xml
清理listener\listener_scan1\lsnr1523。。。 监听.xml文件同上一样。
2).log文件在trace目录下,这个不会自动归档,清理时不能直接删除原文件,如需mv原文件需要关闭监听日志输出
清理.log文件
1)清理asmnet1lsnr_asm 监听.log文件
[grid@12cdb01/u01/app/grid/diag/tnslsnr/12cdb01/asmnet1lsnr_asm/trace]$lsnrctl
lsnrctl for linux: version 12.2.0.1.0 - production on 24-may-2022 17:09:42
米乐app官网下载 copyright (c) 1991, 2016, oracle. all rights reserved.
welcome to lsnrctl, type "help" for information.
lsnrctl> set current_listener asmnet1lsnr_asm
current listener is asmnet1lsnr_asm
lsnrctl> status
connecting to (description=(address=(protocol=ipc)(key=asmnet1lsnr_asm)))
status of the listener
------------------------
alias asmnet1lsnr_asm
version tnslsnr for linux: version 12.2.0.1.0 - production
start date 25-apr-2022 16:36:11
uptime 29 days 0 hr. 34 min. 25 sec
trace level off
security on: local os authentication
snmp off
listener parameter file /u01/app/12c/grid/network/admin/listener.ora
listener log file /u01/app/grid/diag/tnslsnr/12cdb01/asmnet1lsnr_asm/alert/log.xml
listening endpoints summary...
(description=(address=(protocol=ipc)(key=asmnet1lsnr_asm)))
(description=(address=(protocol=tcp)(host=10.0.37.210)(port=1526)))
services summary...
service " asm" has 2 instance(s).
instance " asm1", status ready, has 2 handler(s) for this service...
instance " asm2", status ready, has 1 handler(s) for this service...
service " asm_datadg" has 2 instance(s).
instance " asm1", status ready, has 2 handler(s) for this service...
instance " asm2", status ready, has 1 handler(s) for this service...
service " asm_mgmtdg" has 2 instance(s).
instance " asm1", status ready, has 2 handler(s) for this service...
instance " asm2", status ready, has 1 handler(s) for this service...
service " asm_ocrdg" has 2 instance(s).
instance " asm1", status ready, has 2 handler(s) for this service...
instance " asm2", status ready, has 1 handler(s) for this service...
the command completed successfully
lsnrctl> show log_status
connecting to (description=(address=(protocol=ipc)(key=asmnet1lsnr_asm)))
asmnet1lsnr_asm parameter "log_status" set to on
the command completed successfully
lsnrctl> set log_status off
connecting to (description=(address=(protocol=ipc)(key=asmnet1lsnr_asm)))
asmnet1lsnr_asm parameter "log_status" set to off
the command completed successfully
lsnrctl> show log_status
connecting to (description=(address=(protocol=ipc)(key=asmnet1lsnr_asm)))
asmnet1lsnr_asm parameter "log_status" set to off
the command completed successfully
关闭日志输出后,在另一个会话将asmnet1lsnr_asm.log 进行mv操作或者rm操作
[grid@12cdb01/u01/app/grid/diag/tnslsnr/12cdb01/asmnet1lsnr_asm/trace]$mv asmnet1lsnr_asm.log asmnet1lsnr_asm.log.bak
[grid@12cdb01/u01/app/grid/diag/tnslsnr/12cdb01/asmnet1lsnr_asm/trace]$ll
total 3108300
-rw-r----- 1 grid oinstall 3178705934 may 24 17:17 asmnet1lsnr_asm.log.bak
开启日志输出
lsnrctl> set log_status on
connecting to (description=(address=(protocol=ipc)(key=asmnet1lsnr_asm)))
asmnet1lsnr_asm parameter "log_status" set to on
the command completed successfully
lsnrctl> show log_status
connecting to (description=(address=(protocol=ipc)(key=asmnet1lsnr_asm)))
asmnet1lsnr_asm parameter "log_status" set to on
the command completed successfully
lsnrctl>
可以看到新的log文件已经生成,并且监听日志已经写到新的文件里了,asmnet1lsnr_asm.log.bak可以移走或者删除了
[grid@12cdb01/u01/app/grid/diag/tnslsnr/12cdb01/asmnet1lsnr_asm/trace]$ll
total 3108304
-rw-r----- 1 grid oinstall 709 may 24 17:18 asmnet1lsnr_asm.log
-rw-r----- 1 grid oinstall 3178705934 may 24 17:17 asmnet1lsnr_asm.log.bak
[grid@12cdb01/u01/app/grid/diag/tnslsnr/12cdb01/asmnet1lsnr_asm/trace]$tail -f asmnet1lsnr_asm.log
24-may-2022 17:18:09 * (connect_data=(cid=(program=)(host=12cdb01)(user=grid))(command=status)(arguments=64)(service=asmnet1lsnr_asm)(version=203424000)) * status * 0
24-may-2022 17:18:10 * log_status * 0
2022-05-24t17:18:12.607752 08:00
24-may-2022 17:18:12 * (connect_data=(cid=(program=)(host=12cdb01)(user=grid))(command=status)(arguments=64)(service=asmnet1lsnr_asm)(version=203424000)) * status * 0
2022-05-24t17:18:15.610104 08:00
24-may-2022 17:18:15 * (connect_data=(cid=(program=)(host=12cdb01)(user=grid))(command=status)(arguments=64)(service=asmnet1lsnr_asm)(version=203424000)) * status * 0
2022-05-24t17:18:18.605210 08:00
24-may-2022 17:18:18 * (connect_data=(cid=(program=)(host=12cdb01)(user=grid))(command=status)(arguments=64)(service=asmnet1lsnr_asm)(version=203424000)) * status * 0
2022-05-24t17:18:21.602345 08:00
24-may-2022 17:18:21 * (connect_data=(cid=(program=)(host=12cdb01)(user=grid))(command=status)(arguments=64)(service=asmnet1lsnr_asm)(version=203424000)) * status * 0
清理listener\listener_scan1\lsnr1523。。。 监听.log文件同上一样。
最后修改时间:2022-08-25 15:03:29
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【米乐app官网下载的版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。