注意:如果要部署ADG,主备补丁都在配置ADG后实施。
如果备库仅安装了GI和DB软件,打补丁时只会对GI进行打补丁。
如果不部署ADG,按如下方法给数据库打补丁。
以 p35642822_190000_Linux-x86-64.zip(OCT2023, 19.21.0.0.0) 为例。
下面是给 GI 与 DB 软件一键打 PSU 补丁的方法,根据补丁的不同,安装方法可能有所差异,请参考 README 文件。
升级OPatch 工具
所有节点的 GRID_HOME 目录和 ORACLE_HOME 目录下的 OPatch 目录都需要被更新。
# cd /tmp
# wget ftp://10.30.1.8/pub/soft/db/oracle_opatch_p6880880_190000_Linux-x86-64.zip(生产,指向最新的OPatch)
# su - xoracle
$ unzip -d $ORACLE_HOME /tmp/oracle_opatch_p6880880_190000_Linux-x86-64.zip
$ $ORACLE_HOME/OPatch/opatch version
# su - xgrid
再次执行上面的两条命令。
在其它节点上完成上面相同的操作。
准备共享目录
备库仅创建目录即可,主库通过NFS建立共享:
在节点1上:
# mkdir /dbu; chmod 777 /dbu
# cat /etc/exports
/dbu *(rw,no_root_squash)
# systemctl restart nfs-server rpcbind
在节点2上:
# mkdir /dbu
# mount -t nfs racnode1:/dbu /dbu
准备补丁文件
在节点1上,以 xgrid 身份运行:
$ cd /dbu/
$ wget ftp://10.30.1.8/pub/soft/db/oracle_19c21u_grid_p35642822_190000_Linux-x86-64.zip(生产,RU21)
$ unzip oracle_19c21u_grid_p35642822_190000_Linux-x86-64.zip
# chmod -R 777 /dbu/ (防止因 umask 的不当设置导致文件权限不对)
Oracle 资产校验
在所有节点上分别以 xoracle 和 xgrid 身份执行:
$ $ORACLE_HOME/OPatch/opatch lsinventory -detail -oh $ORACLE_HOME
补丁冲突检查(初次打补丁可以跳过)
以xgrid身份运行:
$ $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /dbu/35642822/35643107
$ $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /dbu/35642822/35655527
$ $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /dbu/35642822/35652062
$ $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /dbu/35642822/35553096
$ $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /dbu/35642822/33575402
以xoracle身份运行:
$ $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /dbu/35642822/35643107
$ $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /dbu/35642822/35655527
应用补丁
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.
在第一个节点上以root身份运行,完成后再在第二个节点上运行,不能并行。
# export PATH=/opt/cluster/product/grid/OPatch:$PATH
# which opatchauto
/opt/cluster/product/grid/OPatch/opatchauto
# export TMOUT=0
19C因为bug ( Doc ID 2582139.1 ),需要将节点1的如下文件复制到节点2相同目录下,并确保文件权限与属主与节点1保持一致后再执行下面的命令。
[xgrid]$ scp /opt/cluster/oraInventory/ContentsXML/oui-patch.xml racnode2:/opt/cluster/oraInventory/ContentsXML/
[xgrid]$ ssh racnode2 'ls -l /opt/cluster/oraInventory/ContentsXML/oui-patch.xml'
[xgrid]$ ssh racnode2 'chmod 660 /opt/cluster/oraInventory/ContentsXML/oui-patch.xml'
# cd /dbu
# opatchauto apply /dbu/35642822 [-nonrolling]
# Load Modified SQL Files into the Database
如果打补丁失败,则重启主机后再进行(原因可能是文件占用未释放,曾在备库发生过)
两个节点均完成后,卸载并关闭 NFS 共享。
清理环境
第2个节点:
# umount /dbu; rmdir /dbu
第1个节点:
# systemctl stop nfs-server rpcbind; > /etc/exports; rm -fr /dbu/