du vs df giving wrong disk usage results
In OS, oracle is reported as using 168 Gb
While in oracle, the usage is only 78 Gb
How can that be?
Space usage in Linux:
find . -type f -printf '%s %p\n'| sort -nr | head -40
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/oravg2-ora_db 196G 168G 19G 91% /oracle_db/db3
At this point , many files were dropped using the Oracle syntax
Example:
Drop some big tablespaces, each one is several Gb in size.
DROP TABLESPACE OLD_TRANSACTION_202401 INCLUDING CONTENTS AND DATAFILES;
DROP TABLESPACE OLD_TRANSACTION_202402 INCLUDING CONTENTS AND DATAFILES;
SELECT tablespace_name FROM dba_tablespaces WHERE tablespace_name = 'OLD_TRANSACTION_202401';
No Data Found
No Data Found
See now space usage in Linux:
df -hP | grep db3
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/oravg2-ora_db 196G 168G 19G 91% /oracle_db/db3
No change in space usage, how can that be?
Check space usage with du
>cd /oracle_db
>du -sh *
78G db3
du report usage of 78Gb, which is in sync with oracle stats, but df report a wrong result.
A common cause is that the file was deleted by a process, but is still in a deleted status, and was not deleted by the OS.
indeed this was the case here:
indeed this was the case here:
>lsof | grep deleted
/oracle_db/db3/db_igt/OLD_TRANSACTION_202401_1.dbf (deleted)
oracle 37484 oracle 424u REG 253,17 4404027392 2621478 /oracle_db/db3/db_igt/OLD_TRANSACTION_202402_1.dbf (deleted)
oracle 37484 oracle 428u REG 253,17 3670024192 2621524
Theory:
When Linux mount point usage as reported by df does not align with the sum of file sizes reported by du, several common scenarios can explain the discrepancy
1. Open but Deleted Files
1. Open but Deleted Files
A file may be deleted using rm, but if a process still holds an open file descriptor to it, the disk space occupied by that file is not immediately released.
It remains allocated until the process either closes the file or terminates.
This is a very common reason for df showing higher usage than du.
For Oracle, a simple solution is to bounce the instance.
There are other options, not related to Oracle scenario
After oracle restart
>df -hP | grep ora
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/oravg2-ora_db 196G 78G 109G 42% /oracle_db/db3
Issue fixed!
No comments:
Post a Comment