linux checks
df -h check disk space, human readable
df --block-size=1G | column -t check disk space by column, Gb
df -ih check inodes space
du -sh size of current dir
du -sh * size of all files and dirs in the current dir
du -sh * 2>dev/null # without error messages, if you logged in not as root
asm checks
. grid.env
su - grid
or
export ORACLE_HOME=/oracle/product/11.2.0.3/grid
export ORACLE_SID=+ASM1
export PATH=$ORACLE_HOME/bin:$PATH
export TNS_ADMIN=/oracle/product/11.2.0.3/grid/network/admin/
asmcmd
lsdg
lsdks
ls -s +data/orcl/datafile Block_Size Blocks Bytes Space Name
du DATA/orcl Used_MB Mirror_used_MB
ls -lt +data/orcl/datafile Type Redund Striped Time Sys Name
ls -l +data/orcl/datafile/sy*
ls --permission +data/orcl/datafile User Group Permission Name
Clear 15 days old ASM audit log files each monday at 1800 hours
00 18 00 00 1 /usr/bin/find $CRS_HOME/rdbms/audit -iname "*\.aud" -daystart -atime 15 -exec rm {} \;
That's it for the ASM audit logs. Of course, if you running Oracle RAC, then make sure to update every node's grid crontab!
find big files
du -ma $ORACLE_HOME | sort -nr | head -n 20 top-20 big files, in Mb, find .log files
clean files older than 5 days
find /data/*.log -mtime +5 -exec echo {} \;
find /data/*.log -mtime +5 -exec rm {} \;
clean oracle backups
RMAN> CROSSCHECK BACKUP;
RMAN> DELETE NOPROMPT OBSOLETE; delete old backups
RMAN> list backup of database summary;
If we need to delete archivelogs as emergency. (!) Then run FULL backup (!)
RMAN> DELETE NOPROMPT ARCHIVELOG ALL COMPLETED BEFORE 'SYSDATE - 7';
RMAN> DELETE NOPROMPT ARCHIVELOG UNTIL TIME 'SYSDATE - 5';
RMAN> DELETE ARCHIVELOG ALL;
RMAN-08138: WARNING: archived log not deleted - must create more backups
Delete archivelogs as emergency. (!) Then run FULL backup (!)
RMAN> DELETE FORCE NOPROMPT ARCHIVELOG ALL COMPLETED BEFORE 'SYSDATE - 10';
Clean audit files
SQL> SHOW PARAMETER AUDIT_FILE_DEST;
cd /oracle/product/19.1.0/db_1/rdbms/audit
find *.aud -mtime +90 -exec echo {} \;
find *.aud -mtime +90 -exec rm {} \;
rm $CRS_HOME/rdbms/audit/*.aud
If Error: -bash: /usr/bin/find: Argument list too long, use this:
find /u01/app/oracle/admin/ORCL/adump/ -name '*.aud' -mtime +90 -exec rm {} \;
SQL> truncate table SYS.AUD$; clean audit records, usually in the SYSTEM tablespace
clean bdump, udump and audit older 14 days
vi clean_all.ksh
#!/bin/ksh
for ORACLE_SID in `cat /etc/oratab|egrep ':N|:Y'|grep -v \*|cut -f1 -d':'`
do
ORACLE_HOME=`cat /etc/oratab|grep ^$ORACLE_SID:|cut -d":" -f2`
DBA=`echo $ORACLE_HOME | sed -e 's:/product/.*::g'`/admin
find $DBA/$ORACLE_SID/bdump -name \*.trc -mtime +14 -exec rm {} \;
$DBA/$ORACLE_SID/udump -name \*.trc -mtime +14 -exec rm {} \;
find $ORACLE_HOME/rdbms/audit -name \*.aud -mtime +14 -exec rm {} \;
done
script loops through each database, visiting the bdump, udump and audit directories, removing all files more than 2 weeks old
clean trace files older than 5 days
find /oracle/admin/ORCL/udump -name *.trc -mtime +5 -exec rm {} \; >/dev/null 2>&1
script sample "del_cdmp.sh"
#!/bin/bash
rm -r /oracle/diag/rdbms/orcl/ORCL1/trace/cdmp* ORCL1 - on the 1-st RAC server, repeat it on the other clusters