oracle 19c 主备 补丁升级19.22

本文详细描述了Oracle数据库的补丁升级过程,包括备份、关闭监听、应用补丁、冲突检测、主备库切换及回退等步骤。
摘要由CSDN通过智能技术生成
  • 补丁升级流程

    • 备库升级

      备库备份$ORALCE_HOME

du -sh $ORACLE_HOME

·        ​​​​​​​        备份目录将dbhome_1压缩

cd $ORACLE_HOME

cd ..

Ls

tar -cvzf db_home.tar.gz db_home_1 /opt/oracle/product/19c

  ​​​​​​​​​​​​​​

      1. 关闭监听关闭数据库查看sqlplus进程
      2. lsnrctl stop

        lsnrctl status

        sqlplus / as sysdba

        startup

        shutdown immediate

        exit

        ps -ef | grep sqlplus

su - oracle

cd /u01/app

mkdir -p /u01/app/backup

tar -pcvf /u01/app/backup/oracle_backup.tar /u01/app/oracle/

  1. 替换高版本opatch
    1. 拷贝当前Opatch目录

su - oracle

cd $ORACLE_HOME

cp OPatch -r OPatch1

cd /soft

unzip -d $ORACLE_HOME p6880880_190000_Linux-x86-64.zip

A  

cd $ORALCE_HOME/OPatch

./opatch version

刚开始的:

替换之后的:​

    1. 应用补丁

 cd /soft

ls 

unzip p35943157_190000_Linux-x86-64.zip

cd 35943157

$ORACLE_HOME/OPatch/opatch prereq -help

​​

      1. 补丁冲突检测

$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail

      1. 应用补丁

$ORACLE_HOME/OPatch/opatch apply

过程中 输入 y

      1. 检查

$ORACLE_HOME/OPatch/opatch lsinv

    1. 主库升级

      1. 目录准备

su - root

chmod -R 755 /soft

chown oracle:oinstall /soft

cd /soft

ls

      1. 备份oraclehome目录

su - oracle

cd $ORALCE_HOEM

cd ..

ls

tar -cvzf dbhome_1.tar.gz dbhome_1

      1. 关闭监听、数据库

 lsnrctl start

 lsnrctl stop

sqlplus / as sysdba

startup

shutdown immediate

exit

ps -ef | grep sqlplus

      1. 升级Opatch

cd $ORACLE_HOME

cp -R OPatch OPatch1

cd /soft

 unzip -d $ORACLE_HOME p6880880_190000_Linux-x86-64.zip

      1. 查看OPatch版本

cd $ORACLE_HOME

cd OPatch

./opatch version

      1. 解压补丁包

cd /soft

ls

unzip p35943157_190000_Linux-x86-64.zip
 

cd 35943157

$ORACLE_HOME/OPatch/opatch prereq -help

    1. 冲突检测

$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail

      1. 应用补丁

$ORACLE_HOME/OPatch/opatch apply

输入 y

$ORACLE_HOME/OPatch/opatch lsinv

      1. 主库注册前检测

cd $ORACLE_HOME/OPatch

lsnrctl start

sqlplus / as sysdba

startup upgrade

最后使用 startup upgrade 命令启动数据库并在升级模式下运行。这将启动数据库实例并将其升级到新版本,但不会打开数据库以供用户连接。

./datapatch -prereq

      1. 检查完成 注册补丁

./datapatch -verbose

      1. 编译无效对象

cd $ORACLE_HOME//rdbms/admin

sqlplus / as sysdba

SQL> @utlrp.sql

      1. 查看主库的补丁注册情况

select VERSION,VERSION_FULL from dba_registry;

完成

  • 主备库切换,完成补丁注册

    1. 主库操作p19cadg1

SQL>select name,open_mode,switchover_status from v$database;

SQL>alter system switch logfile;

SQL>alter system archive log current;

SQL>alter database commit to switchover to physical standby with session shutdown;

SQL>shutdown abort

SQL>startup mount

SQL>select switchover_status from v$database;

SQL>alter database open;

SQL>select switchover_status from v$database;      

    1. 备库操作mount状态p19cadg2

在主库启动时,备库在mount状态

sqlplus / as sysdba

SQL>startup mount

SQL>ALTER  DATABASE RECOVER MANAGED STANDBY  DATABASE DISCONNECT FROM SESSION;

SQL> alter database commit to switchover to primary;

SQL> select name,DATABASE_ROLE from v$database;

SQL> alter database open;

SQL> select name,open_mode,switchover_status from v$database;

    1. 查看当前主备库状态

主库:

SQL> select name,open_mode,switchover_status from v$database;

备库:

SQL> select name,open_mode,switchover_status from v$database;

    1. 检查新主库(原备库)补丁注册

SQL> select VERSION,VERSION_FULL from dba_registry;

  • 补丁回退流程

    1. 关闭数据库和监听
      1. 现备库(原主库p19cadg1)

关闭监听

lsnrctl stop

lsnrctl start

关闭数据库

shu immediate

exit

ps -ef | grep sqlplus

      1. 现主库(原备库p19cadg2)

关闭监听

lsnrctl stop

lsnrctl start

关闭数据库

shu immediate

exit

ps -ef | grep sqlplus

      1. 查看进程(主备)

ps -ef | grep sqlplus

只能有一个

    1. 现备库p19cadg1

su - oracle

cd $ORACLE_HOME/OPatch

./opatch rollback -id 35943157

    1. 编译无效对象

cd $ORACLE_HOME//rdbms/admin

$ sqlplus /nolog

SQL> CONNECT / AS SYSDBA

Connected.

SQL> @utlrp.sql

主库补丁回退

cd $ORACLE_HOME/OPatch

./opatch lspatches

./opatch rollback -id 35943157

    1. 主库回退注册补丁p19cadg2

      1. 注册前检查

cd $ORACLE_HOME/OPatch

lsnrctl start

sqlplus / as sysdba

startup upgrade

./datapatch -prereq

      1. 主库注册补丁p19cadg2

./datapatch -verbose

      1. 主库切换备库p19cadg2(主->备)

主p19cadg2  open状态

备p19cadg2  mount状态

SQL> select name,open_mode,switchover_status from v$database;

SQL> alter system switch logfile;

SQL> alter system archive log current;

SQL> alter database commit to switchover to physical standby with session shutdown;

SQL> shutdown abort

SQL> startup mount

SQL> select switchover_status from v$database;

SQL> alter database open;

SQL> select switchover_status from v$database;

    1. 备库切换主库p19cadg1(备->主)

SQL>ALTER  DATABASE RECOVER MANAGED STANDBY  DATABASE DISCONNECT FROM SESSION;

SQL> alter database commit to switchover to primary;

SQL> select name,DATABASE_ROLE from v$database;

SQL> alter database open;

SQL> select name,open_mode,switchover_status from v$database;

      1. 备库启用实时日历p19cadg2

SQL> alter database recover managed standby database using current logfile disconnect from session;

SQL> select name,open_mode,switchover_status from v$database;

      1. 新主库切换日志

SQL> alter system switch logfile;

SQL> archive log list

    1. 查看数据库状态

select name,open_mode,switchover_status from v$database;

      1. 检查补丁注册情况

select VERSION,VERSION_FULL from dba_registry;

完成

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值