首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

Oracle 数据库跨版本升级迁移实践

实施背景

今年春节加班期间,将某客户的核心数据库从 Oracle 10.2.0.4 RAC 迁移升级至 12.2 RAC。原库是使用的 Raw,而且版本较低,无法直接升级到 12.2 版本,因此整个升级过程相对麻烦。

实施思路

我们在新环境部署了10g、11.2、12.2 的 Database 软件(其中 10g,11.2 均为单机,12.2 为已经安装好的 Oracle RAC 环境);

然后配置好主库到新环境的 DataGuard 数据同步,在正式割接之前确认主备同步正常。由于需要将数据库从 10gR2 迁移到新环境并且升级到 12.2,且需要使用 CDB 模式,因此整个过程相对繁琐。

如下是大致步骤:

1. 停止 Job(将 job_queue_processes 参数提前置为0,并 kill 相关进程);

2. 检查分布式事务,并进行相关处理(实际上我们检查确实发现了部分分布式事务需要手工介入);

select ' exec DBMS_TRANSACTION.PURGE_LOST_DB_ENTRY('||chr(39)||LOCAL_TRAN_ID||chr(39)||');'||chr(10)||'commit;'

from dba_2pc_pending;

3. 在确认主备数据同步之后,进行 switchover,如下是主备切换简约步骤:

--主库

alter database commit to switchover to physical standby WITH SESSION SHUTDOWN;

startup mount;

alter database open read only;

--备库

alter database commit to switchover to primary;

startup force

4. 新主库升级到 11.2 之前需要先创建还原点,防止有问题可以回退;

alter database flashback on;?

alter database open;

alter system switch logfile;

create restore point restore_point_10g guarantee flashback database;?

5. 执行升级脚本,将数据库升级到 11.2;

6. 确认升级成功之后,drop 还原点并创建新的还原点,准备将数据库升级到 12.2;

drop restore point restore_point_10g;

create restore point restore_point_11g guarantee flashback database;?

这里需要注意的是,在升级到 12.2 之前需要将实例参数 compatible 设置为11.2.0.4,否则在升级过程中可能会遭遇 ORA-00600 错误。

7. 执行升级脚本将数据库升级到 12.2;

@/home/oracle/shell/log/preupgrade_fixups.sql

$ORACLE_HOME/perl/bin/perl -I $ORACLE_HOME/perl/lib $ORACLE_HOME/rdbms/admin/catctl.pl -n 8 $ORACLE_HOME/rdbms/admin/catupgrd.sql

@/home/oracle/shell/log/postupgrade_fixups.sql

8. 确认升级后数据库组件正常且无相关报错之后,drop 还原点;

select comp_name,VERSION,STATUS from dba_registry;

drop restore point restore_point_11g;

9. 数据库升级到 12.2 之后,需要将 DB 从 NO-CDB 模式转换成 CDB 模式,将数据库作为 PDB 插入到 12.2 RAC 集群中;

如下是转 CDB 模式是相关简单步骤:

1)启动实例到只读模式

startup mount exclusive?;

alter database open read only;

2)创建 xml 元数据文件

EXEC DBMS_PDB.DESCRIBE( pdb_descr_file => '/tmp/XXXDB.xml');

3)检查兼容性

DECLARE

compatible CONSTANT VARCHAR2(3) :=

CASE

DBMS_PDB.CHECK_PLUG_COMPATIBILITY(pdb_descr_file => '/tmp/XXDB.xml',pdb_name => 'xxdb')

WHEN TRUE THEN 'YES'

ELSE 'NO'

END;

BEGIN

DBMS_OUTPUT.PUT_LINE(compatible);

END;

/

4)进行 nocopy 操作

CREATE PLUGGABLE DATABASE pdbcdrs USING '/tmp/XXDB.xml' NOCOPY;

5) 启动 PDB 进行并进行转换

alter session set container= pdbcdrs;?

alter pluggable database pdbcdrs open;

shutdown immediate?;

@$ORACLE_HOME/rdbms/admin/noncdb_to_pdb.sql

10. 创建 Redo、Undo 以及修改相应参数,将数据库转成 RAC 实例。

问题讨论

在整个升级过程中,我们遇到了几个小问题,分别如下:

1. DataGuard 的文件 convert 参数没有加入 tempfile,导致 DG 切换之后,主库 open 有问题,需要先 drop tempfile 之后才行;

2. 在升级到 12.2 的过程中,遇到 ORA-01722 错误,如下所示:

set serveroutput on

@?/rdbms/admin/catuptabdata.sql

@?/rdbms/admin/utluptabdata.sql

execute dbms_preup.run_fixup_and_report('INVALID_SYS_TABLEDATA');

execute dbms_preup.run_fixup_and_report('INVALID_USR_TABLEDATA');

set serveroutput off

3. 将数据库作为 PDB 插入到 CDB 之后,打开 PDB 时提示为受限模式。

该问题经查是由于我们在执行的过程中漏掉了一个步骤(exec dbms_pdb.sync_pdb();),导致 PDB 的信息与 CDB 的信息不一致,本质上组件信息不一致。

该文档中有详细的描述,认为这是 12.2 的一个加强。

Some warnings in PDB_PLUG_IN_VIOLATIONS prevent you from actually opening the PDB in READ WRITE mode; this is not one of them. You can ignore these messages. It is okay for a PDB to have a subset (fewer) options installed than the CDB into which it is plugged.

(The reverse is NOT true, however -- the CDB must always have the same or more options as its PDBs).

Unpublished Bug 16192980 : NO SIMPLE WAY TO CLEAN ROWS FROM PDB_PLUG_IN_VIOLATIONS AFTER DBMS_PDB CALL has been filed to request a way to clear out no-impact warnings from PDB_PLUG_IN_VIOLATIONS. This enhancement is implemented in versions > 12.2.0.1.

我们尝试过将组件 Reinstall 然后再 Install 是可以的,但是组件较多,大约8个组件,尤其是 Java 或 xdb 相关组件比较麻烦,因此我们将 PDB 删除然后重新创建了 PDB 进行加载,最终解决了该问题。

总的来接,整个过程遇到了几个小问题,但是还算顺利!

参考文档:

PDB Opens up in Restricted mode after migrating from Non-CDB To CDB environment (Doc ID 2202516.1)

PDB does not come out of Restricted Mode due to ORA-959 in PDB_PLUG_IN_VIOLATIONS (Doc ID 2167662.1)

PDB Is Always In Restricted Mode (Doc ID 1933110.1)

PDB in Restrict Mode Causes Issues (Doc ID 1949188.1)

Pluggable Databases Opened in Restricted Mode After PSU Patching (Doc ID 2225006.1)

资源下载

关注公众号:数据和云(OraNews)回复关键字获取

‘2017DTC’,2017 DTC 大会 PPT

‘DBALIFE’,“DBA 的一天”海报

‘DBA04’,DBA 手记4 经典篇章电子书

‘RACV1’, RAC 系列课程视频及 PPT

‘122ARCH’,Oracle 12.2 体系结构图

‘2017OOW’,Oracle OpenWorld 资料

‘PRELECTION’,大讲堂讲师课程资料

  • 发表于:
  • 原文链接http://kuaibao.qq.com/s/20180228A006WV00?refer=cp_1026
  • 腾讯「腾讯云开发者社区」是腾讯内容开放平台帐号(企鹅号)传播渠道之一,根据《腾讯内容开放平台服务协议》转载发布内容。
  • 如有侵权,请联系 cloudcommunity@tencent.com 删除。

扫码

添加站长 进交流群

领取专属 10元无门槛券

私享最新 技术干货

扫码加入开发者社群
领券
http://www.vxiaotou.com