阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

RMAN异构迁移及异构DataGuard

178次阅读
没有评论

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

1、Rman 工具将 Windows 数据库迁移到 Linux 上。

rman 可以实现跨操作系统平台备份恢复,但是必须符合如下标准,且数据库版本要一致。

For Oracle Database 10g Release 2 and above releases:

Solaris x86-64 <-> Linux x86-64

HP-PA <-> HP-IA

Windows IA (64-bit) / Windows (64-bit Itanium) <-> Windows 64-bit for AMD /       

For Oracle Database 11g Release 1 and above releases (requires minimum 11.1 compatible setting):

Linux <-> Windows

另外虽然基本备份和恢复过程和同平台 rman 备份恢复无差异,但是因为跨平台不能读取 redo、archivelog 信息,所以需要原端数据库启动到 mount 状态,然后执行 rman 全备。

11g 支持 set newname for database to 可以方便的将全库数据文件进行自动重命名。

run {

  set newname for database to ‘/home/oracle/app/oracle/oradata/ora/%U’;

  restore database;

  switch datafile all;

  }

启动数据库

alter database open resetlogs;

修改 temp 表空间文件路径

SQL>alter database tempfile ‘/oradata/datafiles/ora/temp01.dbf’ drop;
 Database altered.
 SQL>alter tablespace temp add tempfile ‘/oradata/datafiles/ora/temp01.dbf’ reuse;  – 需要数据库是 open 或 open read only 状态 

修改 redo 存放路径

此时 redo 默认会放到 $ORACLE_HOME/dbs 目录中,参考《Oracle 修改 redo 日志》重新生成新的 redo 到指定位置。

失败测试记录:
记录 1;
      尝试使用关库冷备份的方法将 windows 文件直接复制到 linux 中并尝试修改文件名,从而直接拉起数据库,但是 alter database rename file 命令无法执行成功。

SQL> select name from v$datafile;

NAME

——————————————————————————–

C:\APP\ADMINISTRATOR\ORADATA\ORA\SYSTEM02.DBF

C:\APP\ADMINISTRATOR\ORADATA\ORA\SYSAUX01.DBF

C:\APP\ADMINISTRATOR\ORADATA\ORA\UNDOTBS01.DBF

C:\APP\ADMINISTRATOR\ORADATA\ORA\USERS01.DBF

C:\APP\ADMINISTRATOR\ORADATA\ORA\EXAMPLE01.DBF

SQL> alter database rename file ‘C:\APP\ADMINISTRATOR\ORADATA\ORA\SYSTEM02.DBF’  to ‘/home/oracle/app/oracle/oradata/ora/SYSTEM02.DBF’;

alter database rename file ‘C:\APP\ADMINISTRATOR\ORADATA\ORA\SYSTEM02.DBF’  to ‘/home/oracle/app/oracle/oradata/ora/SYSTEM02.DBF’

*

ERROR at line 1:

ORA-01511: error in renaming log/data files

ORA-01516: nonexistent log file, data file, or temporary file

“C:\APP\ADMINISTRATOR\ORADATA\ORA\SYSTEM02.DBF”

原因:怀疑是和跨平台文件名无法正常识别有关。
记录 2;
如果不将原库处于 mount 状态,而是直接 open 状态下备份,然后备份归档,当目标端恢复时可以成功 restore database,但是 recover database 时就无法成功,报如下错误。根据 mos 介绍这种跨平台场景下,redo、archivelog 不支持传统的方式进行介质恢复。

RMAN> recover database;

Starting recover at 23-NOV-16

using channel ORA_DISK_1

starting media recovery

channel ORA_DISK_1: starting archived log restore to default destination

channel ORA_DISK_1: restoring archived log

archived log thread=1 sequence=95

channel ORA_DISK_1: reading from backup piece /tmp/backup/a/ARCHIVE0DRLLO42_1_1.BAK

channel ORA_DISK_1: piece handle=/tmp/backup/a/ARCHIVE0DRLLO42_1_1.BAK tag=TAG20161123T205634

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

archived log file name=/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_95_925028740.dbf thread=1 sequence=95

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of recover command at 11/23/2016 21:11:20

RMAN-11003: failure during parse/execution of SQL statement: alter database recover logfile ‘/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_95_925028740.dbf’

ORA-10562: Error occurred while applying redo to data block (file# 2, block# 61511)

ORA-10564: tablespace SYSAUX

ORA-01110: data file 2: ‘/home/oracle/app/oracle/oradata/ora/data_D-ORA_TS-SYSAUX_FNO-2’

ORA-10561: block type ‘TRANSACTION MANAGED DATA BLOCK’, data object# 67714

ORA-00600: internal error code, arguments: [ktbrcl:CDLC not in CR], [228], [], [], [], [], [], [], [], [], [], []

2、跨平台 Dataguard

每种操作系统平台都有 platform_id,如

SQL>  select platform_id, platform_name from v$database;

PLATFORM_ID PLATFORM_NAME

———– —————————————————–

        13 Linux x86 64-bit

如下表中的各种 platform_id 组合可进行 Dataguard 配置,有些组合需要满足特定的条件,虽然跨平台不能将原端的归档直接在新库 recover,但是可以部署特定异构平台的 Dataguard,并实现实时同步。

PLATFORM_ID

PLATFORM_NAME
Release name

PLATFORM_IDs supported within the same Data Guard configuration when using Data Guard Redo Apply (Physical Standby)

2

Solaris[tm] OE (64-bit)
Solaris Operating System (SPARC) (64-bit)

2
6 – See Support
 Note: 1982638.1 and Note: 414043.1

3

HP-UX (64-bit)
HP-UX PA-RISC

3
4 – Oracle 10g onward, see Support
 Note: 395982.1 and Note:414043.1

4

HP-UX IA (64-bit)
HP-UX Itanium

4
3 – Oracle 10g onward, see Support Notes
 Note: 395982.1 and Note:414043.1

5

HP Tru64 UNIX
HP Tru64 UNIX

5

6

IBM AIX on POWER Systems (64-bit)

2 – See Support Note: 1982638.1 and Note: 414043.1
6

7

Microsoft Windows (32-bit)
Microsoft Windows (x86)

7
8, 12  – Oracle 10g onward, see Support
 Note: 414043.1 
10 – Oracle 11g onward, requires
 Patch 13104881 –> Fix for 13104881 Included in 12.1 
11, 13 – Oracle 11g onward, see Support
 Note: 414043.1, also requires Patch 13104881

8

Microsoft Windows IA (64-bit)
Microsoft Windows (64-bit Itanium)

7 – Oracle 10g onward, see Support Note: 414043.1
8
12 – Oracle 10g onward
11, 13 – Oracle 11g onward, requires
 Patch 13104881

9

IBM zSeries Based Linux
z/Linux

9
18 (64-bit zSeries only)

10

Linux (32-bit)
Linux x86

7 – Oracle 11g onward, requires Patch 13104881 
10
11, 13 – Oracle 10g onward, see Support
 Note: 414043.1

11

Linux IA (64-bit)
Linux Itanium

10 – Oracle 10g onward, see Support Note: 414043.1
11
13 – Oracle 10g onward
7 – Oracle 11g onward, see Support
 Note: 414043.1, also requires Patch 13104881
8, 12 – Oracle 11g onward, requires
 Patch 13104881

12

Microsoft Windows 64-bit for AMD
Microsoft Windows (x86-64)

7 – Oracle 10g onward, see Support Note Note: 414043.1
8 – Oracle 10g onward
12
11, 13 – Oracle 11g onward, requires
 Patch 13104881

13

Linux 64-bit for AMD
Linux x86-64

7 – Oracle 11g onward, see Support Note: 414043.1, also requires Patch 13104881
10 – Oracle 10g onward, see Support Note
 Note: 414043.1
11 – Oracle 10g onward
8, 12 – Oracle 11g onward, requires
 Patch 13104881
13
20 – Oracle 11g onward

15

HP Open VMS
HP OpenVMS Alpha
HP IA OpenVMS
OpenVMS Itanium

15

16

Apple Mac OS
Mac OS X Server

16

17

Solaris Operating System (x86)
Solaris Operating System (x86)

17
20 – Oracle 10g onward, see Support
 Note: 414043.1

18

IBM Power Based Linux
Linux on Power

9 (64-bit zSeries only)
18

20

Solaris Operating System (AMD64)
Solaris Operating System (x86-64)

13 – Oracle 11g onward 
17 – Oracle 10g onward, see Support
 Note: 414043.1
20

配置过程和普通 Dataguard 无差别,需要注意的是经过测试,需要将备机的 *_FILE_NAME_CONVERT 两个参数设置上,且 rman 恢复的时候直接 recover 而不要通过 set newname 的形式去指定新文件的路径,在使用 rman 进行初始化同步的时候会自动按照转换参数修改 redo 和 temp 文件的路径,否则会导致恢复后 temp 和 redo 仍然使用原 windows 路径格式,且无法手动修改。

注意事项:

SQL> alter system set DB_FILE_NAME_CONVERT=’C:\APP\ADMINISTRATOR\ORADATA\ORA\’,’/home/oracle/app/oracle/oradata/ora/’ scope=spfile;

System altered.

SQL> alter system set LOG_FILE_NAME_CONVERT=’C:\APP\ADMINISTRATOR\ORADATA\ORA\’,’/home/oracle/app/oracle/oradata/ora/’ scope=spfile;

System altered.

特别要特别以上转换参数中,windows 路径的最后一个字符应该是 \,linux 的最后一样应该是 /,否则转换后的数据文件就会是

/home/oracle/app/oracle/oradata/ora\EXAMPLE01.DBF

关于 rman 恢复的总结:

rman restore database 还原时,无论新环境的控制文件是 for standby 的还是普通的控制文件,生成的数据文件的路径并不受OMF影响.

但如果 restore 出来的控制文件是 for standby 的那 restore database 的时候如果不指定 set netname 会按照 *_file_name_convert 参数的转换值来生成数据文件、temp 文件、redo 文件等。

但如果 restore 出来的控制文件是普通的控制文件,那 restore database 的时候如果不指定 set netname,也不会按照 *_file_name_convert 参数的转换值来生成数据文件、temp 文件、redo 文件。如果是 windows 环境,会生成到 $ORALCE_HOME/dbs 目录下,文件名如:C:APPADMINISTRATORORADATAORAEXAMPLE01.DBF。

如果是 linux 则会生成到原路径下,如果路径不存在这直接报错,中断还原。

当创建好了 Dataguard 后,如果主端添加数据文件,则备端处理情况如下:

当备机设置了 db_file_name_convert 参数,并同时启动了 OMF 功能是,OMF 的优先级要高于 db_file_name_convert 参数,备机 OMF 启动的情况下会 忽略 db_file_name_convert 参数。

参考文档:

Data Guard Support for Heterogeneous Primary and Physical Standbys in Same Data Guard Configuration (文档 ID 413484.1)

RMAN DUPLICATE/RESTORE/RECOVER Mixed Platform Support (文档 ID 1079563.1)

Restore From Windows To Linux using RMAN Fails (文档 ID 2003327.1)

Dataguard DB/LOG FILE NAME CONVERT has been set but files are created in a different directory (文档 ID 1348512.1)

更多 Oracle 相关信息见 Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12

本文永久更新链接地址 :http://www.linuxidc.com/Linux/2016-11/137688.htm

正文完
星哥玩云-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-22发表,共计7188字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中