我是靠谱客的博主 尊敬冰棍,最近开发中收集的这篇文章主要介绍RMAN2:异机完全恢复,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

阶段1:准备

1.1 传送备份文件

目标服务器建目录/u01/app/oracle/rmanbak

#mkdir –p /u01/app/oracle/rmanbak

#scp -r /u01/app/oracle/rmanbak 192.168.56.113: /u01/app/oracle/rmanbak/

1.2 确认备份集中的重要文件

# ps -ef|grep pmon

获得实例名 orcl

RMAN> list backup of spfile;       --参数文件

记下Piece Name: /u01/app/oracle/rmanbak/rman_incr_ORCL_4511d06vt02.bak

RMAN> list backup of controlfile;   --控制文件

Piece Name: /u01/app/oracle/rmanbak/rman_incr_ORCL_4411c06vt02.bak

阶段2:恢复参数文件

注:目标服务器的实例名 需要 与源库的实例名一致。

2.1 新建参数文件pifle

#cd  /u01/app/oracle/product/11.0.2/db_1/dbs

#vi initorcl.ora     内容上只需要输入 db_name=orcl 即可保存退出

2.2 从备份集生成pfile

# export ORACLE_SID=orcl     --实例名 应 与源库实例名一致,如源库为RAC则取源库的db_unique_name,如果实例名要不一致,则用nid 命令修改

SQL> startup nomount

RMAN> restore spfile to pfile '/u01/app/oracle/product/11.0.2/db_1/dbs/initorcl.ora' from '/u01/app/oracle/rmanbak/rman_incr_ORCL_4511d06vt02.bak';

2.3 修改参数文件(由于源库为RAC,目标库为单例)

#vi /u01/app/oracle/product/11.0.2/db_1/dbs/initorcl.ora

内容如下:

*.audit_file_dest='/u01/app/oracle/admin/orcl/adump'

*.audit_trail='db'

*.compatible='11.2.0.4.0'

*.control_files='/u01/app/oracle/oradata/orcl/control01.dbf','/u01/app/oracle/oradata/orcl/control02.dbf'

*.db_block_size=8192

*.db_domain=''

*.db_name='orcl'

*.diagnostic_dest='/u01/app/oracle'

*.dispatchers='(PROTOCOL=TCP) (SERVICE=orcl1XDB)'

*.log_archive_dest_1='LOCATION=/u01/archive'

*.log_archive_format='arch%t_%s_%r.log'

*.memory_target=786432000

*.open_cursors=300

*.processes=800

*.remote_login_passwordfile='exclusive'

*.sessions=885

*.undo_tablespace='UNDOTBS1'

2.4 重载参数文件

SQL> shutdown immediate

SQL> create spfile from pfile;
SQL> startup nomount

阶段3:恢复控制文件并注册备份集

3.1 从备份集生成控制文件

RMAN> restore controlfile from ‘/u01/app/oracle/rmanbak/rman_incr_ORCL_4411c06vt02.bak’;

3.2 将备份集注册进控制文件里

RMAN> catalog start with ‘/u01/app/oracle/rmanbak/’;

若有提示

Do you really want to catalog the above files (enter YES or NO)?

输入yes

RMAN> list backup;  --查看注册后备份集个数

RMAN> list backup of archivelog all;  --查看注册后归档日志个数

阶段4:修正数据文件、联机日志文件、临时文件路径

查询当前数据文件、临时文件、联机日志

SQL> set linesize 200;

SQL> col name for a80;

SQL> select file#,name from v$datafile;

SQL> select file#,name from v$tempfile;

SQL> select member from v$logfile;

数据文件、临时文件改名

RMAN> run{

set newname for datafile 1 to '/u01/app/oracle/oradata/orcl/system.dbf';

set newname for datafile 2 to '/u01/app/oracle/oradata/orcl/undotbs1.dbf';

set newname for datafile 3 to '/u01/app/oracle/oradata/orcl/users.dbf';

set newname for datafile 4 to '/u01/app/oracle/oradata/orcl/undotbs2.dbf';

set newname for datafile 5 to '/u01/app/oracle/oradata/orcl/crm.dbf';

set newname for datafile 6 to '/u01/app/oracle/oradata/orcl/sysaux.dbf';

set newname for datafile 7 to '/u01/app/oracle/oradata/orcl/crm2.dbf';

set newname for datafile 8 to '/u01/app/oracle/oradata/orcl/test1.dbf';

set newname for tempfile 1 to '/u01/app/oracle/oradata/orcl/temp.dbf';

RESTORE DATABASE;

SWITCH DATAFILE ALL;   

SWITCH TEMPFILE ALL;

}

说明:SWITCH DATAFILE ALL; SWITCH TEMPFILE ALL;--修改结果同步到控制文件

联机日志改名

SQL> alter database rename file '+DATA/orcl/onlinelog/group_2.262.1080990111' to '/u01/app/oracle/oradata/orcl/redo2_1.log';

SQL> alter database rename file '+ARCH/orcl/onlinelog/group_2.259.1080990113' to '/u01/app/oracle/oradata/orcl/redo2_2.log';

SQL> alter database rename file '+DATA/orcl/onlinelog/group_1.261.1080990109' to '/u01/app/oracle/oradata/orcl/redo1_1.log';

SQL> alter database rename file '+ARCH/orcl/onlinelog/group_1.258.1080990109' to '/u01/app/oracle/oradata/orcl/redo1_2.log';

SQL> alter database rename file '+DATA/orcl/onlinelog/group_3.265.1080990115' to '/u01/app/oracle/oradata/orcl/redo3_1.log';

SQL> alter database rename file '+ARCH/orcl/onlinelog/group_3.260.1080990115' to '/u01/app/oracle/oradata/orcl/redo3_2.log';

SQL> alter database rename file '+DATA/orcl/onlinelog/group_4.266.1080990117' to '/u01/app/oracle/oradata/orcl/redo4_1.log';

SQL> alter database rename file '+ARCH/orcl/onlinelog/group_4.261.1080990119' to '/u01/app/oracle/oradata/orcl/redo4_2.log';

阶段5:恢复并打开数据库

RMAN> recover database;
备注:可能会提示RMAN-06054: media recovery requesting unknown archived log for thread 2 with sequence 508 and starting SCN of 121279435
直接忽略即可

SQL> alter database open resetlogs;

验证结果:略

最后

以上就是尊敬冰棍为你收集整理的RMAN2:异机完全恢复的全部内容,希望文章能够帮你解决RMAN2:异机完全恢复所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(52)

评论列表共有 0 条评论

立即
投稿
返回
顶部