Oracle 12C 补丁升级
2019-01-27 17:37 WWJD_DBA 阅读(4205) 评论(0) 编辑 收藏 举报升级步骤
- Oracle 12.2.0.1升级至12.2.0.1.190115
1、阅读readme文件
2、检查更新opatch
3、备份程序
4、使用opatchauto工具进行数据库升级
5、打OJVM补丁
1、阅读readme文件
2、检查更新opatch
【12.1.0.2.0】版本是12.1.0.1.3 更新至12.2.0.1.13之上
【12.2.0.1.0】版本是12.2.0.1.6 更新至12.2.0.1.12之上
--更新opatch
https://updates.oracle.com/download/6880880.html Opatch下载地址
$ORACLE_HOME/OPatch/opatch version
$ORACLE_HOME/OPatch/opatch lspatches
chmod -R 777 /oracle/soft/p6880880_122010_Linux-x86-64.zip
--------------------------------oracle opatch
su - oracle
ls -ld $ORACLE_HOME/OPatch*
mv $ORACLE_HOME/OPatch $ORACLE_HOME/OPatch`date +\%Y\%m\%d`bak && cd /oracle/soft && unzip p6880880_122010_Linux-x86-64.zip -d $ORACLE_HOME
$ORACLE_HOME/OPatch/opatch version
RAC环境下无法在grid用户下直接执行,会报权限不足,需要root用户mv opatch
--------------------------------grid opatch
su - grid
ls -ld $ORACLE_HOME/OPatch*
cd $ORACLE_HOME/OPatch
pwd
su -
mv /oracle/app/12.2.0/grid/OPatch /oracle/app/12.2.0/grid/OPatch`date +\%Y\%m\%d`
unzip /oracle/soft/p6880880_122010_Linux-x86-64.zip -d /oracle/app/12.2.0/grid
chown -R grid:oinstall /oracle/app/12.2.0/grid/OPatch
su - grid
$ORACLE_HOME/OPatch/opatch version
3、备份程序
【备份软件】
su - root
mkdir -p /oracle/backup_soft
nohup tar -cvf /oracle/backup_soft/`date +\%Y\%m\%d`_oracle.tar /oracle/app/oracle >/oracle/backup_soft/`date +\%Y\%m\%d`_oracle.tar.log &
nohup tar -cvf /oracle/backup_soft/`date +\%Y\%m\%d`_12.2.0.tar /oracle/app/12.2.0 >/oracle/backup_soft/`date +\%Y\%m\%d`_12.2.0.tar.log &
nohup tar -cvf /oracle/backup_soft/`date +\%Y\%m\%d`_grid.tar /oracle/app/grid >/oracle/backup_soft/`date +\%Y\%m\%d`_grid.tar.log &
nohup tar -cvf /oracle/backup_soft/`date +\%Y\%m\%d`_oraInventory.tar /oracle/app/oraInventory >/oracle/backup_soft/`date +\%Y\%m\%d`_oraInventory.tar.log &
nohup tar -cvf /oracle/backup_soft/`date +\%Y\%m\%d`_etc.tar /etc >/oracle/backup_soft/`date +\%Y\%m\%d`_etc.tar.log &
4、使用opatchauto工具进行数据库升级
su – root
mkdir -p /oracle/soft/12c_patch
cd /oracle/soft/12c_patch
unzip /oracle/soft/p28980109_122010_Linux-x86-64.zip -d /oracle/soft/12c_patch
chmod -R 777 /oracle/soft/12c_patch
方法1:GI和DB分开打
【To patch only the GI home】
su - root
export UNZIPPED_PATCH_LOCATION=/oracle/soft/12c_patch/28980109
export GI_HOME=/oracle/app/12.2.0/grid
export PATH=$PATH:$GI_HOME/OPatch
opatchauto apply $UNZIPPED_PATCH_LOCATION/28828733 -oh $GI_HOME -analyze
opatchauto apply $UNZIPPED_PATCH_LOCATION/28828733 -oh $GI_HOME
【To patch only the DB home】
su - root
export UNZIPPED_PATCH_LOCATION=/oracle/soft/12c_patch/28980109
export ORACLE_HOME=/oracle/app/oracle/product/12.2.0/db_1
export PATH=$PATH:$ORACLE_HOME/OPatch
opatchauto apply $UNZIPPED_PATCH_LOCATION/28828733 -oh $ORACLE_HOME -analyze
opatchauto apply $UNZIPPED_PATCH_LOCATION/28828733 -oh $ORACLE_HOME
方法2:GI+DB一起打
su - root
export UNZIPPED_PATCH_LOCATION=/oracle/soft/12c_patch/28980109
export GI_HOME=/oracle/app/12.2.0/grid
export PATH=$PATH:$GI_HOME/OPatch
opatchauto apply $UNZIPPED_PATCH_LOCATION/28828733 -analyze
opatchauto apply $UNZIPPED_PATCH_LOCATION/28828733
--12C补丁列表信息
$ORACLE_HOME/OPatch/opatch version
$ORACLE_HOME/OPatch/opatch lspatches
$ORACLE_HOME/OPatch/opatch lsinventory
--检查数据字典中补丁信息
set lines 500 pages 500
col description for a80
col action_time for a35
col action for a10
col comments for a50
col VERSION for a20
col NAMESPACE for a20
col BUNDLE_SERIES for a20
select * from registry$history;
select patch_id,version,action,status,action_time,description from dba_registry_sqlpatch;
5、打OJVM补丁
【OJVM】
1、ojvm补丁检查
su - oracle
export PATCH_TOP_DIR=/oracle/soft/12c_patch/28980109
export PATH=$PATH:$ORACLE_HOME/OPatch
opatch prereq CheckConflictAgainstOHWithDetail -ph $PATCH_TOP_DIR/28790651
2、关闭所有服务(shut down all the services (database, ASM, listeners, nodeapps, and CRS daemons)
For an Oracle RAC environment, shut down all the services (database, ASM, listeners, nodeapps, and CRS daemons) running from the Oracle home on all the nodes you want to patch. su – root
/oracle/app/12.2.0/grid/bin/crsctl stop cluster -all -----停止所有节点集群服务
3、打OJVM补丁,所有节点都要打(OPatch is used on only one node at a time.)
su - oracle
export PATCH_TOP_DIR=/oracle/soft/12c_patch/28980109
export PATH=$PATH:$ORACLE_HOME/OPatch
cd $PATCH_TOP_DIR/28790651
$ORACLE_HOME/OPatch/opatch apply
$ORACLE_HOME/OPatch/opatch lspatches
$ORACLE_HOME/OPatch/opatch lsinventory
4、启服务 (After all nodes are patched, start all services. )
su – root
/oracle/app/12.2.0/grid/bin/crsctl start cluster -all -----启动所有节点集群服务
5、Loading Modified SQL Files Into the Database
1)Starting the Database for Post Installation Steps in an Oracle RAC Environment
On only one node, perform the following steps to start an Oracle RAC database in startup upgrade mode.
sqlplus / as sysdba
SQL> startup 启动所有服务的时候数据库资源以及启动了
SQL> alter system set cluster_database=false scope=spfile;
$ORACLE_HOME/bin/srvctl stop database -d ndscdb
sqlplus / as sysdba
SQL> startup upgrade
2)
cd $ORACLE_HOME/OPatch
./datapatch -verbose 过程见下面
sqlplus / as sysdba
SQL> shutdown immediate;
3)Restarting the Database after Running the Post Installation Steps in an Oracle RAC Environment
To start the database back in normal mode
sqlplus / as sysdba
SQL> startup
SQL> alter system set cluster_database=true scope=spfile;
SQL> shutdown immediate;
$ORACLE_HOME/bin/srvctl start database -d ndscdb
6、失效对象
cd $ORACLE_HOME/rdbms/admin
sqlplus / as sysdba
SQL> @utlrp.sql
set lin 300 pages 5000
col object_name for a40
col owner for a20
select count(*) from dba_objects where status=\'INVALID\';
select count(*) from dba_objects where status=\'INVALID\' and owner=\'SYS\';
select owner,object_name,object_type,status from dba_objects where status=\'INVALID\';
7、检查数据字典中补丁信息
set lines 500 pages 500
col description for a75
col action_time for a35
col action for a10
col comments for a50
col VERSION for a25
col NAMESPACE for a20
col BUNDLE_SERIES for a20
select * from registry$history;
select patch_id,version,action,status,action_time,description from dba_registry_sqlpatch;
附 升级补丁日志
--补丁安装日志
WWJD-DB1:/root #export UNZIPPED_PATCH_LOCATION=/oracle/soft/12c_patch/28980109
WWJD-DB1:/root #export GI_HOME=/oracle/app/12.2.0/grid
WWJD-DB1:/root #export PATH=$PATH:$GI_HOME/OPatch
WWJD-DB1:/root #opatchauto apply $UNZIPPED_PATCH_LOCATION/28828733 -oh $GI_HOME
OPatchauto session is initiated at Mon Jan 28 13:53:33 2019
System initialization log file is /oracle/app/12.2.0/grid/cfgtoollogs/opatchautodb/systemconfig2019-01-28_01-53-36PM.log.
Session log file is /oracle/app/12.2.0/grid/cfgtoollogs/opatchauto/opatchauto2019-01-28_01-53-48PM.log
The id for this session is D6KS
Executing OPatch prereq operations to verify patch applicability on home /oracle/app/12.2.0/grid
Patch applicability verified successfully on home /oracle/app/12.2.0/grid
Bringing down CRS service on home /oracle/app/12.2.0/grid
Prepatch operation log file location: /oracle/app/grid/crsdata/WWJD-db1/crsconfig/crspatch_WWJD-db1_2019-01-27_09-54-06PM.log
CRS service brought down successfully on home /oracle/app/12.2.0/grid
Start applying binary patch on home /oracle/app/12.2.0/grid
Binary patch applied successfully on home /oracle/app/12.2.0/grid
Starting CRS service on home /oracle/app/12.2.0/grid
Postpatch operation log file location: /oracle/app/grid/crsdata/WWJD-db1/crsconfig/crspatch_WWJD-db1_2019-01-27_09-58-04PM.log
CRS service started successfully on home /oracle/app/12.2.0/grid
OPatchAuto successful.
--------------------------------Summary--------------------------------
Patching is completed successfully. Please find the summary as follows:
Host:WWJD-db1
CRS Home:/oracle/app/12.2.0/grid
Version:12.2.0.1.0
Summary:
==Following patches were SUCCESSFULLY applied:
Patch: /oracle/soft/12c_patch/28980109/28828733/26839277
Log: /oracle/app/12.2.0/grid/cfgtoollogs/opatchauto/core/opatch/opatch2019-01-28_13-55-08PM_1.log
Patch: /oracle/soft/12c_patch/28980109/28828733/28566910
Log: /oracle/app/12.2.0/grid/cfgtoollogs/opatchauto/core/opatch/opatch2019-01-28_13-55-08PM_1.log
Patch: /oracle/soft/12c_patch/28980109/28828733/28822515
Log: /oracle/app/12.2.0/grid/cfgtoollogs/opatchauto/core/opatch/opatch2019-01-28_13-55-08PM_1.log
Patch: /oracle/soft/12c_patch/28980109/28828733/28864846
Log: /oracle/app/12.2.0/grid/cfgtoollogs/opatchauto/core/opatch/opatch2019-01-28_13-55-08PM_1.log
Patch: /oracle/soft/12c_patch/28980109/28828733/28870605
Log: /oracle/app/12.2.0/grid/cfgtoollogs/opatchauto/core/opatch/opatch2019-01-28_13-55-08PM_1.log
OPatchauto session completed at Mon Jan 28 14:06:37 2019
Time taken to complete the session 13 minutes, 4 seconds
WWJD-DB1:/root #
WWJD-DB1:/root #export UNZIPPED_PATCH_LOCATION=/oracle/soft/12c_patch/28980109
WWJD-DB1:/root #export ORACLE_HOME=/oracle/app/oracle/product/12.2.0/db_1
WWJD-DB1:/root #export PATH=$PATH:$ORACLE_HOME/OPatch
WWJD-DB1:/root #opatchauto apply $UNZIPPED_PATCH_LOCATION/28828733 -oh $ORACLE_HOME -analyze
OPatchauto session is initiated at Mon Jan 28 14:13:12 2019
System initialization log file is /oracle/app/oracle/product/12.2.0/db_1/cfgtoollogs/opatchautodb/systemconfig2019-01-28_02-13-16PM.log.
Session log file is /oracle/app/oracle/product/12.2.0/db_1/cfgtoollogs/opatchauto/opatchauto2019-01-28_02-14-04PM.log
The id for this session is 1RQ4
Executing OPatch prereq operations to verify patch applicability on home /oracle/app/oracle/product/12.2.0/db_1
Patch applicability verified successfully on home /oracle/app/oracle/product/12.2.0/db_1
Verifying SQL patch applicability on home /oracle/app/oracle/product/12.2.0/db_1
SQL patch applicability verified successfully on home /oracle/app/oracle/product/12.2.0/db_1
OPatchAuto successful.
--------------------------------Summary--------------------------------
Analysis for applying patches has completed successfully:
Host:WWJD-db1
RAC Home:/oracle/app/oracle/product/12.2.0/db_1
Version:12.2.0.1.0
==Following patches were SKIPPED:
Patch: /oracle/soft/12c_patch/28980109/28828733/28864846
Reason: This patch is not applicable to this specified target type - "rac_database"
Patch: /oracle/soft/12c_patch/28980109/28828733/26839277
Reason: This patch is not applicable to this specified target type - "rac_database"
Patch: /oracle/soft/12c_patch/28980109/28828733/28566910
Reason: This patch is not applicable to this specified target type - "rac_database"
==Following patches were SUCCESSFULLY analyzed to be applied:
Patch: /oracle/soft/12c_patch/28980109/28828733/28870605
Log: /oracle/app/oracle/product/12.2.0/db_1/cfgtoollogs/opatchauto/core/opatch/opatch2019-01-28_14-14-14PM_1.log
Patch: /oracle/soft/12c_patch/28980109/28828733/28822515
Log: /oracle/app/oracle/product/12.2.0/db_1/cfgtoollogs/opatchauto/core/opatch/opatch2019-01-28_14-14-14PM_1.log
OPatchauto session completed at Mon Jan 28 14:14:44 2019
Time taken to complete the session 1 minute, 32 seconds
WWJD-DB1:/root #opatchauto apply $UNZIPPED_PATCH_LOCATION/28828733 -oh $ORACLE_HOME
OPatchauto session is initiated at Mon Jan 28 14:15:18 2019
System initialization log file is /oracle/app/oracle/product/12.2.0/db_1/cfgtoollogs/opatchautodb/systemconfig2019-01-28_02-15-21PM.log.
Session log file is /oracle/app/oracle/product/12.2.0/db_1/cfgtoollogs/opatchauto/opatchauto2019-01-28_02-15-46PM.log
The id for this session is DJVQ
Executing OPatch prereq operations to verify patch applicability on home /oracle/app/oracle/product/12.2.0/db_1
Patch applicability verified successfully on home /oracle/app/oracle/product/12.2.0/db_1
Verifying SQL patch applicability on home /oracle/app/oracle/product/12.2.0/db_1
SQL patch applicability verified successfully on home /oracle/app/oracle/product/12.2.0/db_1
Preparing to bring down database service on home /oracle/app/oracle/product/12.2.0/db_1
Successfully prepared home /oracle/app/oracle/product/12.2.0/db_1 to bring down database service
Bringing down database service on home /oracle/app/oracle/product/12.2.0/db_1
Following database(s) and/or service(s) are stopped and will be restarted later during the session: ndscdb
Database service successfully brought down on home /oracle/app/oracle/product/12.2.0/db_1
Performing prepatch operation on home /oracle/app/oracle/product/12.2.0/db_1
Perpatch operation completed successfully on home /oracle/app/oracle/product/12.2.0/db_1
Start applying binary patch on home /oracle/app/oracle/product/12.2.0/db_1
Binary patch applied successfully on home /oracle/app/oracle/product/12.2.0/db_1
Performing postpatch operation on home /oracle/app/oracle/product/12.2.0/db_1
Postpatch operation completed successfully on home /oracle/app/oracle/product/12.2.0/db_1
Starting database service on home /oracle/app/oracle/product/12.2.0/db_1
Database service successfully started on home /oracle/app/oracle/product/12.2.0/db_1
Preparing home /oracle/app/oracle/product/12.2.0/db_1 after database service restarted
No step execution required.........
Trying to apply SQL patch on home /oracle/app/oracle/product/12.2.0/db_1
SQL patch applied successfully on home /oracle/app/oracle/product/12.2.0/db_1
OPatchAuto successful.
--------------------------------Summary--------------------------------
Patching is completed successfully. Please find the summary as follows:
Host:WWJD-db1
RAC Home:/oracle/app/oracle/product/12.2.0/db_1
Version:12.2.0.1.0
Summary:
==Following patches were SKIPPED:
Patch: /oracle/soft/12c_patch/28980109/28828733/28864846
Reason: This patch is not applicable to this specified target type - "rac_database"
Patch: /oracle/soft/12c_patch/28980109/28828733/26839277
Reason: This patch is not applicable to this specified target type - "rac_database"
Patch: /oracle/soft/12c_patch/28980109/28828733/28566910
Reason: This patch is not applicable to this specified target type - "rac_database"
==Following patches were SUCCESSFULLY applied:
Patch: /oracle/soft/12c_patch/28980109/28828733/28822515
Log: /oracle/app/oracle/product/12.2.0/db_1/cfgtoollogs/opatchauto/core/opatch/opatch2019-01-28_14-17-17PM_1.log
Patch: /oracle/soft/12c_patch/28980109/28828733/28870605
Log: /oracle/app/oracle/product/12.2.0/db_1/cfgtoollogs/opatchauto/core/opatch/opatch2019-01-28_14-17-17PM_1.log
OPatchauto session completed at Mon Jan 28 14:20:23 2019
Time taken to complete the session 5 minutes, 6 seconds
WWJD-DB1:/root #
节点2
WWJD-DB2:/root #export UNZIPPED_PATCH_LOCATION=/oracle/soft/12c_patch/28980109
WWJD-DB2:/root #export GI_HOME=/oracle/app/12.2.0/grid
WWJD-DB2:/root #export PATH=$PATH:$GI_HOME/OPatch
WWJD-DB2:/root #opatchauto apply $UNZIPPED_PATCH_LOCATION/28828733
OPatchauto session is initiated at Mon Jan 28 16:21:56 2019
System initialization log file is /oracle/app/12.2.0/grid/cfgtoollogs/opatchautodb/systemconfig2019-01-28_04-21-59PM.log.
Session log file is /oracle/app/12.2.0/grid/cfgtoollogs/opatchauto/opatchauto2019-01-28_04-22-27PM.log
The id for this session is SW7K
Executing OPatch prereq operations to verify patch applicability on home /oracle/app/oracle/product/12.2.0/db_1
Executing OPatch prereq operations to verify patch applicability on home /oracle/app/12.2.0/grid
Patch applicability verified successfully on home /oracle/app/oracle/product/12.2.0/db_1
Patch applicability verified successfully on home /oracle/app/12.2.0/grid
Verifying SQL patch applicability on home /oracle/app/oracle/product/12.2.0/db_1
SQL patch applicability verified successfully on home /oracle/app/oracle/product/12.2.0/db_1
Preparing to bring down database service on home /oracle/app/oracle/product/12.2.0/db_1
Successfully prepared home /oracle/app/oracle/product/12.2.0/db_1 to bring down database service
Bringing down CRS service on home /oracle/app/12.2.0/grid
Prepatch operation log file location: /oracle/app/grid/crsdata/WWJD-db2/crsconfig/crspatch_WWJD-db2_2019-01-28_00-23-06AM.log
CRS service brought down successfully on home /oracle/app/12.2.0/grid
Performing prepatch operation on home /oracle/app/oracle/product/12.2.0/db_1
Perpatch operation completed successfully on home /oracle/app/oracle/product/12.2.0/db_1
Start applying binary patch on home /oracle/app/oracle/product/12.2.0/db_1
Binary patch applied successfully on home /oracle/app/oracle/product/12.2.0/db_1
Performing postpatch operation on home /oracle/app/oracle/product/12.2.0/db_1
Postpatch operation completed successfully on home /oracle/app/oracle/product/12.2.0/db_1
Start applying binary patch on home /oracle/app/12.2.0/grid
Binary patch applied successfully on home /oracle/app/12.2.0/grid
Starting CRS service on home /oracle/app/12.2.0/grid
Postpatch operation log file location: /oracle/app/grid/crsdata/WWJD-db2/crsconfig/crspatch_WWJD-db2_2019-01-28_00-35-56AM.log
CRS service started successfully on home /oracle/app/12.2.0/grid
Preparing home /oracle/app/oracle/product/12.2.0/db_1 after database service restarted
No step execution required.........
Trying to apply SQL patch on home /oracle/app/oracle/product/12.2.0/db_1
SQL patch applied successfully on home /oracle/app/oracle/product/12.2.0/db_1
OPatchAuto successful.
--------------------------------Summary--------------------------------
Patching is completed successfully. Please find the summary as follows:
Host:WWJD-db2
RAC Home:/oracle/app/oracle/product/12.2.0/db_1
Version:12.2.0.1.0
Summary:
==Following patches were SKIPPED:
Patch: /oracle/soft/12c_patch/28980109/28828733/28864846
Reason: This patch is not applicable to this specified target type - "rac_database"
Patch: /oracle/soft/12c_patch/28980109/28828733/26839277
Reason: This patch is not applicable to this specified target type - "rac_database"
Patch: /oracle/soft/12c_patch/28980109/28828733/28566910
Reason: This patch is not applicable to this specified target type - "rac_database"
==Following patches were SUCCESSFULLY applied:
Patch: /oracle/soft/12c_patch/28980109/28828733/28822515
Log: /oracle/app/oracle/product/12.2.0/db_1/cfgtoollogs/opatchauto/core/opatch/opatch2019-01-28_16-31-15PM_1.log
Patch: /oracle/soft/12c_patch/28980109/28828733/28870605
Log: /oracle/app/oracle/product/12.2.0/db_1/cfgtoollogs/opatchauto/core/opatch/opatch2019-01-28_16-31-15PM_1.log
Host:WWJD-db2
CRS Home:/oracle/app/12.2.0/grid
Version:12.2.0.1.0
Summary:
==Following patches were SUCCESSFULLY applied:
Patch: /oracle/soft/12c_patch/28980109/28828733/26839277
Log: /oracle/app/12.2.0/grid/cfgtoollogs/opatchauto/core/opatch/opatch2019-01-28_16-32-45PM_1.log
Patch: /oracle/soft/12c_patch/28980109/28828733/28566910
Log: /oracle/app/12.2.0/grid/cfgtoollogs/opatchauto/core/opatch/opatch2019-01-28_16-32-45PM_1.log
Patch: /oracle/soft/12c_patch/28980109/28828733/28822515
Log: /oracle/app/12.2.0/grid/cfgtoollogs/opatchauto/core/opatch/opatch2019-01-28_16-32-45PM_1.log
Patch: /oracle/soft/12c_patch/28980109/28828733/28864846
Log: /oracle/app/12.2.0/grid/cfgtoollogs/opatchauto/core/opatch/opatch2019-01-28_16-32-45PM_1.log
Patch: /oracle/soft/12c_patch/28980109/28828733/28870605
Log: /oracle/app/12.2.0/grid/cfgtoollogs/opatchauto/core/opatch/opatch2019-01-28_16-32-45PM_1.log
OPatchauto session completed at Mon Jan 28 16:42:00 2019
Time taken to complete the session 20 minutes, 4 seconds
WWJD-DB2:/root #