1.2.1.2 Validation of Oracle Inventory
$ORACLE_HOME/OPatch/opatch lsinventory -detail -oh $ORACLE_HOME
1.2.1.3 Download and Unzip the Patch
[root@wydb01:0 /u01/soft/patch]$ unzip p31750108_190000_Linux-x86-64.zip
[root@wydb01:0 /u01/soft/patch]$ chown -R grid.oinstall 31750108
1.2.1.4 Run OPatch Conflict Check
For Grid Infrastructure Home, as home user:
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /u01/soft/patch/31750108/31771877
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /u01/soft/patch/31750108/31772784
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /u01/soft/patch/31750108/31773437
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /u01/soft/patch/31750108/ --- 这个没必要做
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /u01/soft/patch/31750108/31780966
For Database home, as home user:
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /u01/soft/patch/31750108/31771877
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /u01/soft/patch/31750108/31772784
1.2.1.5 Run OPatch SystemSpace Check
For Grid Infrastructure Home, as home user:
Create file /tmp/patch_list_gihome.txt with the following content:
cat > /tmp/patch_list_gihome.txt <<EOF
/u01/soft/patch/31750108/31771877
/u01/soft/patch/31750108/31772784
/u01/soft/patch/31750108/31773437
/u01/soft/patch/31750108/31780966
EOF
Run the opatch command to check if enough free space is available in the Grid Infrastructure Home:
$ORACLE_HOME/OPatch/opatch prereq CheckSystemSpace -phBaseFile /tmp/patch_list_gihome.txt
For Database home, as home user:
Create file /tmp/patch_list_dbhome.txt with the following content:
cat > /tmp/patch_list_dbhome.txt <<EOF
/u01/soft/patch/31750108/31771877
/u01/soft/patch/31750108/31772784
EOF
Run opatch command to check if enough free space is available in the Database Home:
$ORACLE_HOME/OPatch/opatch prereq CheckSystemSpace -phBaseFile /tmp/patch_list_dbhome.txt
1.2.2 One-off Patch Conflict Detection and Resolution
1.2.3 opatchauto
The Opatch utility has automated the patch application for the Oracle Grid Infrastructure (GI) home and the Oracle RAC database homes. It operates by querying existing configurations and automating the steps required for patching each Oracle RAC database home of same version and the GI home.
The utility must be executed by an operating system (OS) user with root privileges, and it must be executed on each node in the cluster if the GI home or Oracle RAC database home is in non-shared storage. The utility should not be run in parallel on the cluster nodes.
Depending on command line options specified, one invocation of opatchauto can patch the GI home, Oracle RAC database homes, or both GI and Oracle RAC database homes of the same Oracle release version as the patch. You can also roll back the patch with the same selectivity.
Add the directory containing the opatchauto to the $PATH environment variable. For example:
export PATH=$PATH:/u01/app/12.2.0/grid/OPatch
To patch the GI home and all Oracle RAC database homes of the same version:
opatchauto apply /u01/soft/patch/31750108
[root@wydb01:0 /u01/soft/patch]$ opatchauto apply /u01/soft/patch/31750108
OPatchauto session is initiated at Sat Nov 28 10:36:55 2020
System initialization log file is /u01/app/12.2.0/grid/cfgtoollogs/opatchautodb/systemconfig2020-11-28_10-36-58AM.log.
Session log file is /u01/app/12.2.0/grid/cfgtoollogs/opatchauto/opatchauto2020-11-28_10-37-46AM.log
The id for this session is J2VP
Executing OPatch prereq operations to verify patch applicability on home /u01/app/12.2.0/grid
Executing OPatch prereq operations to verify patch applicability on home /u01/app/oracle/product/12.2.0/db_1
Patch applicability verified successfully on home /u01/app/oracle/product/12.2.0/db_1
Patch applicability verified successfully on home /u01/app/12.2.0/grid
Verifying SQL patch applicability on home /u01/app/oracle/product/12.2.0/db_1
SQL patch applicability verified successfully on home /u01/app/oracle/product/12.2.0/db_1
Preparing to bring down database service on home /u01/app/oracle/product/12.2.0/db_1
Successfully prepared home /u01/app/oracle/product/12.2.0/db_1 to bring down database service
Bringing down CRS service on home /u01/app/12.2.0/grid
CRS service brought down successfully on home /u01/app/12.2.0/grid
Performing prepatch operation on home /u01/app/oracle/product/12.2.0/db_1
Perpatch operation completed successfully on home /u01/app/oracle/product/12.2.0/db_1
Start applying binary patch on home /u01/app/oracle/product/12.2.0/db_1
The network connection was aborted by the local system.
可见关键时刻出现了网络中断!
杀掉opatch相关的进程,先不回滚,再次执行apply试一试:
[root@wydb01:5 ~]$ opatchauto apply /u01/soft/patch/31750108
OPatchauto session is initiated at Sat Nov 28 10:57:26 2020
System initialization log file is /u01/app/12.2.0/grid/cfgtoollogs/opatchautodb/systemconfig2020-11-28_10-57-31AM.log.
Clusterware is either not running or not configured. You have the following 2 options:
- Configure and start the Clusterware on this node and re-run the tool
- Run the tool with '-oh
' to first patch the Grid Home, then invoke tool with '-database ' or '-oh ' to patch the RAC home
OPATCHAUTO-72029: CLusterware home not configured.
OPATCHAUTO-72029: Clusterware is either not running or not configured or cluster is software only GI
OPATCHAUTO-72029: If only Grid Infrastructure software is installed, please run opatchauto with '-oh' option . Alternatively configure and start the Clusterware before running opatchauto.
OPatchauto session completed at Sat Nov 28 10:57:33 2020
Time taken to complete the session 0 minute, 7 seconds
Topology creation failed.
可见需要启动crs
[root@wydb01:5 ~]$ crsctl start crs
CRS-6706: Oracle Clusterware Release patch level ('1645742981') does not match Software patch level ('441346801'). Oracle Clusterware cannot be started.
CRS-4000: Command Start failed, or completed with errors.
可见无法启动crs
这里需要清理本地patch即可启动crs及db
clscfg -localpatch
crsctl start crs
吸取教训不再远程操作以免浪费时间,登陆到内网服务器xwindows界面,再次apply
2020-11-28 11:14:45,492 INFO [1] oracle.glcm.opatch.common.impl.SingletonPatch - /u01/soft/patch/31750108/31772784/etc/config/maintenance_alias.xml does not exist
2020-11-28 11:15:31,957 INFO [1] oracle.opatchauto.core.binary.OACLogger -
Patch /u01/soft/patch/31750108/31772784 FAILED.
2020-11-28 11:15:31,958 INFO [1] oracle.opatchauto.core.binary.OACLogger -
oracle.opatch.opatchsdk.OPatchException: ApplySession failed in system modification phase... 'ApplySession::apply failed:
Copy failed from '/u01/soft/patch/31750108/31772784/files/bin/crsd.bin' to '/u01/app/12.2.0/grid/bin/crsd.bin'...
Copy failed from '/u01/soft/patch/31750108/31772784/files/bin/gipcd.bin' to '/u01/app/12.2.0/grid/bin/gipcd.bin'...
Copy failed from '/u01/soft/patch/31750108/31772784/files/bin/octssd.bin' to '/u01/app/12.2.0/grid/bin/octssd.bin'...
Copy failed from '/u01/soft/patch/31750108/31772784/files/bin/ohasd.bin' to '/u01/app/12.2.0/grid/bin/ohasd.bin'...
Copy failed from '/u01/soft/patch/31750108/31772784/files/bin/oraagent.bin' to '/u01/app/12.2.0/grid/bin/oraagent.bin'...
Copy failed from '/u01/soft/patch/31750108/31772784/files/bin/osysmond.bin' to '/u01/app/12.2.0/grid/bin/osysmond.bin'...
这次失败的原因是无法cp文件,详情提示“Text file busy”
再次apply时发现,提示已经成功停止crs时实际是误报,crs并没有停止,赶紧同时手动停止crs即可顺利完成apply。
查看日志可以发现,有些已经apply的会直接跳过,如下:
==Following patches were SKIPPED:
Patch: /u01/soft/patch/31750108/31771877
Reason: This patch is already been applied, so not going to apply again.
==Following patches were SUCCESSFULLY applied:
Patch: /u01/soft/patch/31750108/31772784
Log: /u01/app/12.2.0/grid/cfgtoollogs/opatchauto/core/opatch/opatch2020-11-28_11-46-18AM_1.log
Patch: /u01/soft/patch/31750108/31773437
Log: /u01/app/12.2.0/grid/cfgtoollogs/opatchauto/core/opatch/opatch2020-11-28_11-46-18AM_1.log
Patch: /u01/soft/patch/31750108/31780966
Log: /u01/app/12.2.0/grid/cfgtoollogs/opatchauto/core/opatch/opatch2020-11-28_11-46-18AM_1.log
此时查看补丁情况如下:
[grid@wydb01:6 ~]$ $ORACLE_HOME/OPatch/opatch lspatches
31780966;TOMCAT RELEASE UPDATE 19.0.0.0.0 (31780966)
31773437;ACFS RELEASE UPDATE 19.9.0.0.0 (31773437)
31772784;OCW RELEASE UPDATE 19.9.0.0.0 (31772784)
31771877;Database Release Update : 19.9.0.0.201020 (31771877)
OPatch succeeded.
[oracle@wydb01:6 ~]$ $ORACLE_HOME/OPatch/opatch lspatches
31772784;OCW RELEASE UPDATE 19.9.0.0.0 (31772784)
31771877;Database Release Update : 19.9.0.0.201020 (31771877)
OPatch succeeded.
由于我已经事先创建了数据库包括3个PDB,按照官方文档,需要执行如下步骤。
1.2.6.2 Loading Modified SQL Files into the Database
open所有的pdb
cd $ORACLE_HOME/OPatch
./datapatch -verbose
在rac节点1执行输出如下:
[oracle@wydb01:1 ~]$ cd $ORACLE_HOME/OPatch [oracle@wydb01:1 /u01/app/oracle/product/12.2.0/db_1/OPatch]$ ./datapatch -verbose SQL Patching tool version 19.9.0.0.0 Production on Sat Nov 28 14:30:50 2020 Copyright (c) 2012, 2020, Oracle. All rights reserved. Log file for this invocation: /u01/app/oracle/cfgtoollogs/sqlpatch/sqlpatch_144528_2020_11_28_14_30_50/sqlpatch_invocation.log Connecting to database...OK Gathering database info...done Note: Datapatch will only apply or rollback SQL fixes for PDBs that are in an open state, no patches will be applied to closed PDBs. Please refer to Note: Datapatch: Database 12c Post Patch SQL Automation (Doc ID 1585822.1) Bootstrapping registry and package to current versions...done Determining current state...done Current state of interim SQL patches: No interim patches found Current state of release update SQL patches: Binary registry: 19.9.0.0.0 Release_Update 200930183249: Installed PDB CDB$ROOT: Applied 19.3.0.0.0 Release_Update 190410122720 successfully on 03-NOV-20 06.38.48.877045 PM PDB PDB$SEED: Applied 19.3.0.0.0 Release_Update 190410122720 successfully on 03-NOV-20 06.38.50.622447 PM PDB PDBAPP: Applied 19.3.0.0.0 Release_Update 190410122720 successfully on 03-NOV-20 06.38.50.622447 PM PDB PDBCOL: Applied 19.3.0.0.0 Release_Update 190410122720 successfully on 03-NOV-20 06.38.50.622447 PM PDB PDBHIS: Applied 19.3.0.0.0 Release_Update 190410122720 successfully on 03-NOV-20 06.38.50.622447 PM Adding patches to installation queue and performing prereq checks...done Installation queue: For the following PDBs: CDB$ROOT PDB$SEED PDBAPP PDBHIS PDBCOL No interim patches need to be rolled back Patch 31771877 (Database Release Update : 19.9.0.0.201020 (31771877)): Apply from 19.3.0.0.0 Release_Update 190410122720 to 19.9.0.0.0 Release_Update 200930183249 No interim patches need to be applied Installing patches... Patch installation complete. Total patches installed: 5 Validating logfiles...done Patch 31771877 apply (pdb CDB$ROOT): SUCCESS logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/31771877/23869227/31771877_apply_WYDB_CDBROOT_2020Nov28_14_32_31.log (no errors) Patch 31771877 apply (pdb PDB$SEED): SUCCESS logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/31771877/23869227/31771877_apply_WYDB_PDBSEED_2020Nov28_14_34_36.log (no errors) Patch 31771877 apply (pdb PDBAPP): SUCCESS logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/31771877/23869227/31771877_apply_WYDB_PDBAPP_2020Nov28_14_34_36.log (no errors) Patch 31771877 apply (pdb PDBHIS): SUCCESS logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/31771877/23869227/31771877_apply_WYDB_PDBHIS_2020Nov28_14_34_36.log (no errors) Patch 31771877 apply (pdb PDBCOL): SUCCESS logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/31771877/23869227/31771877_apply_WYDB_PDBCOL_2020Nov28_14_34_36.log (no errors) SQL Patching tool complete on Sat Nov 28 14:36:28 2020
最后执行:
cd $ORACLE_HOME/rdbms/admin
sqlplus / AS SYSDBA
SQL> @utlrp.sql
文章评论