How to Clean-Up the ‘.patch_storage‘ Directory

文章介绍了如何使用OPatch工具的内置清理功能以及手动方法来清除不再使用的Oracle数据库补丁,从而释放硬盘空间。首先运行OPatch的cleanup命令进行自动清理,然后通过检查opatchlsinventory的输出来确定已应用的补丁,最后手动删除未在当前数据库中应用的补丁目录。
摘要由CSDN通过智能技术生成

When we patch the database using the OPatch utility, patches are stored in the "$ORACLE_HOME/.patch_storage" directory. Over time old patches can represent a large amount of wasted space. This article demonstrates how to clean up wasted storage associated with old database patches.

Run OPatch Clean-Up

The OPatch utility has its own cleanup routine.

[oracle@oracle-db-19c OPatch]$ pwd
/u01/app/oracle/product/19.3.0/dbhome_1/OPatch
[oracle@oracle-db-19c OPatch]$ $ORACLE_HOME/OPatch/opatch util cleanup
Oracle Interim Patch Installer version 12.2.0.1.17
Copyright (c) 2023, Oracle Corporation.  All rights reserved.


Oracle Home       : /u01/app/oracle/product/19.3.0/dbhome_1
Central Inventory : /u01/app/oraInventory
   from           : /u01/app/oracle/product/19.3.0/dbhome_1/oraInst.loc
OPatch version    : 12.2.0.1.17
OUI version       : 12.2.0.7.0
Log file location : /u01/app/oracle/product/19.3.0/dbhome_1/cfgtoollogs/opatch/opatch2023-02-15_13-42-52PM_1.log

Invoking utility "cleanup"
OPatch will clean up 'restore.sh,make.txt' files and '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

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

OPatch succeeded.
[oracle@oracle-db-19c OPatch]$ 

This will clean up some space, but from experience it rarely picks up all the patches that can be removed.

Manual Clean-Up

If you need to clean up more space, then consider doing the following.

We need to make sure we don't delete any patches that are currently applied to the database. We can do this by checking the output of the opatch lsinventory command as follows.

[oracle@oracle-db-19c OPatch]$ $ORACLE_HOME/OPatch/opatch lsinventory | grep -E "(^Patch.*applied)|(^Sub-patch)"
Patch  29585399     : applied on Fri Apr 19 05:21:33 HKT 2019
Patch  29517242     : applied on Fri Apr 19 05:21:17 HKT 2019
[oracle@oracle-db-19c OPatch]$ 

We can see we have three patches applied. Now let's check the contents of the ".patch_storage" directory. We can see we have 14 patches stored there.

[oracle@oracle-db-19c OPatch]$ 
[oracle@oracle-db-19c OPatch]$ cd $ORACLE_HOME/.patch_storage
[oracle@oracle-db-19c .patch_storage]$ ls -al
total 24
drwxr-xr-x.  5 oracle oinstall  188 Feb 15 13:49 .
drwxrwxr-x. 71 oracle oinstall 4096 Nov  2 15:39 ..
drwxr-xr-x.  3 oracle oinstall   74 Apr 18  2019 29517242_Apr_17_2019_23_27_10
drwxr-xr-x.  3 oracle oinstall   74 Apr 18  2019 29585399_Apr_9_2019_19_12_47
-rw-r--r--.  1 oracle oinstall 6307 Apr 18  2019 interim_inventory.txt
-rw-r--r--.  1 oracle oinstall   92 Apr 18  2019 LatestOPatchSession.properties
drwxr-xr-x.  6 oracle oinstall  122 Apr 18  2019 NApply
-rw-r--r--.  1 oracle oinstall 4975 Apr 18  2019 record_inventory.txt
[oracle@oracle-db-19c .patch_storage]$ 

It is safe to remove any patch directories that are not part of the initial list from OPatch. In this case that would be the following directories.

/u01/app/oracle/product/19.3.0/dbhome_1/.patch_storage
[oracle@oracle-db-19c .patch_storage]$ rm -Rf 29517242_Apr_17_2019_23_27_10
[oracle@oracle-db-19c .patch_storage]$ rm -Rf 29585399_Apr_9_2019_19_12_47
[oracle@oracle-db-19c .patch_storage]$ 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值