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

32次阅读
没有评论

共计 4726 个字符,预计需要花费 12 分钟才能阅读完成。

丸趣 TV 小编给大家分享一下如何利用 Oracle Data Guard 完成跨平台的数据库迁移案例,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

    客户原本是一套单机版的 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 的转换过程时间并不长,提前测试和准备好初始化参数文件、执行脚本将进一步缩短这部分时间。

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

以上是“如何利用 Oracle Data Guard 完成跨平台的数据库迁移案例”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注丸趣 TV 行业资讯频道!

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-07-24发表,共计4726字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)