catalog start with + switch database to copy的妙用

环境:RHEL6.4 + Oracle 11.2.0.4 Primary RAC + Standby RAC

现象:从主库恢复控制文件之后,由于是OMF管理的方式,导致ASM上存储的数据文件名字和控制文件中的名字不一样。

我们来看看现象的具体情况:

ASM上的数据文件信息:

ASMCMD [+data/mynas/datafile] > ls -l
Type Redund Striped Time Sys Name
DATAFILE UNPROT COARSE AUG 31 16:00:00 Y DBADATA.276.952933931
DATAFILE UNPROT COARSE AUG 11 21:00:00 Y DBS_D_HANK.273.951774293
DATAFILE UNPROT COARSE AUG 31 16:00:00 Y DBS_D_HANK.274.951774467
DATAFILE UNPROT COARSE AUG 31 16:00:00 Y DBS_D_JINGYU.262.951608185
DATAFILE UNPROT COARSE AUG 31 16:00:00 Y DBS_I_JINGYU.263.951608185
DATAFILE UNPROT COARSE AUG 31 16:00:00 Y SYSAUX.257.951608183
DATAFILE UNPROT COARSE AUG 31 16:00:00 Y SYSTEM.258.951608183
DATAFILE UNPROT COARSE AUG 31 16:00:00 Y TEST.264.951608185
DATAFILE UNPROT COARSE AUG 31 16:00:00 Y TEST2.260.951608185
DATAFILE UNPROT COARSE AUG 31 16:00:00 Y UNDOTBS1.259.951608185
DATAFILE UNPROT COARSE AUG 31 16:00:00 Y UNDOTBS2.261.951608185
DATAFILE UNPROT COARSE AUG 31 16:00:00 Y USERS.265.951608205
ASMCMD [+data/mynas/datafile] >

恢复的备库控制文件中的信息:

SQL> select name, database_role, open_mode from gv$database;

NAME      DATABASE_ROLE    OPEN_MODE
--------- ---------------- --------------------
JYZHAO PHYSICAL STANDBY MOUNTED SQL> select name from v$datafile; NAME
--------------------------------------------------------------------------------
+DATA/mynas/datafile/system.256.919998779
+DATA/mynas/datafile/sysaux.257.919998781
+DATA/mynas/datafile/undotbs1.258.919998783
+DATA/mynas/datafile/users.259.919998789
+DATA/mynas/datafile/undotbs2.264.919999419
+DATA/mynas/datafile/dbs_d_jingyu.268.947072261
+DATA/mynas/datafile/dbs_i_jingyu.270.947072263
+DATA/mynas/datafile/test.271.947072293
+DATA/mynas/datafile/test2.272.947072883
+DATA/mynas/datafile/dbs_d_hank.273.951758265
+DATA/mynas/datafile/dbadata.275.952933837 11 rows selected.

可以看到,虽然路径是对的,但由于OMF特性,文件名字完全不一样。

有的同学看到这里,尤其是刚刚入门的初级DBA,可能会直接想简单粗暴的直接使用rename数据文件来解决问题。

当然,这我的这个场景里,也恰巧可以用rename来解决问题,但这只是因为我这里测试环境文件少,可以容易对应起来。

而且这种方式不但容易误操作,在数据文件多的情况,有可能根本无法轻松识别出对应关系。

那应该怎么做呢?

。。。

现在换个角度来考虑,这些控制文件记录的都是不存在的文件,只是数据库认为是这些文件,而我的ASM上才是真实的数据文件,那么,

我可以把ASM上的文件都认为是数据文件的copy备份,完全可以使用RMAN的catalog start with手工将这些copy“备份”加进来,数据库会认为这些文件就只是数据文件的copy备份,然后直接switch database to copy就可以成功切换。

参考命令:

RMAN> catalog start with '+data/mynas/datafile';
RMAN> switch database to copy;

实际操作过程和结果如下:

RMAN> list copy;

using target database control file instead of recovery catalog
specification does not match any datafile copy in the repository
specification does not match any control file copy in the repository
List of Archived Log Copies for database with db_unique_name MYNAS
===================================================================== Key Thrd Seq S Low Time
------- ---- ------- - ---------
2 1 983 A 31-AUG-17
Name: +FRA/mynas/archivelog/2017_08_31/thread_1_seq_983.743.953483617 4 1 984 A 31-AUG-17
Name: +FRA/mynas/archivelog/2017_08_31/thread_1_seq_984.731.953483625 1 2 826 A 31-AUG-17
Name: +FRA/mynas/archivelog/2017_08_31/thread_2_seq_826.737.953483619 3 2 827 A 31-AUG-17
Name: +FRA/mynas/archivelog/2017_08_31/thread_2_seq_827.736.953483623 RMAN> catalog start with '+data/mynas/datafile'; Starting implicit crosscheck backup at 31-AUG-17
allocated channel: ORA_DISK_1
Crosschecked 37 objects
Finished implicit crosscheck backup at 31-AUG-17 Starting implicit crosscheck copy at 31-AUG-17
using channel ORA_DISK_1
Finished implicit crosscheck copy at 31-AUG-17 searching for all files in the recovery area
cataloging files...
cataloging done List of Cataloged Files
=======================
File Name: +fra/MYNAS/ARCHIVELOG/2017_08_31/thread_2_seq_821.628.953475515
File Name: +fra/MYNAS/ARCHIVELOG/2017_08_31/thread_1_seq_974.622.953475665
File Name: +fra/MYNAS/ARCHIVELOG/2017_08_31/thread_1_seq_757.609.953475667
File Name: +fra/MYNAS/ARCHIVELOG/2017_08_31/thread_1_seq_755.607.953475667
File Name: +fra/MYNAS/ARCHIVELOG/2017_08_31/thread_1_seq_756.598.953475667
File Name: +fra/MYNAS/ARCHIVELOG/2017_08_31/thread_1_seq_758.462.953475671
File Name: +fra/MYNAS/ARCHIVELOG/2017_08_31/thread_1_seq_759.464.953475671
File Name: +fra/MYNAS/ARCHIVELOG/2017_08_31/thread_1_seq_760.457.953475673
File Name: +fra/MYNAS/ARCHIVELOG/2017_08_31/thread_1_seq_761.456.953475677
File Name: +fra/MYNAS/ARCHIVELOG/2017_08_31/thread_1_seq_763.434.953475677
File Name: +fra/MYNAS/ARCHIVELOG/2017_08_31/thread_1_seq_762.422.953475677
File Name: +fra/MYNAS/ARCHIVELOG/2017_08_31/thread_1_seq_764.401.953475679
File Name: +fra/MYNAS/ARCHIVELOG/2017_08_31/thread_2_seq_606.384.953475815
File Name: +fra/MYNAS/ARCHIVELOG/2017_08_31/thread_2_seq_607.381.953475815
File Name: +fra/MYNAS/ARCHIVELOG/2017_08_31/thread_2_seq_605.374.953475815
File Name: +fra/MYNAS/ARCHIVELOG/2017_08_31/thread_2_seq_608.364.953475817
File Name: +fra/MYNAS/ARCHIVELOG/2017_08_31/thread_2_seq_609.357.953475817
File Name: +fra/MYNAS/ARCHIVELOG/2017_08_31/thread_2_seq_610.438.953475817
File Name: +fra/MYNAS/ARCHIVELOG/2017_08_31/thread_2_seq_611.421.953475819
File Name: +fra/MYNAS/ARCHIVELOG/2017_08_31/thread_2_seq_612.412.953475819
File Name: +fra/MYNAS/ARCHIVELOG/2017_08_31/thread_2_seq_613.393.953475819
File Name: +fra/MYNAS/ARCHIVELOG/2017_08_31/thread_2_seq_614.592.953475821
File Name: +fra/MYNAS/ARCHIVELOG/2017_08_31/thread_2_seq_822.580.953476813
File Name: +fra/MYNAS/ARCHIVELOG/2017_08_31/thread_1_seq_975.562.953476817
File Name: +fra/MYNAS/ARCHIVELOG/2017_08_31/thread_2_seq_823.551.953477803
File Name: +fra/MYNAS/ARCHIVELOG/2017_08_31/thread_1_seq_976.512.953477807
File Name: +fra/MYNAS/ARCHIVELOG/2017_08_31/thread_1_seq_977.500.953478181
File Name: +fra/MYNAS/ARCHIVELOG/2017_08_31/thread_1_seq_978.488.953478659
File Name: +fra/MYNAS/ARCHIVELOG/2017_08_31/thread_2_seq_824.476.953478659
File Name: +fra/MYNAS/ARCHIVELOG/2017_08_31/thread_1_seq_979.317.953479329
File Name: +fra/MYNAS/ARCHIVELOG/2017_08_31/thread_1_seq_980.298.953481127
File Name: +fra/MYNAS/ARCHIVELOG/2017_08_31/thread_1_seq_981.473.953481743
File Name: +fra/MYNAS/ARCHIVELOG/2017_08_31/thread_2_seq_825.475.953481753
File Name: +fra/MYNAS/ARCHIVELOG/2017_08_31/thread_1_seq_982.745.953482353
File Name: +fra/MYNAS/ARCHIVELOG/2017_08_11/thread_1_seq_171.341.951768137
File Name: +fra/MYNAS/ARCHIVELOG/2017_08_11/thread_2_seq_135.342.951768137
File Name: +fra/MYNAS/ARCHIVELOG/2017_08_30/thread_2_seq_513.634.953368985
File Name: +fra/MYNAS/ARCHIVELOG/2017_08_30/thread_2_seq_514.638.953369045 searching for all files that match the pattern +data/mynas/datafile List of Files Unknown to the Database
=====================================
File Name: +data/MYNAS/DATAFILE/SYSAUX.257.951608183
File Name: +data/MYNAS/DATAFILE/SYSTEM.258.951608183
File Name: +data/MYNAS/DATAFILE/UNDOTBS1.259.951608185
File Name: +data/MYNAS/DATAFILE/TEST2.260.951608185
File Name: +data/MYNAS/DATAFILE/UNDOTBS2.261.951608185
File Name: +data/MYNAS/DATAFILE/DBS_D_JINGYU.262.951608185
File Name: +data/MYNAS/DATAFILE/DBS_I_JINGYU.263.951608185
File Name: +data/MYNAS/DATAFILE/TEST.264.951608185
File Name: +data/MYNAS/DATAFILE/USERS.265.951608205
File Name: +data/MYNAS/DATAFILE/DBS_D_HANK.273.951774293
File Name: +data/MYNAS/DATAFILE/DBS_D_HANK.274.951774467
File Name: +data/MYNAS/DATAFILE/DBADATA.276.952933931 Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done List of Cataloged Files
=======================
File Name: +data/MYNAS/DATAFILE/SYSAUX.257.951608183
File Name: +data/MYNAS/DATAFILE/SYSTEM.258.951608183
File Name: +data/MYNAS/DATAFILE/UNDOTBS1.259.951608185
File Name: +data/MYNAS/DATAFILE/TEST2.260.951608185
File Name: +data/MYNAS/DATAFILE/UNDOTBS2.261.951608185
File Name: +data/MYNAS/DATAFILE/DBS_D_JINGYU.262.951608185
File Name: +data/MYNAS/DATAFILE/DBS_I_JINGYU.263.951608185
File Name: +data/MYNAS/DATAFILE/TEST.264.951608185
File Name: +data/MYNAS/DATAFILE/USERS.265.951608205
File Name: +data/MYNAS/DATAFILE/DBS_D_HANK.273.951774293
File Name: +data/MYNAS/DATAFILE/DBS_D_HANK.274.951774467
File Name: +data/MYNAS/DATAFILE/DBADATA.276.952933931 RMAN> switch database to copy; datafile 1 switched to datafile copy "+DATA/mynas/datafile/system.258.951608183"
datafile 2 switched to datafile copy "+DATA/mynas/datafile/sysaux.257.951608183"
datafile 3 switched to datafile copy "+DATA/mynas/datafile/undotbs1.259.951608185"
datafile 4 switched to datafile copy "+DATA/mynas/datafile/users.265.951608205"
datafile 5 switched to datafile copy "+DATA/mynas/datafile/undotbs2.261.951608185"
datafile 6 switched to datafile copy "+DATA/mynas/datafile/dbs_d_jingyu.262.951608185"
datafile 7 switched to datafile copy "+DATA/mynas/datafile/dbs_i_jingyu.263.951608185"
datafile 8 switched to datafile copy "+DATA/mynas/datafile/test.264.951608185"
datafile 9 switched to datafile copy "+DATA/mynas/datafile/test2.260.951608185"
datafile 10 switched to datafile copy "+DATA/mynas/datafile/dbs_d_hank.274.951774467"
datafile 11 switched to datafile copy "+DATA/mynas/datafile/dbadata.276.952933931" RMAN>

可以看到,数据文件都已经成功切换到正确的文件上,这时就可以了,整个过程简单、高效、不容易出错。

catalog start with + switch database to copy的妙用的更多相关文章

  1. Oracle 11g R2 RAC with ASM存储迁移--Rman copy&ASM Rebalance(一)

    ASM GROUP-Rman copy迁移 0x00--环境介绍 VMware版本:VMware12pro 主机操作系统:RHEL6.5_64 共享存储使用VMWARE创建共享磁盘文件 数据库版本:O ...

  2. rman备份恢复命令之switch(转)

    一 switch 命令1 switch命令用途更新数据文件名为rman下镜像拷贝时指定的数据文件名更新数据文件名为 set newname 命令指定的名字. 2 switch 命令使用前提条件rman ...

  3. 将文件系统数据库迁移到ASM中

    使用裸设备配置ASM实例 http://www.cnblogs.com/myrunning/p/4270849.html 1.查看我们创建的磁盘组 [oracle@std ~]$ export ORA ...

  4. 将数据库从普通文件系统迁移到ASM中

    数据库存储的是普通的文件系统,现在将数据库迁移到ASM存储中. 准备ASM环境: [oracle@kel ~]$ asmcmd ASMCMD> ls ASM/ KEL/ ASMCMD> 在 ...

  5. ocp 1Z0-043 131-205题解析

    131. Which three methods can you use to run an Automatic Database Diagnostic Monitor (ADDM) analysis ...

  6. 普通文件迁移ASM

    1.ASM Access Through FTP and HTML Using XDB Configuration 2.rman 3.dbms_file_transfer 4.11g asmcmd 利 ...

  7. OCP读书笔记(26) - 题库(ExamF)

    501.Note the output of the following query;SQL> SELECT flashback_archieve_name, status FROM dba_f ...

  8. 同一环境下新建Standby RAC库

    需求:在同一个环境下新建Standby RAC库,即和Primary RAC在相同的磁盘组. 说明:生产环境一般不建议这样配置DG,因为存储层面是相同磁盘组,灾备的实际意义不大.我这里是用作读写分离. ...

  9. ASM的备份集在文件系统上恢复测试

    背景:最近时常有客户咨询这类问题,其实很简单一个操作,但由于每个人的理解差异,也容易出现各种问题或者误解,本文主要总结下这个过程以及常遇到的问题处理. 环境:Site A(Oracle RAC 11. ...

随机推荐

  1. 关于form表单排版的技巧

    //此处说明一个对于排版表单的方法将form表单嵌套在table里,因为table是格式化的,所以就不用再手动排版了源码如下 <from action="" method=& ...

  2. log4j.properties 日志文件的详细配置说明

    一.在一个web 项目中,使用tomcat 启动通常会在控制台输出出现一个警告信息: 通常为未添加 log4j.properties文件的原因. 二.下面以一个普通的maven项目为例说明一下 1. ...

  3. samba速度调优

    本来windows上传到板子上的速度很慢 增加 socket options = TCP_NODELAY 明显上传下载速度都快了 参考: https://superuser.com/questions ...

  4. ajax post get

    1.Ajax   post 方法 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind=&qu ...

  5. hide server info

    <?php /*wamp64\bin\apache\apache2.4.18\confhttpd.conf ServerSignature On  ServerTokens Full Serve ...

  6. Linux的磁盘系统和文件系统显示的文件大小为什么不一样(du指令和ls指令的区别)

    写在前面:本博客为本人原创,严禁任何形式的转载!本博客只允许放在博客园(.cnblogs.com),如果您在其他网站看到这篇博文,请通过下面这个唯一的合法链接转到原文! 本博客全网唯一合法URL:ht ...

  7. Delphi中DLL初始化和退出处理

    来自delphibbs: zhousy_2000, 时间: 2005-09-13 13:53:00, ID: 3203484 <1>利用Unit的Initalization与Finaliz ...

  8. oracle查表技巧

    查每张表中有多少条记录 SELECT table_name,num_rows FROM user_tables order by num_rows desc; https://www.cnblogs. ...

  9. 转:Java properties | FileNotFoundException: properties (系统找不到指定的文件。)

    原文地址:https://blog.csdn.net/cor_twi/article/details/44514871 web项目 (dynamic web project ) 读取propertie ...

  10. oracle 监听报错the information provided for this listener is currently in use by other software on this computer

    use another port number: the information provided for this listener is currently in use by other sof ...