Oracle Patch清理

2024-05-09 08:04
文章标签 oracle 清理 patch

本文主要是介绍Oracle Patch清理,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

场景:
在对Oracle安装补丁后,会发现OS上被占用了大量的空间,本文档清理Opatch过程中的一些文件,释放空间

参考文档:
Can You Delete $ORACLE_HOME/.patch_storage Directory ? (Doc ID 403218.1)
How To Avoid Disk Full Issues Because OPatch Backups Take Big Amount Of Disk Space. (Doc ID 550522.1)

-- 查看$ORACLE_HOME下的隐藏文件夹.patch_storage。 可以看到之前的补丁过程,产生的一些文件。这些文件主要用于rollback补丁,如果不需要,可以清除,以释放空间。

[oracle@19ctest .patch_storage]$ du -sm *
1       29517242_Apr_17_2019_23_27_10
1       29585399_Apr_9_2019_19_12_47
2314    35042068_Apr_6_2023_15_25_04
1941    35320081_Jul_15_2023_12_54_11
2071    35643107_Oct_3_2023_13_34_29
1939    35943157_Jan_13_2024_05_42_55
2138    36233263_Apr_8_2024_17_16_56
1       interim_inventory.txt
1       LatestOPatchSession.properties
1       NApply
1       newdirs.txt
1       record_inventory.txt
[oracle@19ctest .patch_storage]$ pwd
/u01/app/oracle/product/19.0.0/db_1/.patch_storage
[oracle@19ctest .patch_storage]$ 

-- /u01目录剩余17G 

[oracle@19ctest .patch_storage]$ df -h
Filesystem                   Size  Used Avail Use% Mounted on
devtmpfs                     4.3G     0  4.3G   0% /dev
tmpfs                        4.4G     0  4.4G   0% /dev/shm
tmpfs                        4.4G  8.8M  4.4G   1% /run
tmpfs                        4.4G     0  4.4G   0% /sys/fs/cgroup
/dev/mapper/ol_19cdg01-root   17G  4.1G   13G  24% /
/dev/sdc1                    120G   74G   47G  62% /oradata
/dev/sdd1                    120G   60G   61G  50% /arch
/dev/sda1                   1014M  169M  846M  17% /boot
/dev/sde1                    100G   24G   76G  24% /mysql
/dev/sdf1                    120G   47G   74G  39% /oradatapdb
/dev/sdb1                     40G   24G   17G  59% /u01
tmpfs                        883M     0  883M   0% /run/user/0
[oracle@19ctest .patch_storage]$ 

-- opatch clean的帮助,该命令清除.patch_storage directory文件夹下的'restore.sh,make.txt' files and 'scratch,backup' 

[oracle@19ctest ~]$ opatch util cleanup -help
Oracle Interim Patch Installer version 12.2.0.1.41
Copyright (c) 2024, Oracle Corporation.  All rights reserved.DESCRIPTIONThis utility cleans up 'restore.sh,make.txt' files and '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 torollback 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 willbe located under ORACLE_HOME/.patch_storage/]OPTIONS   -invPtrLocUsed to locate the oraInst.loc file. Needed when theinstallation used the -invPtrLoc flag. This should bethe path to the oraInst.loc file.-jreThis option tells OPatch to use JRE (java) from thespecified location instead of the default locationunder Oracle Home. Both -jdk and -jre options cannotbe specified together. OPatch will display error inthat case.-ohThe oracle home to work on. This takes precedence overthe environment variable ORACLE_HOME.-psThis 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 underORACLE_HOME/.patch_storage. If this directory is specifiedand is valid, then the contents specified in the descriptionwill be cleaned up only for this patch. Otherwise, all patchrelated 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.
[oracle@19ctest ~]$ 

-- 从清理过程看,会清理'restore.sh,make.txt' files and 'scratch,backup' directories.但仍然可以对补丁进行rollback 

[oracle@19ctest ~]$ opatch util cleanup
Oracle Interim Patch Installer version 12.2.0.1.41
Copyright (c) 2024, Oracle Corporation.  All rights reserved.Oracle Home       : /u01/app/oracle/product/19.0.0/db_1
Central Inventory : /u01/app/oraInventoryfrom           : /u01/app/oracle/product/19.0.0/db_1/oraInst.loc
OPatch version    : 12.2.0.1.41
OUI version       : 12.2.0.7.0
Log file location : /u01/app/oracle/product/19.0.0/db_1/cfgtoollogs/opatch/opatch2024-05-08_13-30-06PM_1.logInvoking 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: YBackup area for restore has been cleaned up. For a complete list of files/directories
deleted, Please refer log file.OPatch succeeded.
[oracle@19ctest ~]$ 

一些log 

[May 8, 2024 1:30:11 PM] [INFO]     [OPSR-MEMORY] Loaded all one offs from inventory. Heap memory in use: 29 (MB)
[May 8, 2024 1:30:11 PM] [INFO]     [OPSR-TIME] Raw inventory loaded successfully
[May 8, 2024 1:30:11 PM] [INFO]     Invoking utility "cleanup"
[May 8, 2024 1:30:11 PM] [INFO]     [OPSR-TIME] Cleaning up backup
[May 8, 2024 1:30:11 PM] [INFO]     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]

-- 执行完毕后,貌似没有变化,可能和自己环境有关(19年开始测试补丁,基本上每个季度都测试,后面把又把数据库用RMAN做了迁移,又转换成了PDB模式)。

[oracle@19ctest ~]$ df -h
Filesystem                   Size  Used Avail Use% Mounted on
devtmpfs                     4.3G     0  4.3G   0% /dev
tmpfs                        4.4G     0  4.4G   0% /dev/shm
tmpfs                        4.4G  8.8M  4.4G   1% /run
tmpfs                        4.4G     0  4.4G   0% /sys/fs/cgroup
/dev/mapper/ol_19cdg01-root   17G  4.1G   13G  24% /
/dev/sdc1                    120G   74G   47G  62% /oradata
/dev/sdd1                    120G   60G   61G  50% /arch
/dev/sda1                   1014M  169M  846M  17% /boot
/dev/sde1                    100G   24G   76G  24% /mysql
/dev/sdf1                    120G   47G   74G  39% /oradatapdb
/dev/sdb1                     40G   24G   17G  59% /u01
tmpfs                        883M     0  883M   0% /run/user/0
[oracle@19ctest ~]$ 

-- 也可能和log中的以下有关 

[oracle@19ctest db_1]$ tail -f /u01/app/oracle/product/19.0.0/db_1/cfgtoollogs/opatch/opatch2024-05-08_13-30-06PM_1.log
[May 8, 2024 1:30:59 PM] [INFO]     Cannot delete as either pathToBeDeleted is empty or it does not contain .patch_storage :
[May 8, 2024 1:30:59 PM] [INFO]     Cannot delete as either pathToBeDeleted is empty or it does not contain .patch_storage :
[May 8, 2024 1:30:59 PM] [INFO]     Cannot delete as either pathToBeDeleted is empty or it does not contain .patch_storage :
[May 8, 2024 1:30:59 PM] [INFO]     Cannot delete as either pathToBeDeleted is empty or it does not contain .patch_storage :
[May 8, 2024 1:30:59 PM] [INFO]     Cannot delete as either pathToBeDeleted is empty or it does not contain .patch_storage :
[May 8, 2024 1:30:59 PM] [INFO]     Cannot delete as either pathToBeDeleted is empty or it does not contain .patch_storage :
[May 8, 2024 1:30:59 PM] [INFO]     Cannot delete as either pathToBeDeleted is empty or it does not contain .patch_storage :
[May 8, 2024 1:30:59 PM] [INFO]     Cannot delete as either pathToBeDeleted is empty or it does not contain .patch_storage :
[May 8, 2024 1:30:59 PM] [INFO]     [OPSR-TIME] Loading cooked inventory

-- 查看到的补丁

SYS@cdbtest SQL> select comments from dba_registry_history;COMMENTS
--------------------------------------------------------------------------------
RDBMS_19.23.0.0.0DBRU_LINUX.X64_240405
Patch applied from 19.3.0.0.0 to 19.21.0.0.0: Release_Update - 230930151951
Patch applied from 19.21.0.0.0 to 19.22.0.0.0: Release_Update - 240104023954
Patch applied from 19.22.0.0.0 to 19.23.0.0.0: Release_Update - 240406004238SYS@cdbtest SQL> alter session set container =test;Session altered.SYS@cdbtest SQL> select comments from dba_registry_history;COMMENTS
--------------------------------------------------------------------------------
RDBMS_19.23.0.0.0DBRU_LINUX.X64_240405
Patch applied on 19.3.0.0.0: Release_Update - 190410122720
Patch applied from 19.3.0.0.0 to 19.5.0.0.0: Release_Update - 190909180549
Patch applied from 19.5.0.0.0 to 19.11.2.0.0: Release_Update_Revision - 21100717
1159RAN jvmpsu.sql
OJVM RU post-install
Patch rolled back from 19.11.2.0.0 to 19.11.0.0.0: Release_Update - 210413004009
Patch applied from 19.11.0.0.0 to 19.14.0.0.0: Release_Update - 211225122123
Patch applied from 19.14.0.0.0 to 19.15.0.0.0: Release_Update - 220331125408COMMENTS
--------------------------------------------------------------------------------
Patch applied from 19.15.0.0.0 to 19.17.0.0.0: Release_Update - 220924224051
Patch applied from 19.17.0.0.0 to 19.18.0.0.0: Release_Update - 230111171738
Patch applied on 19.18.0.0.0: Release_Update - 230111171738
Patch applied on 19.18.0.0.0: Release_Update - 230111171738
Patch applied from 19.18.0.0.0 to 19.19.0.0.0: Release_Update - 230322020406
Patch applied from 19.19.0.0.0 to 19.20.0.0.0: Release_Update - 230715022800
Patch applied from 19.20.0.0.0 to 19.21.0.0.0: Release_Update - 230930151951
Patch applied on 19.21.0.0.0: Release_Update - 230930151951
Patch applied on 19.21.0.0.0: Release_Update - 230930151951
Patch applied on 19.21.0.0.0: Release_Update - 230930151951
Patch applied on 19.21.0.0.0: Release_Update - 230930151951COMMENTS
--------------------------------------------------------------------------------
Patch applied on 19.21.0.0.0: Release_Update - 230930151951
Patch applied on 19.21.0.0.0: Release_Update - 230930151951
Patch applied on 19.21.0.0.0: Release_Update - 230930151951
OJVM RU post-deinstall
Patch applied on 19.21.0.0.0: Release_Update - 230930151951
Patch applied from 19.21.0.0.0 to 19.22.0.0.0: Release_Update - 240104023954
Patch applied from 19.22.0.0.0 to 19.23.0.0.0: Release_Update - 24040600423827 rows selected.SYS@cdbtest SQL> 

-- 也可以手工清除,官网上对于手工清除,是这样说明的 

Additionally, further cleanup of the $ORACLE_HOME/.patch_storage is possible if there are directories from patches applied to previous versions. This can be done manually as follows:

1.  run command:

$ opatch lsinventory

2.  Remove all the sub-directories from $ORACLE_HOME/.patch_storage that are not present in the list of installed patches. Directory names would be prefaced with the patchid for example:

13343438_<timestamp>

example to find sub-directories : $ opatch lsinventory | grep -E "(^Patch.*applied)|(^Sub-patch)"

Note: List of patches include the sub patches of install Bundle patches, PSU, GI PSU.  Hence you should NOT remove the sub patch folders.

[oracle@19ctest ~]$ opatch lsinventory | grep -E "(^Patch.*applied)|(^Sub-patch)"
Patch  36233263     : applied on Fri Apr 19 08:54:31 CST 2024
Patch  29585399     : applied on Thu Apr 18 15:21:33 CST 2019
[oracle@19ctest ~]$ 

-- 手工清理掉

rm -rf  29517242_Apr_17_2019_23_27_10
rm -rf  35042068_Apr_6_2023_15_25_04
rm -rf  35320081_Jul_15_2023_12_54_11
rm -rf  35643107_Oct_3_2023_13_34_29
rm -rf  35943157_Jan_13_2024_05_42_55

--清理后空间,剩余25G 

[oracle@19ctest .patch_storage]$ df -h
Filesystem                   Size  Used Avail Use% Mounted on
devtmpfs                     4.3G     0  4.3G   0% /dev
tmpfs                        4.4G     0  4.4G   0% /dev/shm
tmpfs                        4.4G  8.8M  4.4G   1% /run
tmpfs                        4.4G     0  4.4G   0% /sys/fs/cgroup
/dev/mapper/ol_19cdg01-root   17G  4.1G   13G  24% /
/dev/sdc1                    120G   74G   47G  62% /oradata
/dev/sdd1                    120G   60G   61G  50% /arch
/dev/sda1                   1014M  169M  846M  17% /boot
/dev/sde1                    100G   24G   76G  24% /mysql
/dev/sdf1                    120G   47G   74G  39% /oradatapdb
/dev/sdb1                     40G   16G   25G  39% /u01
tmpfs                        883M     0  883M   0% /run/user/0
[oracle@19ctest .patch_storage]$ 

END

这篇关于Oracle Patch清理的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/972839

相关文章

oracle DBMS_SQL.PARSE的使用方法和示例

《oracleDBMS_SQL.PARSE的使用方法和示例》DBMS_SQL是Oracle数据库中的一个强大包,用于动态构建和执行SQL语句,DBMS_SQL.PARSE过程解析SQL语句或PL/S... 目录语法示例注意事项DBMS_SQL 是 oracle 数据库中的一个强大包,它允许动态地构建和执行

PLsql Oracle 下载安装图文过程详解

《PLsqlOracle下载安装图文过程详解》PL/SQLDeveloper是一款用于开发Oracle数据库的集成开发环境,可以通过官网下载安装配置,并通过配置tnsnames.ora文件及环境变... 目录一、PL/SQL Developer 简介二、PL/SQL Developer 安装及配置详解1.下

oracle如何连接登陆SYS账号

《oracle如何连接登陆SYS账号》在Navicat12中连接Oracle11g的SYS用户时,如果设置了新密码但连接失败,可能是因为需要以SYSDBA或SYSOPER角色连接,解决方法是确保在连接... 目录oracle连接登陆NmOtMSYS账号工具问题解决SYS用户总结oracle连接登陆SYS账号

Oracle数据库如何切换登录用户(system和sys)

《Oracle数据库如何切换登录用户(system和sys)》文章介绍了如何使用SQL*Plus工具登录Oracle数据库的system用户,包括打开登录入口、输入用户名和口令、以及切换到sys用户的... 目录打开登录入口登录system用户总结打开登录入口win+R打开运行对话框,输php入:sqlp

查询Oracle数据库表是否被锁的实现方式

《查询Oracle数据库表是否被锁的实现方式》本文介绍了查询Oracle数据库表是否被锁的方法,包括查询锁表的会话、人员信息,根据object_id查询表名,以及根据会话ID查询和停止本地进程,同时,... 目录查询oracle数据库表是否被锁1、查询锁表的会话、人员等信息2、根据 object_id查询被

Oracle查询优化之高效实现仅查询前10条记录的方法与实践

《Oracle查询优化之高效实现仅查询前10条记录的方法与实践》:本文主要介绍Oracle查询优化之高效实现仅查询前10条记录的相关资料,包括使用ROWNUM、ROW_NUMBER()函数、FET... 目录1. 使用 ROWNUM 查询2. 使用 ROW_NUMBER() 函数3. 使用 FETCH FI

数据库oracle用户密码过期查询及解决方案

《数据库oracle用户密码过期查询及解决方案》:本文主要介绍如何处理ORACLE数据库用户密码过期和修改密码期限的问题,包括创建用户、赋予权限、修改密码、解锁用户和设置密码期限,文中通过代码介绍... 目录前言一、创建用户、赋予权限、修改密码、解锁用户和设置期限二、查询用户密码期限和过期后的修改1.查询用

Oracle数据库使用 listagg去重删除重复数据的方法汇总

《Oracle数据库使用listagg去重删除重复数据的方法汇总》文章介绍了在Oracle数据库中使用LISTAGG和XMLAGG函数进行字符串聚合并去重的方法,包括去重聚合、使用XML解析和CLO... 目录案例表第一种:使用wm_concat() + distinct去重聚合第二种:使用listagg,

oracle中exists和not exists用法举例详解

《oracle中exists和notexists用法举例详解》:本文主要介绍oracle中exists和notexists用法的相关资料,EXISTS用于检测子查询是否返回任何行,而NOTE... 目录基本概念:举例语法pub_name总结 exists (sql 返回结果集为真)not exists (s

Oracle的to_date()函数详解

《Oracle的to_date()函数详解》Oracle的to_date()函数用于日期格式转换,需要注意Oracle中不区分大小写的MM和mm格式代码,应使用mi代替分钟,此外,Oracle还支持毫... 目录oracle的to_date()函数一.在使用Oracle的to_date函数来做日期转换二.日