Clean Disk Space

User Rating: 5 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Active
 

 

Linux checks

df -h                                    check disk space, human view
df -g | 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 for example

HP-UX checks

bdf                                      check disk space
df -k

du -ks * size of all files and dirs in the current dir

ASM checks

. grid.env
          su - grid
      or
          export ORACLE_HOME=/u01/app/11.2.0.3/grid
          export ORACLE_SID=+ASM1
          export PATH=$ORACLE_HOME/bin:$PATH
          export TNS_ADMIN=/u01/app/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 30                TOP-30 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 /u01/app/oracle/product/11.2.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

/usr/bin/find /u01/app/oracle/admin/ORCL/udump -name *.trc -mtime +5 -exec rm {} \; >/dev/null 2>&1

Script sample "del_cdmp.sh"

#!/bin/bash
rm -r /u01/app/oracle/diag/rdbms/orcl/ORCL1/trace/cdmp*                         ORCL1 - on the 1-st RAC server, repeat it on the other clusters

ADRCI, clean older than 1 days

adrci
show homes
set home diag/RDBMS/orcl
purge -age 1

Automate clean up disk space in the home (u01)

cd
mkdir scripts
vi /home/oracle/scripts/adrci.sh

#!/bin/sh
. ~/orcl.env
adrci exec="set home diag/rdbms/orcl/ORCL1; purge -age 1"
adrci exec="set home diag/tnslsnr/postcode/listener; purge -age 1"

crontab -e
50 11 * * * /home/oracle/scripts/adrci.sh
00 20 * * * su - oracle -c "/bin/bash /home/oracle/scripts/adrci.sh"
chmod -R 775 /home/oracle/scripts/

ADR retention policy – automatic purge

adrci> show control

adrci> set control (LONGP_POLICY = 8760)
LONGP_POLICY
The incident metadata retention policy controls how long the metadata is kept around. This policy has a default setting of one year (default is 8760 = 365 days = 1 year). Here are the components that currently get purged by LONGP_POLICY:

ALERT — files in the ./alert directory
INCIDENT – files in the ./incident/incdir_ directory.
SWEEP — files in the ./sweep directory
STAGE — files in the ./stage directory
HM — files in the ./hm directory and metadata in the HM schema

adrci> set control (SHORTP_POLICY = 720)
SHORTP_POLICY
The incident files and dumps retention policy controls how long generated dump files are kept around. This policy has a default setting of one month (default is 720 which corresponds to 30 days – approximately 1 month). Here are the components that currently get purged by SHORTP_POLICY:

TRACE – files in the ./trace directory
CDUMP – files in the ./cdump directory
UTSCDMP – files in the ./trace/cdmp_ directories
IPS – files in the ./incpkg directory and metadata in the IPS schema

Manual purge of ADR files

$ crontab -e
00 05 * * 0 adr_purge.sh

# Purge ADR contents (adr_purge.sh)
echo "INFO: adrci purge started at 'date'"
adrci exec="show homes"|grep -v : | while read file_line
do
echo "INFO: adrci purging diagnostic destination " $file_line
echo "INFO: purging ALERT older than 90 days"
adrci exec="set homepath $file_line;purge -age 129600 -type ALERT"
echo "INFO: purging INCIDENT older than 30 days"
adrci exec="set homepath $file_line;purge -age 43200 -type INCIDENT"
echo "INFO: purging TRACE older than 30 days"
adrci exec="set homepath $file_line;purge -age 43200 -type TRACE"
echo "INFO: purging CDUMP older than 30 days"
adrci exec="set homepath $file_line;purge -age 43200 -type CDUMP"
echo "INFO: purging HM older than 30 days"
adrci exec="set homepath $file_line;purge -age 43200 -type HM"
echo ""
echo ""
done
echo
echo "INFO: adrci purge finished at 'date'"

Extend space on SAN, shortly

Check:
. grid_env
asmcmd
lsdg            Usable_file_MB

[oracle@server]$ . grid.env
[oracle@server]$ acfsutil size 7730G /DB/data              Important: free scape should be on the connected SAN LUN

Newsletter

Enter your email to join our mailing list

Quick Contact