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. ubuntu16.04安装kinetic调用gazebo_control解决方案

    解决方案 sudo apt-get install ros-kinetic-gazebo-ros-control

  2. SET ARITHABORT {ON | OFF}讲解

    SET ARITHABORT {ON | OFF} 在查询处理过程中如果出现溢出错误或把零作为除数则查询处理是否该终止如 果为ON 则表示终止查询如果为OFF 则表示返回一个警告信息对于进行算术运 算 ...

  3. 蓝桥杯 入门训练 Fibonacci数列 解析

    问题描述 Fibonacci数列的递推公式为:Fn=Fn-1+Fn-2,其中F1=F2=1. 当n比较大时,Fn也非常大,现在我们想知道,Fn除以10007的余数是多少. 输入格式 输入包含一个整数n ...

  4. 如何辨别高潜牛人的六个方法,据说源自500强HR

    如果你是一名领导,当老板派下来任务让你招人的时候,你有考虑过怎么招到合适的人么?今天,架构师米洛特意分享一篇优秀的网络文章,据说来自500强的HR,希望对你招人有所帮助. 如何识人是HR及管理者重要的 ...

  5. azkaban---visualize crontab--frontail

    azkaban---visualize crontab azkaban--docker-----http://www.jkeabc.com/254015.html azkaban--tips   ht ...

  6. mvc 使用Newtonsoft.Json进行序列化json数据

    mvc 使用Newtonsoft.Json进行序列化json数据 JsonResult  使用js 序列号化,先集成扩展.使用newtonsoft http://blog.csdn.net/zhang ...

  7. [development][C] C语言标准

    GUN C的标准文档: 也就是glibc https://www.gnu.org/software/libc/ http://man7.org/linux/man-pages/dir_section_ ...

  8. TMS WEB Core v1.2预览版:新的Electron应用程序支持

    2019年2月20日,星期三 几个月前,我们已经开始与Electron进行实验.在工作概念验证之后,我们的目标是为Delphi开发人员尽可能多地包装Electron API.但当然不仅仅是可以使用的E ...

  9. mysql 内置功能目录

    mysql 内置功能 视图介绍 mysql 内置功能 视图 使用 mysql 内置功能 触发器介绍 mysql 内置功能 触发器 实验 mysql 内置功能 事务 介绍 mysql 内置功能 存储过程 ...

  10. CentOS安装Docker CE

    安装Docker CE(免费版) docker EE企业版您可以根据需要以不同方式安装Docker CE: 大多数用户 设置Docker的存储库并从中进行安装,以便于安装和升级任务.这是推荐的方法. ...