m6米乐安卓版下载-米乐app官网下载

[译] 我可以用 opatch 清理以前的补丁包吗? -m6米乐安卓版下载

刺史武都 2022-06-08
373

原文地址:我可以用 opatch 清理以前的补丁包吗
原文作者:mike.dietrich

你是否喜欢秘密?现在让我从一个对大多数人来说不是秘密的秘密开始,让它变得更加晦涩难懂。

当您使用 opatch 或 opatchauto 安装补丁时,很多文件将存储在隐藏目录中:

$oracle_home/.patch_storage
$oracle_home/.opatchauto_storage

为什么隐藏这些目录?我真的不知道。也许是为了表示“不要碰任何东西!不得擅闯!远离!私人财产”。但是像往常一样,当你试图隐藏某些东西时,你只会让它变得更有趣。

无论如何,当您仔细观察时,尤其是当您在我的环境中拥有某种补丁历史记录时,您可能会很快意识到:使用了很多空间。

就我而言,这些目录在我的环境中总共消耗了超过 10gb 的空间:

[cdb2] oracle@hol:/u01/app/oracle/product/19/.patch_storage
$ ls
32218454_jan_14_2021_16_24_38               
32545013_apr_16_2021_07_40_05     
32904851_jul_20_2021_09_21_24    
33192694_sep_14_2021_16_48_27     
33192793_oct_15_2021_07_09_52
33197296_oct_4_2021_00_44_36
33515361_jan_13_2022_06_14_07
33561310_jan_5_2022_08_13_10
interim_inventory.txt
latestopatchsession.properties
napply
newdirs.txt
record_inventory.txt
10017056

不要清除它

补丁所有者给出的第一条规则:不要清除此目录。稍后可能需要回滚补丁。

我仍然从一些人那里知道,他们不时删除整个目录以释放空间。到目前为止,我还没有听说这会破坏未来的补丁。如果我在我的环境中这样做,我会确保始终保留最后两个子目录——以防万一。但是我没有很多一次性或合并补丁。

  • 规则 1
    不要清除.patch_storage和 . opatchauto_storage。

opatch 工具清理
让我把这一章写得很短。

  • 规则 2
    opatch util cleanup不会做你期望它做的事情。有时它做的比你想象的要多一点。

解决办法是什么?

很长一段时间以来,许多客户都在寻求m6米乐安卓版下载的解决方案。只需简单浏览一下错误数据库,就会发现相当数量的错误和增强请求针对或要求 opatch 进行适当的清理。

下面的内容看起来很有趣:

enh 31138227 – $oh/.patch_storage 保留 n-1 版本仅用于更好的空间消耗
我本来希望有这样的m6米乐安卓版下载的解决方案,因为我通常在我的 linux 系统上这样做:

# package-cleanup --oldkernels --count=1

它删除了我不再需要或不再使用的旧内核。

从上面的增强请求中,我了解到从版本 26 开始有一个新的 opatch 选项可用:

./opatch util archive -patches 123456,1122334 -archive_dir /dirx

这里的第一个问题是 opatch 中通常的-help选项没有告诉你它。由于增强请求是非公开的,因此您无法查看详细信息。但秘密关键字是:opatch util archive -help

注解

实际上,我从功能所有者那里了解到,帮助没有向您显示帮助更高级别的命令选项的原因很简单——该功能还没有“上线”。由于我是通过我提交的一个错误了解它的,所以我尝试了它并且不知道它尚未公开。不过,它工作正常。

$ ./opatch util archive -help
oracle interim patch installer version 12.2.0.1.28
米乐app官网下载 copyright (c) 2022, oracle corporation.  all rights reserved.   description
    this operation helps to archive the patches stored under 
    oracle_home/.patch_storage to custom storage location.
    note: patch directories in .patch_storage will be used during
    rollback operation.
syntax
opatch util archive [-patches  ]
			[-archive_dir ]
                
options
       -patches
              a comma separated list of patches to be given for 
              archive.
       -archive_dir
              specify custom storage path to store the patches 
              which are going to be archived.
              
		note: all options are mandatory.  
recommendation :
  to archive patches, opatch recommends the following 
    1. archiving inactive patches : 
        run the following command to get inactive patches :  "opatch/opatch lsinv -inactive" 
		
example
	opatch util archive -patches 123456,1122334 -archive_dir /dir1/dir2/		            
opatch succeeded.

所以这是新命令:opatch util archive -patches … -archive_dir …

不要对命令语法中的括号感到困惑。所有选项都是强制性的,而不是可选的。

这是解决千兆字节旧补丁内容浪费硬盘空间问题的承诺。让我们看看这是否也解决了您的问题。

哪些补丁目录是候选的?

当您搜索非活动房屋时,此 opatch 命令最有帮助,但输出很长:

$ ./opatch lsinv -inactive

它会告诉您不活动的补丁号。这些是您要传递给下面的存档命令的那些。

opatch 实用程序存档

正如您之前所读到的,即使我之前自己非法清理过,我的机器上仍然消耗了超过 10gb 的空间。

尽管如此,归档命令仍会进行空间检查(请参阅下面的what if …)

$ ./opatch util archive -patches 32218454,32545013,32904851,33192694,33192793,33197296,33515361,33561310 -archive_dir /media/sf_temp/
oracle interim patch installer version 12.2.0.1.28
米乐app官网下载 copyright (c) 2022, oracle corporation.  all rights reserved.
oracle home       : /u01/app/oracle/product/19
central inventory : /u01/app/orainventory
   from           : /u01/app/oracle/product/19/orainst.loc
opatch version    : 12.2.0.1.28
oui version       : 12.2.0.7.0
log file location : /u01/app/oracle/product/19/cfgtoollogs/opatch/opatch2022-01-20_14-08-15pm_1.log
invoking utility "archive"
archiving patch - 33515361 ....
sucessfully archived patch - 33515361 in /media/sf_temp/33515361_jan_13_2022_06_14_07.zip
archiving patch - 32545013 ....
sucessfully archived patch - 32545013 in /media/sf_temp/32545013_apr_16_2021_07_40_05.zip
archiving patch - 32904851 ....
sucessfully archived patch - 32904851 in /media/sf_temp/32904851_jul_20_2021_09_21_24.zip
archiving patch - 33197296 ....
sucessfully archived patch - 33197296 in /media/sf_temp/33197296_oct_4_2021_00_44_36.zip
archiving patch - 33192793 ....
sucessfully archived patch - 33192793 in /media/sf_temp/33192793_oct_15_2021_07_09_52.zip
archiving patch - 33192694 ....
sucessfully archived patch - 33192694 in /media/sf_temp/33192694_sep_14_2021_16_48_27.zip
archiving patch - 33561310 ....
sucessfully archived patch - 33561310 in /media/sf_temp/33561310_jan_5_2022_08_13_10.zip
archiving patch - 32218454 ....
sucessfully archived patch - 32218454 in /media/sf_temp/32218454_jan_14_2021_16_24_38.zip
succesfully verified the created archive. deleting the original patch from  - /u01/app/oracle/product/19/.patch_storage/33515361_jan_13_2022_06_14_07
succesfully verified the created archive. deleting the original patch from  - /u01/app/oracle/product/19/.patch_storage/32545013_apr_16_2021_07_40_05
succesfully verified the created archive. deleting the original patch from  - /u01/app/oracle/product/19/.patch_storage/32904851_jul_20_2021_09_21_24
succesfully verified the created archive. deleting the original patch from  - /u01/app/oracle/product/19/.patch_storage/33197296_oct_4_2021_00_44_36
succesfully verified the created archive. deleting the original patch from  - /u01/app/oracle/product/19/.patch_storage/33192793_oct_15_2021_07_09_52
succesfully verified the created archive. deleting the original patch from  - /u01/app/oracle/product/19/.patch_storage/33192694_sep_14_2021_16_48_27
succesfully verified the created archive. deleting the original patch from  - /u01/app/oracle/product/19/.patch_storage/33561310_jan_5_2022_08_13_10
succesfully verified the created archive. deleting the original patch from  - /u01/app/oracle/product/19/.patch_storage/32218454_jan_14_2021_16_24_38
patch archive operation completed successfully.
opatch succeeded.

如果 …

当然,使用 opatch 总是有很多有趣的 opatch 错误消息。

我的第一次尝试失败了:

$ ./opatch util archive -patches 32218454,32545013,32904851,33192694,33192793,33197296,33515361,33561310 -archive_dir /home/oracle/patch_storage
oracle interim patch installer version 12.2.0.1.28
米乐app官网下载 copyright (c) 2022, oracle corporation.  all rights reserved.
oracle home       : /u01/app/oracle/product/19
central inventory : /u01/app/orainventory
   from           : /u01/app/oracle/product/19/orainst.loc
opatch version    : 12.2.0.1.28
oui version       : 12.2.0.7.0
log file location : /u01/app/oracle/product/19/cfgtoollogs/opatch/opatch2022-01-20_11-48-35am_1.log
invoking utility "archive"
patch archive operation failed.
utilsession failed to archive the patches 
utilsession failed: patch archive operation failed.
opatch failed with error code 73

为什么失败了?我需要检查日志文件以找出:

[jan 20, 2022 11:48:37 am] [info]   archive directory: /home/oracle/patch_storage has required permission to archive the patches
[jan 20, 2022 11:48:37 am] [info]   space for patch :: /u01/app/oracle/product/19/.patch_storage/32218454_jan_14_2021_16_24_38 :: 1715352980
[jan 20, 2022 11:48:37 am] [info]   space for patch :: /u01/app/oracle/product/19/.patch_storage/32545013_apr_16_2021_07_40_05 :: 1974092970
[jan 20, 2022 11:48:37 am] [info]   space for patch :: /u01/app/oracle/product/19/.patch_storage/32904851_jul_20_2021_09_21_24 :: 1927088358
[jan 20, 2022 11:48:38 am] [info]   space for patch :: /u01/app/oracle/product/19/.patch_storage/33192793_oct_15_2021_07_09_52 :: 1818503734
[jan 20, 2022 11:48:38 am] [info]   space for patch :: /u01/app/oracle/product/19/.patch_storage/33192694_sep_14_2021_16_48_27 :: 444972030
[jan 20, 2022 11:48:38 am] [info]   space for patch :: /u01/app/oracle/product/19/.patch_storage/33197296_oct_4_2021_00_44_36 :: 126355388
[jan 20, 2022 11:48:38 am] [info]   space for patch :: /u01/app/oracle/product/19/.patch_storage/33515361_jan_13_2022_06_14_07 :: 1750455909
[jan 20, 2022 11:48:38 am] [info]   space for patch :: /u01/app/oracle/product/19/.patch_storage/33561310_jan_5_2022_08_13_10 :: 452566990
[jan 20, 2022 11:48:38 am] [info]   archive directory: /home/oracle/patch_storage needs 10209388359 bytes.
[jan 20, 2022 11:48:38 am] [severe] no space to archive given patches in /home/oracle/patch_storage
[jan 20, 2022 11:48:38 am] [info]   patch archive operation failed.
[jan 20, 2022 11:48:38 am] [severe] patch archive operation failed.
[jan 20, 2022 11:48:38 am] [info]   utilsession failed to archive the patches
[jan 20, 2022 11:48:38 am] [severe] utilsession failed to archive the patches
[jan 20, 2022 11:48:38 am] [severe] oui-67073:utilsession failed: patch archive operation failed.
[jan 20, 2022 11:48:38 am] [info]   finishing utilsession at thu jan 20 11:48:38 cet 2022
[jan 20, 2022 11:48:38 am] [info]   stack description: java.lang.runtimeexception: patch archive operation failed.
                                        at oracle.opatch.opatchutil.ousession.archive(ousession.java:3491)
                                        at sun.reflect.nativemethodaccessorimpl.invoke0(native method)
                                        at sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62)
                                        at sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43)
                                        at java.lang.reflect.method.invoke(method.java:498)
                                        at oracle.opatch.utilsession.process(utilsession.java:355)
                                        at oracle.opatch.opatchsession.process(opatchsession.java:2660)
                                        at oracle.opatch.opatch.process(opatch.java:870)
                                        at oracle.opatch.opatch.main(opatch.java:927)
                                    caused by: java.lang.runtimeexception: patch archive operation failed.
                                        ... 9 more

你觉得这有点难读吗?我同意——我做了一个快速翻译,因为 190423787 的大小不容易使用。我也删除了一些输出。现在这工作得更好:

archive directory: /home/oracle/patch_storage has required permission to archive the patches
 32218454_jan_14_2021_16_24_38 :: 1.715 gb
 32545013_apr_16_2021_07_40_05 :: 1.974 gb
 32904851_jul_20_2021_09_21_24 :: 1.927 gb
 33192793_oct_15_2021_07_09_52 :: 1.818 gb
 33192694_sep_14_2021_16_48_27 :: 0.444 gb
 33197296_oct_4_2021_00_44_36 ::  0.126 gb
 32515361_jan_13_2022_06_14_07 :: 1.750 gb
 33561310_jan_5_2022_08_13_10 ::  0.452 gb
archive directory: /home/oracle/patch_storage needs 10.209 gb.
no space to archive given patches in /home/oracle/patch_storage

计算采用每个补丁目录的当前大小(此处介于 444 mb 和 1.9 gb 之间,将其相加,计算出大约 10 gb 的大小 - 并说:“嘿,迈克,您的设备上没有足够的空间再存储 10 gb “。

所以我把文件放在我的主机系统的磁盘上,知道我至少有 80gb 的可用空间。这是 opatch 完成其职责后的结果:

688m   jan 20 14:10   33515361_jan_13_2022_06_14_07.zip
948m   jan 20 14:12   32545013_apr_16_2021_07_40_05.zip
824m   jan 20 14:13   32904851_jul_20_2021_09_21_24.zip
119m   jan 20 14:13   33197296_oct_4_2021_00_44_36.zip
717m   jan 20 14:15   33192793_oct_15_2021_07_09_52.zip
118m   jan 20 14:15   33192694_sep_14_2021_16_48_27.zip
120m   jan 20 14:15   33561310_jan_5_2022_08_13_10.zip
725m   jan 20 14:17   32218454_jan_14_2021_16_24_38.zip

总共使用了 4.26 gb。这意味着消耗的空间不到 50%。

  • 学习 1:
    空间使用假设是完全错误的,并且使用当前大小而不是至少一个假设。

  • 学习 2:
    opatch util archive命令对每个补丁的子目录进行简单的压缩。

这让我想到了神奇的最后一个问题。

opatch util 存档会释放 .patch_storage 中的空间吗?

既然您已经看到上面的命令输出,您可能不再好奇了。

它进行清理。之后将删除每个要归档的补丁子目录。这就是我的.patch_storage目录之后的样子:

$ ls -lhrt
total 160k
-rw-r--r--.  1 oracle dba  24k jan 19 21:39 newdirs.txt
drwxr-xr-x. 16 oracle dba 4.0k jan 19 22:12 napply
-rw-r--r--.  1 oracle dba  64k jan 19 22:12 record_inventory.txt
-rw-r--r--.  1 oracle dba  64k jan 19 22:12 interim_inventory.txt
-rw-r--r--.  1 oracle dba   92 jan 19 22:12 latestopatchsession.properties

所有子目录都消失了。它现在只累积了 160k。

我想我可以处理这个。

如果你想回滚补丁会发生什么?

我很高兴在删除我将它们存档到的主机环境中的所有补丁之前,我也尝试了这一点:

$ ./opatch rollback -id 33516412
oracle interim patch installer version 12.2.0.1.28
米乐app官网下载 copyright (c) 2022, oracle corporation.  all rights reserved.
oracle home       : /u01/app/oracle/product/21
central inventory : /u01/app/orainventory
   from           : /u01/app/oracle/product/21/orainst.loc
opatch version    : 12.2.0.1.28
oui version       : 12.2.0.9.0
log file location : /u01/app/oracle/product/21/cfgtoollogs/opatch/opatch2022-01-20_15-38-47pm_1.log
patches will be rolled back in the following order: 
   33516412
prerequisite check "checkrollbackable" failed.
possible causes are:
 the patch can not be rolled back 
 no read or write permission to oracle_home/.patch _storage 
 the oracle_home/.patch_storage file may have been removed.
the details are:
***************************************************
following patches are archived:
33516412
please follow the instructions below to unarchive the patches before proceeding with current opatch operation (as /u01/app/oracle/product/21 owner).
step 1: /u01/app/oracle/product/21/opatch/opatch util unarchive -patches 33516412
step 2 : resume/rerun current opatch operation: /u01/app/oracle/product/21/opatch/opatch rollback -id 33516412 -invptrloc /u01/app/oracle/product/21/orainst.loc 
***************************************************
utilsession failed: prerequisite check "checkrollbackable" failed.
log file location: /u01/app/oracle/product/21/cfgtoollogs/opatch/opatch2022-01-20_15-38-47pm_1.log
opatch failed with error code 73

所以我需要先“取消归档”补丁。

让我试试这个:opatch util unarchive -patches 33516412

$ /u01/app/oracle/product/21/opatch/opatch util unarchive -patches 33516412
oracle interim patch installer version 12.2.0.1.28
米乐app官网下载 copyright (c) 2022, oracle corporation.  all rights reserved.
oracle home       : /u01/app/oracle/product/21
central inventory : /u01/app/orainventory
   from           : /u01/app/oracle/product/21/orainst.loc
opatch version    : 12.2.0.1.28
oui version       : 12.2.0.9.0
log file location : /u01/app/oracle/product/21/cfgtoollogs/opatch/opatch2022-01-20_15-40-58pm_1.log
invoking utility "unarchive"
unarchive given patches for given oh
started : unarchiving the patch dirs to oh/.patch_storage
user specified list :[33516412]
total space needed for unarchive :1511356677
unarchive successful :/u01/app/oracle/product/21/.patch_storage/33516412_jan_13_2022_06_54_26
unarchive  session is complete
to clean up archives from custom storage path,run the following command :'/u01/app/oracle/product/21/opatch/opatch util cleanuparchives'
opatch succeeded.

之后我可以为这个练习完成我的捆绑补丁的回滚。

  • 学习 3:
    如果您曾经计划回滚补丁包,请将存档保存在您要求 opatch 将它们存档到的完全相同的位置。否则,您可能无法回滚捆绑包。

其他发现

除了您需要知道获取“帮助”信息的命令这一事实之外,这是我很快遇到的另一个陷阱:

不要在补丁号之间放置空格字符。

当你这样做时:

$ ./opatch util archive -patches 33197448, 33587128 -archive_dir /media/sf_temp
oracle interim patch installer version 12.2.0.1.28
米乐app官网下载 copyright (c) 2022, oracle corporation.  all rights reserved.
syntax error... unrecognized option for util.
please use the option 'opatch util -help' to get correct syntax
opatch failed with error code 14

您会看到 opatch 因其中一个神秘错误而失败。

修复方法是去掉补丁号和逗号之间的空格,如:

$ ./opatch util archive -patches 33197448,33587128 -archive_dir /media/sf_temp
oracle interim patch installer version 12.2.0.1.28
米乐app官网下载 copyright (c) 2022, oracle corporation.  all rights reserved.
oracle home       : /u01/app/oracle/product/12.2.0.1
central inventory : /u01/app/orainventory
   from           : /u01/app/oracle/product/12.2.0.1/orainst.loc
opatch version    : 12.2.0.1.28
oui version       : 12.2.0.1.4
log file location : /u01/app/oracle/product/12.2.0.1/cfgtoollogs/opatch/opatch2022-01-20_15-21-41pm_1.log
invoking utility "archive"
archiving patch - 33587128 ....
sucessfully archived patch - 33587128 in /media/sf_temp/33587128_dec_27_2021_16_38_16.zip
archiving patch - 33197448 ....
sucessfully archived patch - 33197448 in /media/sf_temp/33197448_oct_4_2021_05_28_49.zip
succesfully verified the created archive. deleting the original patch from  - /u01/app/oracle/product/12.2.0.1/.patch_storage/33587128_dec_27_2021_16_38_16
succesfully verified the created archive. deleting the original patch from  - /u01/app/oracle/product/12.2.0.1/.patch_storage/33197448_oct_4_2021_05_28_49
patch archive operation completed successfully.
opatch succeeded.

然后它工作。

  • 学习 4:
    不要在逗号分隔的补丁号列表中使用空格字符作为-patches

  • 学习 5:
    新的opatch util archive命令释放了大量空间。不幸的是,没有自动性,仍然是非 n-1 m6米乐安卓版下载的解决方案。但是你们中的大多数人不会受到影响,因为你修补了新家,只是从一个家转到另一个家。

在我的测试中,我在 3 个 oracle home、12.2.0.1、19c 和 21c 中总共释放了大约 15gb。我仍然想要的是一个 n-1 选项,仅自动保留上一个补丁并清除旧补丁,因为我很少会跳回多个补丁包,如果有的话。此外,我还期望有一个“全部”开关,它可以清除每个补丁,而无需复制和粘贴单独的补丁号。

清理档案

最后——感谢向我指出这一点的斯蒂芬安德森——问题仍然存在:
你现在需要手动从磁盘中删除档案吗?

让我们看看,因为有另一个——或多或少没有记录的——命令。您可能已经在上面的输出中看到了这一点:
opatch util cleanuparchives

让我向您展示这是如何工作的:

$ $oracle_home/opatch/opatch util cleanuparchives
oracle interim patch installer version 12.2.0.1.28
米乐app官网下载 copyright (c) 2022, oracle corporation.  all rights reserved.
oracle home       : /u01/app/oracle/product/19
central inventory : /u01/app/orainventory
   from           : /u01/app/oracle/product/19/orainst.loc
opatch version    : 12.2.0.1.28
oui version       : 12.2.0.7.0
log file location : /u01/app/oracle/product/19/cfgtoollogs/opatch/opatch2022-01-21_12-27-56pm_1.log
invoking utility "cleanuparchives"
started : util cleauparchives session
patch id :33515361
patch id :32545013
patch id :32904851
patch id :33197296
patch id :33192793
patch id :33192694
patch id :33561310
patch id :32218454
nothing to cleanup
cleanuparchives from secondary storage is successful.
opatch succeeded.

现在知道 opatch 很长一段时间了,我想知道这个“ nothing to cleanup ”消息,然后是“… is successful ”输出。发生了什么事?

首先,我检查了我的存档存储——所有文件都还在。

然后作为下一步,我尝试恢复一个物理上仍在磁盘上的档案,就像我之前所做的那样:

$ /u01/app/oracle/product/21/opatch/opatch util unarchive -patches 33515361
oracle interim patch installer version 12.2.0.1.28
米乐app官网下载 copyright (c) 2022, oracle corporation.  all rights reserved.
oracle home       : /u01/app/oracle/product/19
central inventory : /u01/app/orainventory
   from           : /u01/app/oracle/product/19/orainst.loc
opatch version    : 12.2.0.1.28
oui version       : 12.2.0.7.0
log file location : /u01/app/oracle/product/19/cfgtoollogs/opatch/opatch2022-01-21_12-31-31pm_1.log
invoking utility "unarchive"
unarchive given patches for given oh
started : unarchiving the patch dirs to oh/.patch_storage
user specified list :[33515361]
total space needed for unarchive :1750455909
unarchive successful :/u01/app/oracle/product/19/.patch_storage/33515361_jan_13_2022_06_14_07
unarchive  session is complete
to clean up archives from custom storage path,run the following command :'/u01/app/oracle/product/19/opatch/opatch util cleanuparchives'
opatch succeeded.

所以基本上我不能告诉你“ cleanuparchives ”命令做了什么,或者它是否应该做任何事情。opatch 日志文件对我没有任何帮助。命令的帮助告诉我:

$ $oracle_home/opatch/opatch util cleanuparchives -help
oracle interim patch installer version 12.2.0.1.28
米乐app官网下载 copyright (c) 2022, oracle corporation.  all rights reserved.
description
    this operation helps to cleanup the archived files from custom storage
    location.
    note: this will not cleanup any other directories/files in the system.
   		  this will only cleanup the archives generated as part of 
   		  util archive operation.
syntax
opatch util cleanuparchives

我可以确认它没有做它应该做的事情。

「喜欢文章,快来给作者赞赏墨值吧」
【米乐app官网下载的版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论

网站地图