Can We Delete $ORCLE_HOME/.patch_storage

问:$ORCLE_HOME/.patch_storage占据了7-8G的空间,能否删除?

答:该目录不能直接删除,但是可以通过opatch命令做一定的清理。

该目录的作用可以参看Metalink Note: 403218.1

该目录中保存着每次Patch涉及到的文件的备份还有local inventory的备份,如果我们要做patch rollback就需要存储在这个目录中的信息,下面几种情况都必须要做Patch Rollback。
1. 某些之前的Patch跟现在需要的Patch冲突,则必须先Rollback之前的Patch。
2. 最新的CPU (Critical Patch Update) Patch总是包含前一版本的Patch内容,因此每次打CPU Patch都会自动做一次前一版本Patch的Rollback。

如何通过opatch命令清理该目录可以参看Metalink Note: 550522.1

在新版的OPatch中,新增了util命令,通过该命令可以清理.patch_storage目录。

具体的命令为:opatch util cleanup

帮助信息:opatch util cleanup -help

$ opatch util cleanup -help
Invoking OPatch 10.2.0.3.4

Oracle Interim Patch Installer version 10.2.0.3.4
Copyright (c) 2007, 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  ]
[-jre  ] [-oh  ]
[-silent] [-force] [-report]
[-ps , this will
be located under ORACLE_HOME/.patch_storage/]

示例:

$ opatch util cleanup
Invoking OPatch 10.2.0.3.4

Oracle Interim Patch Installer version 10.2.0.3.4
Copyright (c) 2007, Oracle Corporation. All rights reserved.

UTIL session

Oracle Home : /home/oracle/10.2.0.3
Central Inventory : /home/oracle/oraInventory
from : /etc/oraInst.loc
OPatch version : 10.2.0.3.4
OUI version : 10.2.0.3.0
OUI location : /home/oracle/10.2.0.3/oui
Log file location : /home/oracle/10.2.0.3/cfgtoollogs/opatch/opatch2008-02-12_10-33-40AM.log

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 "/home/oracle/10.2.0.3/.patch_storage" before cleanup is 438057972 bytes.
Size of directory "/home/oracle/10.2.0.3/.patch_storage" after cleanup is 198415929 bytes.

UtilSession: Backup area for restore has been cleaned up. For a complete list of files/directories
deleted, Please refer log file.

OPatch succeeded. 
$ 

如果在执行了上述命令之后,还觉得.patch_storage占用了过大的空间,那么可以更进一步的做手工清理。
执行’opatch lsinventory’命令,查看输出,然后手动删除.patch_storage目录中所有不在输出列表中的子目录。

Leave a Reply

Your email address will not be published. Required fields are marked *