利用Oracle Data Guard完成跨平台的数据库迁移案例

本文涉及的产品
日志服务 SLS,月写入数据量 50GB 1个月
简介:     客户原本是一套单机版的Oracle 11.2.0.3.0 Database for Windows的数据库系统,客户的需求是将单机版的Oracle Database迁移到3节点的Oracle RAC Database中,并且平台变成Linux,但数据库版本不变化。

    客户原本是一套单机版的Oracle 11.2.0.3.0 Database for  Windows的数据库系统,客户的需求是将单机版的Oracle Database迁移到3节点的Oracle RAC Database中,并且平台变成Linux,但数据库版本不变化。客户希望尽可能短的停机时间。

    通常对于不跨版本的Oracle Database迁移常使用DG(Data Guard),配置好DG之后做一次switchover即可完成数据库的快速迁移,后续再进行修改IP地址等工作。

   虽然这个案例需要跨平台,但从11g开始Oracle Database支持有限制的跨平台配置DG,下面是配置异构平台DG的兼容性列表(物理Standby)


   从上面的兼容性列表可以看出,Microsoft Windows (x86_64)(12) 和Linux x86_64(13)能够兼容构建异构平台的DG,但需要注意的是Oracle Database 需要是11g,并且需要应用Patch 13104881,该Patch只存在于Linux平台,并且只在Windows(主库)向Linux(备库)同步时,需要在Linux平台应用此补丁(反向不会遇到相应的bug),更多内容请参考Patch 13104881说明。

有关在异构平台搭建ADG的详细内容请参考文章:《 在物理 Data Guard 中对异构主备系统的支持 (Doc ID 1602437.1)

   确认现有的平台和新平台之间能够搭建DG之后,那么剩下的问题就是如何将单机Database转换成RAC Database,这步实际需要在将Linux平台的备库转换成主库之后进行的,下面描述的是整个迁移大致的 步骤:

1.在新环境下 安装Oracle Grid Infrastructure集群件。

2.在新环境下 安装Oracle RAC Database软件。

3.创建ASM磁盘组,配置好监听程序。

4.在RAC的第一个节点 创建Windows到Linux的ADG(使用第一个节点的VIP地址, 配置成实时同步模式) ,并直接将控制文件、数据文件、日志文件等存放到共享的ASM磁盘组。
   <<<< 由于是配置Windows到Linux的DG,肯定涉及到DB _FILE_NAME_CONVERT和 LOG_FILE_NAME_CONVERT参数的设置,这两个参数需要重启数据库实例才能生效, 需要注意的是,从主库到备库的duplicate操作,对目录的转换实际是由备库中的这两个参数设置来控制的,所以在前期配置阶段可以不为主库设置这两个参数,这就意味着即使在跨平台的环境中主库也可以在不重启的情况下完成DG的配置(除了这两个参数外的其他大部分DG参数都不需要重启便可生效)。

   <<<<  LOG_FILE_NAME_CONVERT参数的值一定要包含所有在线Redo日志,standby Redo日志的目录的转换。DB_FILE_NAME_CONVERT参数的值一定要包含所有数据文件和临时文件目录的转换。例如:
LOG_FILE_NAME_CONVERT='+DATA01/dbm/onlinelog/','+DATA_DM01/dbm/onlinelog/','+FRA01/dbm/onlinelog/','+DBFS_DG/dbm/onlinelog/'
DB_FILE_NAME_CONVERT='+DATA01/dbm/datafile/','+DATA_DM01/dbm/datafile/','+DATA01/dbm/tempfile/','+DATA_DM01/dbm/tempfile/'
LOG_FILE_NAME_CONVERT和DB_FILE_NAME_CONVERT两个参数的值的最后都要加上/斜杠。
对DB_FILE_NAME_CONVERT的参数设置除了考虑到数据文件外,还需要考虑到临时文件的位置,特别是ASM的时候,OMF管理设置数据文件为datafile目录,临时文件为tempfile,不能只指定磁盘组的名字,一定要指定到具体的绝对路径。

   <<<< 另外还需要注意着两个参数值的配置,假设有A库(主库)和B库(备库),在A库配置的这两个参数的值应该='B库位置','A库位置',在B库配置的这两个参数的值应该='A库位置','B库位置',切不可搞反了。

   <<<< 如果DG配置完成后,日志传输服务没有正常工作,可以考虑执行alter system set  log_archive_dest_state_2=defer;alter system set  log_archive_dest_state_2=enable;的方式禁用再启用远程目录传输。

   <<<< 再做单机版主库到备库的的DG的时候,最好将 ORACLE_SID环境变量,instance_name和db_unique_name 配置为相同的值,之后再进行调整。

5.将备库转换为主库(可以做Switchover操作,也可以在确保主备库实时同步的前提下 直接关闭主库,将备库激活成为可读可写的数据库)。

6.执行下面的步骤将单机版的数据库转换为RAC数据库:

4) Take a backup of original single-instance pfile to e.g. /tmp/initorcl.ora and Add the following entry in pfile, e.g. for a two node RAC cluster

*.cluster_database = TRUE
*.cluster_database_instances = 2
*.undo_management=AUTO
.undo_tablespace=undotbs (undo tablespace which already exists)
.instance_name=
.instance_number=1
.thread=1
.local_listener=_
.instance_name=
.instance_number=2
.local_listener=_
.thread=2
.undo_tablespace=UNDOTBS2
.cluster_database = TRUE
.cluster_database_instances = 2 
 

is equal to "1". is equal to "2", e.g. ORCL1, ORCL2.


5) change the location of control file in parameter file

local drive to shared cluster file system location

ie control_files='/control01.ctl'

to ie control_files='/control01.ctl'

6) create spfile from pfile( spfile should be stored in shared device)

export ORACLE_SID=ORCL1
sqlplus "/ as sysdba"
create spfile='/spfileORCL.ora' from pfile='/tmp/initORCL.ora';
exit

7) Create the $ORACLE_HOME/dbs/init.ora e.g. initORCL1.ora file that contains the following entry

spfile='spfile_path_name'

spfile_path_name is the complete path name of the SPFILE.

example :-

spfile='/cfs/spfile/spfileORCL1.ora'

8) create new password file for ORCL1 instance.

orapwd file=orapwORCL1 password=oracle

9) start the database in mount stage

10) Rename the datafile,redo logs to new shared device

alter database rename file '' to '<new shared="" location="" path';=""
11) Add second instance redo logs (or more when multiple instances will be started)

alter database
add logfile thread 2
group 3 ('<shared location="" redo2_01_100.dbf')="" size="" 100m,="" group 4 ('<shared location="" redo2_02_100.dbf')="" size="" 100m;=""
alter database enable public thread 2;


12) create the second (or more) instance undo tablespace from existing instance

Path and file name will different for your environment


CREATE UNDO TABLESPACE UNDOTBS2 DATAFILE
'/dev/RAC/undotbs_02_210.dbf' SIZE 200M ;


13) Open your database (i.e. alter database open;) and run $ORACLE_HOME/rdbms/admin/catclust.sql to create cluster database specific views within the existing instance


2. On the second node and other nodes

14) Set ORACLE_SID and ORACLE_HOME environment variables on the second node

15) Create the $ORACLE_HOME/dbs/init.ora e.g. initORCL2.ora file for the second node the same way as with point 7.

16) create new password file for second instance ORCL2 instance as in point 8

orapwd file=orapwORCL2 password=oracle

17) Start the second Instance

3. on one of the nodes

18) After configuring the listener,you have to add the database in cluster as below

srvctl add database -d -o -p

srvctl add instance -d -i -n

srvctl add instance -d -i -n

19) in case ASM is used, add the rdbms instance / asm dependency, e.g.

srvctl modify instance -d -i -s <+ASM1>

    整个单机到RAC的转换过程时间并不长,提前测试和准备好初始化参数文件、执行脚本将进一步缩短这部分时间。

   更多单机Database转换为RAC Database的内容请参考文章 How to Convert 10g Single-Instance database to 10g RAC using Manual Conversion procedure (Doc ID 747457.1) 》,该文章适用于10g+的数据库。

完成单机到RAC的转换后,后续完成调整DG参数,调整IP地址等工作即完成了数据库的跨平台迁移和从单机到RAC的转换工作。

--end--
相关实践学习
日志服务之使用Nginx模式采集日志
本文介绍如何通过日志服务控制台创建Nginx模式的Logtail配置快速采集Nginx日志并进行多维度分析。
相关文章
|
2天前
|
Oracle 安全 关系型数据库
|
2天前
|
存储 Oracle 关系型数据库
关系型数据库Oracle运行RMAN脚本
【7月更文挑战第23天】
10 4
|
2天前
|
监控 Oracle 算法
|
4天前
|
Oracle 关系型数据库 Unix
关系型数据库Oracle设置环境变量:
【7月更文挑战第22天】
18 4
|
2天前
|
Oracle 关系型数据库 数据库
关系型数据库Oracle编写RMAN脚本
【7月更文挑战第23天】
10 2
|
4天前
|
Oracle 关系型数据库 数据库
关系型数据库Oracle执行RMAN脚本
【7月更文挑战第22天】
14 2
|
4天前
|
Oracle 关系型数据库 数据库连接
|
20天前
|
存储 关系型数据库 MySQL
探索MySQL:关系型数据库的基石
MySQL,作为全球最流行的开源关系型数据库管理系统(RDBMS)之一,广泛应用于各种Web应用、企业级应用和数据仓库中
|
18天前
|
缓存 运维 关系型数据库
数据库容灾 | MySQL MGR与阿里云PolarDB-X Paxos的深度对比
经过深入的技术剖析与性能对比,PolarDB-X DN凭借其自研的X-Paxos协议和一系列优化设计,在性能、正确性、可用性及资源开销等方面展现出对MySQL MGR的多项优势,但MGR在MySQL生态体系内也占据重要地位,但需要考虑备库宕机抖动、跨机房容灾性能波动、稳定性等各种情况,因此如果想用好MGR,必须配备专业的技术和运维团队的支持。 在面对大规模、高并发、高可用性需求时,PolarDB-X存储引擎以其独特的技术优势和优异的性能表现,相比于MGR在开箱即用的场景下,PolarDB-X基于DN的集中式(标准版)在功能和性能都做到了很好的平衡,成为了极具竞争力的数据库解决方案。
|
18天前
|
关系型数据库 MySQL 网络安全
Mysql 数据库主从复制
在MySQL主从复制环境中,配置了两台虚拟机:主VM拥有IP1,从VM有IP2。主VM的`my.cnf`设置server-id为1,启用二进制日志;从VM设置server-id为2,开启GTID模式。通过`find`命令查找配置文件,编辑`my.cnf`,在主服务器上创建复制用户,记录二进制日志信息,然后锁定表并备份数据。备份文件通过SCP传输到从服务器,恢复数据并配置复制源,启动复制。检查复制状态确认运行正常。最后解锁表,完成主从同步,新用户在从库中自动更新。
993 7
Mysql 数据库主从复制

推荐镜像

更多