RMAN-使用catalog恢复目录进行备份与恢复

时间:2021-05-04 09:04:39

RMAN Architecture
The RMAN architecture, shown in Figure 7-3, includes a target database, repository, and Media Management Layer, as well as Server Processes, Channels, Backup Sets, and Backup Pieces. The target database is the database that is either being backed up or restored. RMAN connects to the target database using server sessions. The repository is a separate database or schema that contains the metadata about your target database, as well as all of the backup and recovery information connected with that database for maintenance purposes. It can keep track of all of the information about every backup that you perform, including all of the file information, the time of the backup, and the database incarnation (the database version) at the time of the backup. This information can all be used to restore files and recover the database by issuing very simple restore and recovery commands. All of the information needed to complete these operations is stored in the repository. This repository can be implemented in one of two ways:
■ By using control files
■ As a recovery catalog database
Control files are the default option for implementing a repository since backup information is written to control files making the recovery catalog optional. Using a control file, however, limits the functionality of RMAN, while a recovery catalog provides you with the use of all RMAN features (this option is strongly recommended). Some of the advantages that a recovery catalog gives include the following:
■ The catalog will store the physical structure of the target database, as well as backups of data files, control files, and archive logs.
■ You can store scripts of common tasks.
■ Multiple databases can be managed from one location.
■ Complete reporting capabilities
■ Access to a longer history of backups and metadata
■ Ability to perform recovery when control files are lostA complete set of options when you try to restore from previous backup sets
■ More recovery flexibility and options
One disadvantage of using an RMAN recovery is that it needs to be managed itself. However, this is a small database or schema, so maintenance is minimal. Also, one RMAN catalog can manage multiple databases. Backups can be performed easily through a hot backup or database export. You also need to keep the recovery catalog in sync with the control files, which is performed with the RMAN-provided resync command.

1、Set Up a Recovery Catalog and Target Database
Setting up a recovery catalog is a very simple process. This can be done through the Enterprise Manager GUI or through some simple commands in SQL*Plus and the RMAN command-line interface. In SQL*Plus, all you need to do is to create a tablespace to store the catalog data in, create an RMAN user, and then grant the 
recovery_catalog_owner role to the RMAN user. In RMAN, run the  create     catalogstatement:  (使用恢复目录对数据库进行备份,以sys连接到rman实例,创建数据表空间,创建rcat用户并授权)以下测试时单独新建了一个实例rman,也可以不用新建,跟目标数据库使用同一个实例。

SQL> conn sys/rman@rman as sysdba;--最好单独创建一个新的实例rman,并使用sys用户连接到rman
已连接。
SQL> create tablespace rcatts datafile 'D:\rman\rman_data\rcatts.dbf' size 1024M; 表空间已创建。 SQL> create user rcat identified by rcat temporary tablespace temp
2 default tablespace rcatts quota unlimited on rcatts; 用户已创建。 SQL> grant connect, resource, recovery_catalog_owner to rcat; 授权成功。 SQL> exit
从 Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 断开 C:\Users\Administrator>

2、In the RMAN command-line interface, log in and create the catalog:

(使用上一步创建的rcat用户登录并创建恢复目录)

C:\Users\Administrator>rman catalog=rcat/rcat@rman;

恢复管理器: Release 11.2.0.1.0 - Production on 星期二 10月 7 23:52:05 2014

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

连接到恢复目录数据库

RMAN> create catalog;

恢复目录已创建

RMAN>

3、把目标数据库注册到恢复目录catalog中

Now you need to register the target database in the catalog. To do this, connect to the target and the catalog database and then register the target database in the catalog. This can be done from either location. The target connection must have a user ID with sysdba privileges, so an Oracle password file must be created using the orapwd utility. As described in Chapter 3, you also need to create the Oracle networking configuration using tnsnames or an equivalent for both the target and recovery catalog instances:

RMAN> connect catalog rcat/rcat@rman;--连接到恢复目录数据库

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-06167: 已经连接 RMAN> connect target rusky/rusky@orcl;--连接目标数据库orcl,用户为rusky,密码为rusky 连接到目标数据库: ORCL (DBID=1385990360) RMAN> register database; 注册在恢复目录中的数据库
正在启动全部恢复目录的 resync
完成全部 resync RMAN>

4、It’s now time to back up your entire database

连接恢复目录,连接目标数据库

C:\Users\Administrator>rman target rusky/rusky@orcl catalog rcat/rcat@rman;

恢复管理器: Release 11.2.0.1. - Production on 星期日 10月  :: 

Copyright (c) , , Oracle and/or its affiliates.  All rights reserved.

连接到目标数据库: ORCL
连接到恢复目录数据库 RMAN>

备份数据库。

RMAN> configure default device type to disk;--可不用指定,使用默认。可使用show all 查看configure参数
RMAN> configure controlfile autobackup on;--默认值off,一般设置为on,即备份目标数据库的同时备份控件文件
RMAN> backup database plus archivelog;--备份数据库库的同时备份归档文件。如果想单独备份归档文件,可使用命令:backup archivelog all;
RMAN> exit;

5、上一步数据库已完全备份成功,可设置一个恢复的环境,如可关闭数据库并且删除所有的数据文件、归档日志、控制文件、参数文件等。

To do this, shut down the database and delete all of the data files, archive logs, control files, and the spfile SPFILEORA11G.ora for the target database.
6、恢复数据库
重新连接到恢复目录和目标数据库,并将数据库置于nomount状态。

RMAN> connect catalog rcat/rcat@rman;
RMAN> connect target rusky/rusky@orcl;
RMAN> startup nomount;
RMAN> restore archivelog all;
RMAN> restore controlfile; --resotrer控制文件、参数文件、归档日志文件只能在nomount状态。
RMAN> alter database mount;
RMAN> restore database;--restore数据文件要先mount
RMAN> recover database;
RMAN> alter database open resetlogs;

7、其它相关操作

(1) 在rman提示符下来验证成功注册的数据库。
RMAN>Report Schema;
(2) 删除恢复目录
如同可以创建恢复目录模式,你也可以删除恢复目录模式。使用drop catalog命令可以删除恢复目录模式。当删除恢复目录模式,包含在模式中的所有信息都会丢失,因此在删除模式之前应该考虑备份恢复目录模式数据库。两次drop catalog
RMAN> drop catalog;

恢复目录所有者是RMAN
再输入一次 DROP CATALOG 命令来确认目录删除

RMAN> drop catalog;

恢复目录已删除

RMAN>
(3) 恢复目录中取消数据库注册
可在RMAN中使用unregister database命令来取消数据库注册。如果希望取消已存在的数据库注册,只要连接到数据库和恢复目录,并执行unregister database命令即可:
RMAN>unregister database;

如果数据库已删除,并且希望从恢复目录中删除该数据库,则大多数情况下只需要知道希望取消注册的数据库的名称。如希望取消注册orcl数据库实例。则可连接到恢复目录执行以下命令:
RMAN>Unregister database orcl;

8、恢复目录的备份

恢复目录本身也需要做备份,恢复目录的备份只能使用exp/imp导出导入方式进行备份。

RMAN不能用于备份初始化参数文件和口令文件。

9、更新恢复目录
为了支持更新的RMAN客户端,例如RMAN恢复目录版本是10g,而新的RMAN客户端是11G,使用upgrade catalog命令更新本地包和模式,与drop catalog一样,需要连接到恢复目录,但是无需连接到目标数据库:
RMAN> upgrade catalog;

恢复目录所有者是RCAT
再输入一次 UPGRADE CATALOG 命令来确认目录升级

RMAN> upgrade catalog;

恢复目录已升级到版本11.02.00.01
DBMS_RCVMAN 程序包升级为 11.02.00.01 版
DBMS_RCVCAT 程序包升级为 11.02.00.01 版

RMAN>

==============RMAN-catalog和nocatalog的区别====================================

注意,当使用rman nocatalog恢复时,数据库必须是处于“mount”状态的。而Oracle startup mount的前提条件是control必须存在。因此,你必须在恢复datafile之前先恢复controlfile。 使用rman catalog方式时,可以startup nomount然后restore controlfile;但使用rman nocatalog时,必须先用文件方式恢复controlfile。

下面对比一下rman nocatalog和rman catalog的恢复时的步骤,以便建立正确的备份策略(以下的恢复都是在online状态下的备份):
rman nocatalog恢复:
1) 建立oracle运行环境(包括init或sp文件)
2) 文件方式恢复controlfile到init文件指定的位置
3) startup mount
4) rman,恢复datafile
5) alter database open resetlogs

rman catalog恢复:
1) 建立oracle运行环境(包括init或sp文件)
2) rman ,restore controfile
3) alter database mount
4) rman, restore datafile
5) alter database open resetlogs

可以看出,rman nocatalog备份时,必须用文件方式备份controlfile。

==================

Report schema              Report shema是指在数据库中查找schema

List backup                   从control读取信息

Crosscheck backup       看一下backup的文件,检查controlfile中的目录或文件是否真正在磁盘上

Delete backupset 24      24代表backupset 的编号, 既delete目录,也delete你的文件

=====================

The purpose of the RMAN recovery catalog:
A recovery catalog is a database schema used by RMAN to store metadata about one or more Oracle databases. Typically, you store the catalog in a dedicated database. A recovery catalog provides the following benefits:
A recovery catalog creates redundancy for the RMAN repository stored in the control file of each target database. The recovery catalog serves as a secondary metadata repository. If the target control file and all backups are lost, then the RMAN metadata still exists in the recovery catalog.
A recovery catalog centralizes metadata for all your target databases. Storing the metadata in a single place makes reporting and administration tasks easier to perform.
A recovery catalog can store metadata history much longer than the control file. This capability is useful if you must do a recovery that goes further back in time
than the history in the control file. The added complexity of managing a recovery catalog database can be offset by the convenience of having the extended backup
history available.
Some RMAN features function only when you use a recovery catalog. For example, you can store RMAN scripts in a recovery catalog. The chief advantage of a stored script is that it is available to any RMAN client that can connect to the target database and recovery catalog. Command files are only available if the RMAN client has access to the file system on which they are stored.
A recovery catalog is required when you use RMAN in a Data Guard environment. By storing backup metadata for all primary and standby databases, the catalog enables you to offload backup tasks to one standby database while enabling you to restore backups on other databases in the environment.

======FROM=======

http://blog.csdn.net/tianlesoftware/article/details/5641763

[oracle数据库11G初学者指南].Oracle.Database.11g,.A.Beginner's.Guide

RMAN-使用catalog恢复目录进行备份与恢复的更多相关文章

  1. Oracle之catalog恢复目录的创建于维护(51CTO风哥rman课程)

    catalog恢复目录配置过程 1,创建一个表空间 2,创建rman用户并授权 3,创建恢复目录 4,配置TNS 5,注册数据库 6,检查 创建ramn表空间 首先查看一下其他表空间位置 create ...

  2. RMAN_学习笔记3_RMAN Catalog恢复目录

    2014-12-23 Created By BaoXinjian

  3. rman catalog (rman 恢复目录)

    受控制文件大小的限制,一般rman需要用rman catalog来管理及存放备份信息: 这里介绍一下创建rman catalog的步骤: C:\Documents andSettings\Admini ...

  4. OCP读书笔记(3) - 使用RMAN恢复目录

    创建恢复目录 在hndx上创建恢复目录:[oracle@oracle admin]$ export ORACLE_SID=hndx[oracle@oracle admin]$ sqlplus / as ...

  5. RMAN 还原与恢复

    一. RMAN 还原与恢复基础 在RMAN 用于中,还原与恢复是两个不同的概念.还原(restore):指访问先前生成的备份,从中得到一个或多个对象,然后在磁盘上的某个位置还原这些对象.恢复(reco ...

  6. RMAN恢复目录

    是否使用RMAN恢复目录(Recovery Catalog 你可能从其他人或书上听过RMAN恢复目录(也有可能是其他名字,RMAN Recovery Catalog的翻译较多较杂,以下简称恢复目录), ...

  7. RMAN_学习笔记5_RMAN Catalog Script恢复目录脚本

    2014-12-24 Created By BaoXinjian

  8. rman全库恢复到不同主机,不同实例名,不同目录下

    一.配置目标主机的ip.hostname及与源端主机的连通性 1.配置目标主机IP 使用图形界面配置IP: administration----network---修改IP(指定静态IP) deact ...

  9. Oracle DB 使用RMAN恢复目录

    • 对恢复目录和RMAN 资料档案库控制文件的使用进行比较• 创建和配置恢复目录• 在恢复目录中注册数据库• 同步恢复目录• 使用RMAN 存储脚本• 备份恢复目录• 创建虚拟专用目录 RMAN 资料 ...

随机推荐

  1. BZOJ 2079: [Poi2010]Guilds

    Description 问一个图是否有二染色方案,满足每个点都跟他颜色不用的点有连边. Sol 结论题. 除了只有一个点,否则任何图都能被二染色. Code /******************** ...

  2. 1.NoSql简介

    NoSQL,指的是非关系型的数据库.随着互联网web2.0网站的兴起,传统的关系数据库在应付web2.0网站,特别是超大规模和高并发的SNS类型的web2.0纯动态网站已经显得力不从心,暴露了很多难以 ...

  3. Javascript & JQuery读书笔记

    Hi All, 分享一下我学JS & JQuery的读书笔记: JS的3个不足:复杂的文档对象模型(DOM),不一致的浏览器的实现和便捷的开发,调试工具的缺乏. Jquery的选择器 a. 基 ...

  4. drool-6.5的自学demo

    先丢代码地址 https://gitee.com/a247292980/drools 再丢pom.xml <project xmlns="http://maven.apache.org ...

  5. python使用udp实现聊天器

    聊天器简易版 使用udp实现一个简单的聊天器程序,要求如下: 在一个电脑中编写1个程序,有2个功能 1.获取键盘数据,并将其发送给对方 2.接收数据并显示 并且功能数据进行选择以上的2个功能调用 例子 ...

  6. 对于链表中tada的绝对值相等的点,仅保留第一次出现的结点而删除其余绝对值相等的点

    算法的核心思想是用空间换时间,使用辅助数组记录链表中已出现的数值  从而只需对链表进行一趟扫描 typedef struct node { int data; struct node* next; } ...

  7. 对于python setup install的程序如何删除干净

    python很好用,尤其是用过easy_install的朋友更是觉得它的便捷,卸载命令也很简单 easy_install -m package-name但是面对源码安装的怎么办呢? setup.py ...

  8. java实验报告五

    一.实验内容 1.掌握Socket程序的编写: 2.掌握密码技术的使用: 3.设计安全传输系统. 二.实验基础: IP和端口:IP是用来标示计算机,而端口是用来标示某个计算机上面的特定应用.至于它们的 ...

  9. 天梯赛 L2-014 列车调度 (模拟)

    火车站的列车调度铁轨的结构如下图所示. Figure 两端分别是一条入口(Entrance)轨道和一条出口(Exit)轨道,它们之间有N条平行的轨道.每趟列车从入口可以选择任意一条轨道进入,最后从出口 ...

  10. APP开放接口API安全性——Token令牌Sign签名的设计与实现

    在APP开放接口API的设计中,避免不了的就是安全性问题. 一.https协议 对于一些敏感的API接口,需要使用https协议.https是在http超文本传输协议加入SSL层,它在网络间通信是加密 ...