Why does the size of my ORACLE_HOME increase?
Posted by Harald van Breederode on February 21, 2010
Recently I discovered that the size of an ORACLE_HOME for a given release varies from machine to machine although the machines are of the same architecture and run the same operating system. A small difference in size can be explained by the fact that one ORACLE_HOME was re-linked in the past while the other wasn’t, but this time the difference was more than 1 GByte. Digging a bit further revealed a sub-directory called .patch_storage
which, as the name implies, is used to store patch related data.
I found NOTE:550522.1 on MyOracleSupport which describes what this directory is used for and why it suddenly so big. It turns out that recent versions of OPatch, installed by installing patch 6880880, not only store object files (several kilo byes in size) that are patched in $ORACLE_HOME/.patch_storage
but also the library (several tens of mega bytes in size) in which the affected object file belongs. This is to make rolling back installed patches as quick as possible. Thus in effect this is a space-for-time issue. Because OPatch doesn’t clean the .patch_storage
directory up whenever files are no longer needed because a more recent patch gets installed the size of an ORACLE_HOME increases without notice.
The good news is that recent versions of OPatch have an option to clean up the .patch_storage
directory manually if one doesn’t like this space-for-time optimization.
Let’s have a look at the current disk usage before cleaning up my .patch_storage
directory.
$ cd $ORACLE_HOME $ du -hs .patch_storage 1.2G .patch_storage
The above shows that I currently have 1.2 GByte in the .patch_storage
directory. This is an Oracle 11g Release 1 (11.1.0.7.0) ORACLE_HOME with the latest PSU and a few interim patches applied.
The opatch util cleanup
command is used to clean up the .patch_storage
but before doing so let’s have a look at the OPatch help output for this command.
$ opatch util cleanup -help Invoking OPatch 11.2.0.1.1 Oracle Interim Patch Installer version 11.2.0.1.1 Copyright (c) 2009, Oracle Corporation. All rights reserved. UTIL session DESCRIPTION This utility cleans up 'restore.sh,make.txt' files and 'rac,scratch,backup' directories of the.patch_storage directory of Oracle Home.If -ps option is used, then, it cleans the above specified areas only for that patch, else for all patches under ORACLE_HOME/.patch_storage. You will be still able to rollback patches after this cleanup. SYNTAX opatch util cleanup [-invPtrLoc <Path to oraInst.loc> ] [-jre <LOC> ] [-oh <ORACLE_HOME> ] [-silent] [-report] [-ps <patch ID with time stamp>, this will be located under ORACLE_HOME/.patch_storage/] OPTIONS -invPtrLoc Used to locate the oraInst.loc file. Needed when the installation used the -invPtrLoc flag. This should be the path to the oraInst.loc file. -jre This option tells OPatch to use JRE (java) from the specified location instead of the default location under Oracle Home. Both -jdk and -jre options cannot be specified together. OPatch will display error in that case. -oh The oracle home to work on. This takes precedence over the environment variable ORACLE_HOME. -ps This option is used to specify the Patch ID with timestamp. This Patch ID with timestamp should be the same as in .patch_storage directory. A directory by this name will be present under ORACLE_HOME/.patch_storage. If this directory is specified and is valid, then the contents specified in the description will be cleaned up only for this patch. Otherwise, all patch related directories will be acted upon by this utility. -silent In silent mode, the cleanup always takes place. -report Prints the operations without actually executing them. OPatch succeeded.
With this knowledge we can proceed with the actual clean up as shown below:
$ opatch util cleanup Invoking OPatch 11.2.0.1.1 Oracle Interim Patch Installer version 11.2.0.1.1 Copyright (c) 2009, Oracle Corporation. All rights reserved. UTIL session Oracle Home : /u01/app/oracle/product/11.1.0 Central Inventory : /u01/app/oraInventory from : /etc/oraInst.loc OPatch version : 11.2.0.1.1 OUI version : 11.1.0.7.0 OUI location : /u01/app/oracle/product/11.1.0/oui Log file location : /u01/app/oracle/product/11.1.0/cfgtoollogs/opatch/opatch2010-02-20_15-27-15PM.log Patch history file: /u01/app/oracle/product/11.1.0/cfgtoollogs/opatch/opatch_history.txt Invoking utility "cleanup" OPatch will clean up 'restore.sh,make.txt' files and 'rac,scratch,backup' directories. You will be still able to rollback patches after this cleanup. Do you want to proceed? [y|n] y User Responded with: Y Size of directory "/u01/app/oracle/product/11.1.0/.patch_storage" before cleanup is 1256452888 bytes. Size of directory "/u01/app/oracle/product/11.1.0/.patch_storage" after cleanup is 142265128 bytes. UtilSession: Backup area for restore has been cleaned up. For a complete list of files/directories deleted, Please refer log file. OPatch succeeded.
OPatch started by displaying the amount of disk usage in the .patch_storage
directory before asking for permission to perform the actual clean up. Once the clean up is finished OPatch reports the new amount of disk usage. We can easily verify that OPatch indeed freed up a fair amount of disk space by running the du –hs
command.
$ du -hs .patch_storage 144M .patch_storage
In short: Running opatch util cleanup
after installing patches prevents your ORACLE_HOME from eating up too much disk space without losing the ability from rolling back those patches.
-Harald
Simone Pedroso said
Hi Harald, great tip to add to the patch procedure. Thanks! Simone.
Log Buffer #180: a Carnival of the Vanities for DBAs | The Pythian Blog said
[…] Meanwhile, Harald van Breederode does the same for this one: Why does the size of my ORACLE_HOME increase? […]
joel garry said
Looking at the top n largest files in my $ORACLE_HOME and I see, among some expected things… (drum roll please)… core, emdb and http-web-access.log files taking up gigs.
Blogroll Report 19/02/2010 – 26/02/2010 « Coskan’s Approach to Oracle said
[…] 1-How to use opatch util cleanup option to remove unnecessary old patch files from disk? Harold Van Breederode-Why does the size of my ORACLE_HOME increase? […]
iphone said
Thank you for the tips, i just reduce all my 11.2 Oracle Homes by 2 Go !!
vibhu said
good post