1.停止集群件备份家目录
----两节点分别操作
cd /u01/app/19.3.0/grid/bin/
crsctl stop crs
tar -zcvf /u01/app.tar.gz /u01/app
/u01/app/19.0.0/grid/bin/crsctl start crs
2.两节点 GI、DB OPatch 替换(都得执行)
----# 表示 root 用户,$ 表示 Oracle 用户提示符,(ASM1)$ 表示 grid 用户
# cd /u01/app/19.3.0/grid
# mv OPatch OPatch.bak20
# chown -R grid:oinstall /soft
# unzip p6880880_19c_19.20_Linux-x86-64.zip
# cp -r OPatch /u01/app/19.3.0/grid/
# chown grid:oinstall -R /u01/app/19.3.0/grid/OPatch
su - grid
cd /u01/app/19.3.0/grid/OPatch
./opatch version
$ opatch version
[grid@p19c01:/u01/app/19.3.0/grid/OPatch]$ ./opatch version
OPatch Version: 12.2.0.1.39
OPatch succeeded.
DB:
$ cd $ORACLE_HOME
$ mv OPatch/ OPatch_bak20
su root
chown -R oracle:oinstall /soft
cp -r /soft/OPatch ./
cd OPatch
./opatch version
[oracle@p19c01:/u01/app/oracle/product/19.3.0/db/OPatch]$ ./opatch version
OPatch Version: 12.2.0.1.39
OPatch succeeded.
[oracle@p19c01:/u01/app/oracle/product/19.3.0/db/OPatch]$
grid:
oracle:
3 收集补丁信息
所有库都要做:
grid:
su - root
chown grid:oinstall -R /soft
su - grid
$ORACLE_HOME/OPatch/opatch lsinventory > /soft/grid_patch.txt
$ORACLE_HOME/OPatch/opatch lsinv -detail -oh $ORACLE_HOME >> /soft/grid_patch.txt
$ORACLE_HOME/OPatch/opatch lspatches >> /soft/grid_patch.txt
oracle:
su - root
chown oracle:oinstall -R /soft
chown oracle:oinstall -R /OPatch
su - oracle
$ORACLE_HOME/OPatch/opatch lsinventory > /soft/oracle_patch.txt
$ORACLE_HOME/OPatch/opatch lsinv -detail -oh $ORACLE_HOME >> /soft/oracle_patch.txt
$ORACLE_HOME/OPatch/opatch lspatches >> /soft/oracle_patch.txt
4 补丁冲突验证
cd /soft
[root@rac2 soft]# unzip 19c_19.20_Linux-x86-64.zip
[root@rac2 soft]# chmod -R 777 35319490
我们可以下载readme文件查看
Grid:
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /soft/35319490/35320081
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /soft/35319490/35320149
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /soft/35319490/35332537
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /soft/35319490/35553096
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /soft/35319490/33575402
Oracle:
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /soft/35319490/35320081
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /soft/35319490/35320149
grid:
所有的补丁都得打
oracle:
5 补丁空间验证
Grid用户查看
[root@rac1 ~]$ vi /soft/patch_list_gihome.txt
[root@rac1 ~]# cat /soft/patch_list_gihome.txt
下面的内容是写到/soft/patch_list_gihome.txt
/soft/35319490/35320081
/soft/35319490/35320149
/soft/35319490/35332537
/soft/35319490/35553096
/soft/35319490/33575402
chown grid:oinstall -R /soft/patch_list_gihome.txt
su - grid
[grid@rac1 ~]$ $ORACLE_HOME/OPatch/opatch prereq CheckSystemSpace -phBaseFile /soft/patch_list_gihome.txt
Oracle用户查看
su - root
vi /soft/patch_list_dbhome.txt
[oracle@rac1 oatch_rac]$ cat /soft/patch_list_dbhome.txt
/soft/35319490/35320081
/soft/35319490/35320149
chown oracle:oinstall -R /soft/patch_list_dbhome.txt
su - oracle
[oracle@rac1 ~]$ $ORACLE_HOME/OPatch/opatch prereq CheckSystemSpace -phBaseFile /soft/patch_list_dbhome.txt
6 补丁预演
root:
/u01/app/oracle/product/19.3.0/db/OPatch/opatchauto apply /soft/35319490 -oh /u01/app/oracle/product/19.3.0/db -analyze
/u01/app/19.3.0/grid/OPatch/opatchauto apply /soft/35319490 -oh /u01/app/19.3.0/grid -analyze
7.组件及无效对象检查
su - oracle
sqlplus / as sysdba
spool /soft/database_invalid.sql
set lines 200 pages 2000;
show parameter name;
col comp_id for a20;
col version for a20;
col status for a30;
select comp_id,version,status from dba_registry;
select owner,object_type,object_name from dba_objects where status<>'VALID';
spool off;
8 补丁更打
滚动升级,打完一个节点的再打另一个节点,此操作主库须与业务确认
我的升级采用了两种方法,一种是grid和oracle分开打补丁,一种是一起打补丁
节点一采用的是分开打补丁,节点二采用的是一起打补丁
8.1 GI补丁更打
问题/dev/shm磁盘空间不足
ORA-00845: MEMORY_TARGET not supported on this system
Cause: The MEMORY_TARGET parameter was not supported on this operating system or /dev/shm was not sized correctly on Linux.
Action: Refer to documentation for a list of supported operating systems. Or, size /dev/shm to be at least the SGA_MAX_SIZE on each Oracle instance running on the system.
解决方法
扩容/shm
vim /etc/fstab
tmpfs /dev/shm tmpfs defaults,size=3G 0 0
umount /dev/shm/
mount /dev/shm/
df -h
首先检测集群的状态,保证集群是正常工作的
su - oracle
srvctl status database -d p19c0
如果没启动,记得启动一下实例
srvctl start instance -d p19c0 -i p19c01
srvctl start instance -d p19c0 -i p19c02
可以在grid中查看
su - grid
cd /u01/app/19.3.0/grid/bin
crsctl status res -t
接着我们按照readme的要求将OPatch的路径加入到.bash_profile中
su - root
vi .bash_profile
export PATH=$PATH:$HOME/bin:/u01/app/19.3.0/grid/bin
export PATH=$PATH:/u01/app/19.3.0/grid/OPatch
source .bash_profile
补丁冲突检查
ps -ef | grep sqlplus //如果有sqlplus连进去都需要杀掉,两个节点都检查
su - root
export PERL5LIB=/u01/app/19.3.0/grid/perl/lib
cd /
opatchauto apply /soft/35319490 -analyze
给grid用户打补丁
ps -ef | grep sqlplus
export PERL5LIB=/u01/app/19.3.0/grid/perl/lib
opatchauto apply /soft/35319490
ps -ef | grep sqlplus
export PERL5LIB=/u01/app/19.3.0/grid/perl/lib
/u01/app/19.3.0/grid/OPatch/opatchauto apply /soft/35319490 -oh /u01/app/19.3.0/grid -analyze
ps -ef | grep sqlplus
export PERL5LIB=/u01/app/19.3.0/grid/perl/lib
/u01/app/19.3.0/grid/OPatch/opatchauto apply /soft/35319490 -oh /u01/app/19.3.0/grid
给oracle用户打补丁
ps -ef | grep sqlplus
export PERL5LIB=/u01/app/19.3.0/grid/perl/lib
/u01/app/oracle/product/19.3.0/db/OPatch/opatchauto apply /soft/35319490 -oh /u01/app/oracle/product/19.3.0/db -analyze
ps -ef | grep sqlplus
export PERL5LIB=/u01/app/19.3.0/grid/perl/lib
/u01/app/oracle/product/19.3.0/db/OPatch/opatchauto apply /soft/35319490 -oh /u01/app/oracle/product/19.3.0/db
补丁检查:
opatch lsinventory
回退补丁:
opatchauto rollback /soft/35319490
节点二打补丁
chown oracle:oinstall -R /soft/35319490
首先检测集群的状态,保证集群是正常工作的
su - oracle
srvctl status database -d p19c0
如果没启动,记得启动一下实例
srvctl start instance -d p19c0 -i p19c01
srvctl start instance -d p19c0 -i p19c02
可以在grid仲查看
cd /u01/app/19.3.0/grid/bin
crsctl status res -t
接着我们按照readme的要求将OPatch的路径加入到.bash_profile中
su - root
vi .bash_profile
PATH=$PATH:$HOME/bin:/u01/app/19.3.0/grid/bin
export PATH=$PATH:/u01/app/19.3.0/grid/OPatch
source .bash_profile
我们要将sqlplus进程都退出
补丁冲突检查
ps -ef | grep sqlplus //如果有sqlplus连进去都需要杀掉,两个节点都检查
su - root
chmod 660 /u01/app/oraInventory/ContentsXML/oui-patch.xml
chown grid:oinstall -R /u01/app/oraInventory/ContentsXML/oui-patch.xml
su - root
cd /
export PERL5LIB=/u01/app/19.3.0/grid/perl/lib
opatchauto apply /soft/35319490 -analyze
打补丁
ps -ef | grep sqlplus
export PERL5LIB=/u01/app/19.3.0/grid/perl/lib
su - oracle
cd $ORACLE_HOME/OPatch
./opatch lspatches
opatchauto rollback /soft/33182768
opatchauto rollback /soft/33182768 -oh /u01/app/19.3.0/grid
8.2节点一打完补丁之后进行补丁注册以及编译无效对象
将修改后的SQL文件加载到数据库中
下表是针对独立数据库运行Datapatch实用程序的步骤,在一个节点执行即可。
sqlplus / as sysdba
startup upgrade
quit
cd $ORACLE_HOME/OPatch
./datapatch -verbose
查看patch
set linesize 200;
col STATUS format a20;
col DESCRIPTION format a80;
select PATCH_ID,PATCH_TYPE,STATUS,DESCRIPTION from dba_registry_sqlpatch;
查看是否有存在失效对象:
col owner for a16
col object_name for a50 trunc
col object_type for a20 trunc
select owner,object_name,object_type from dba_objects where status != 'VALID';
--若有,执行命令清空:
@?/rdbms/admin/utlrp.sql
打完补丁之后检查
crsctl query crs releasepatch
crsctl query crs softwarepatch
kfod op=patches
9.打完补丁之后的操作
启动数据库
startup
将修改后的SQL文件加载到数据库中
下表是针对独立数据库运行Datapatch实用程序的步骤,在一个节点执行即可。
sqlplus / as sysdba
startup upgrade
quit
cd $ORACLE_HOME/OPatch
./datapatch -verbose
查看patch
set linesize 200;
col STATUS format a20;
col DESCRIPTION format a80;
select PATCH_ID,PATCH_TYPE,STATUS,DESCRIPTION from dba_registry_sqlpatch;
查看是否有存在失效对象:
col owner for a16
col object_name for a50 trunc
col object_type for a20 trunc
select owner,object_name,object_type from dba_objects where status != 'VALID';
--若有,执行命令清空:
@?/rdbms/admin/utlrp.sql
10.补丁回退
节点一
su - root
chown oracle:oinstall -R /soft
chown oracle:oinstall -R /soft/35319490
/u01/app/19.3.0/grid/OPatch/opatchauto rollback /soft/35319490 -oh /u01/app/19.3.0/grid
chown oracle:oinstall -R /soft
chown oracle:oinstall -R /soft/35319490
/u01/app/oracle/product/19.3.0/db/OPatch/opatchauto rollback /soft/35319490 -oh /u01/app/oracle/product/19.3.0/db
节点二
su - root
chown grid:oinstall -R /soft
chown grid:oinstall -R /soft/35319490
/u01/app/19.3.0/grid/OPatch/opatchauto rollback /soft/35319490 -oh /u01/app/19.3.0/grid
chown oracle:oinstall -R /soft
chown oracle:oinstall -R /soft/35319490
/u01/app/oracle/product/19.3.0/db/OPatch/opatchauto rollback /soft/35319490 -oh /u01/app/oracle/product/19.3.0/db
回退之后检查
crsctl query crs releasepatch
crsctl query crs softwarepatch
kfod op=patches
回退完成
p/oracle/product/19.3.0/db
[外链图片转存中...(img-eps349ri-1711252411865)]
[外链图片转存中...(img-pI7y6usu-1711252411865)]
[外链图片转存中...(img-Nuwn8eDV-1711252411865)]
回退之后检查
crsctl query crs releasepatch
crsctl query crs softwarepatch
kfod op=patches
[外链图片转存中...(img-HgvYkpUF-1711252411866)]
[外链图片转存中...(img-nwbqeyXP-1711252411866)]
[外链图片转存中...(img-cy5clEmX-1711252411866)]
回退完成
[外链图片转存中...(img-zWeXGX0v-1711252411867)]