Home  >  Article  >  Database  >  ORACLE 11g RMAN备份恢复

ORACLE 11g RMAN备份恢复

WBOY
WBOYOriginal
2016-06-07 15:24:34741browse

rman catalog是为数据备份恢复时,使用恢复目录catalog,与nocatalog的不同是,nocatalog将备份相关的信息记录在了控制文件中,而catalog将备份信息记录在了恢复目录中。 本文做的实验是将恢复目录创建在oracle 12c上,需要备份的数据库在oracle 11g上。 STE

rman catalog是为数据备份恢复时,使用恢复目录catalog,与nocatalog的不同是,nocatalog将备份相关的信息记录在了控制文件中,而catalog将备份信息记录在了恢复目录中。

本文做的实验是将恢复目录创建在oracle 12c上,需要备份的数据库在oracle 11g上。


STEP1:在恢复目录catalog数据库上创建专门用于恢复的的用户c##rman,并赋予相关的权限(oracle 12c创建用户前加c##, 可以参考http://blog.csdn.net/wenchu20/article/details/43196577)

--创建恢复目录的表空间
SQL> create tablespace TBS_RMAN datafile '/u01/app/oradata/rman1.dbf' size 5M autoextend on next 2M;

Tablespace created.

--创建用户
SQL> create user c##rman identified by rman default tablespace tbs_rman temporary tablespace TEMP;

User created.

--对用户rman赋权
SQL> grant connect,resource,recovery_catalog_owner to rman;

Grant succeeded.

创建用户后,用rman登录PL/SQL,由于没有对rman用户赋予任何对象权限,所以没有任何对象

ORACLE 11g RMAN备份恢复


STEP2:连接rman的target 和catalog

[oracle@REDHAT6 ~]$ rman target sys/oracle  catalog rman/rman
-- 或者使用下面的方式登录
[oracle@REDHAT6 ~]$ rman 

Recovery Manager: Release 11.2.0.3.0 - Production on Wed Jan 28 00:27:14 2015

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

RMAN> connect target sys/oracle;

connected to target database: ORCL (DBID=1396675707)

RMAN> connect catalog rman/rman;

connected to recovery catalog database

RMAN> 

STEP3:创建恢复目录,在恢复目录下面会自动创建相关的对象
RMAN> create catalog tablespace TBS_RMAN;

recovery catalog created


执行上述命令后,就会看到 rman用户下面多了许多对象(table, view等)
ORACLE 11g RMAN备份恢复


STEP4:恢复目录已经创建了, 需要将 target 和 catalog关联起来,即注册服务器(注册服务器之前 DB表是空的,注册后DB表中有数据)

RMAN> register database;

database registered in recovery catalog
starting full resync of recovery catalog
full resync complete

注册完毕后,可以看看相关表中有数据了,下图是db表中的数据
SQL> select * from db;

    DB_KEY	DB_ID CURR_DBINC_KEY
---------- ---------- --------------
	 1 1396675707		   2


OK, catalog恢复目录已经创建完毕


本实验,如果数据库shutdown(或数据库处于nomount, mount状态),都将不能查看备份相关的信息,因为恢复目录catalog与目标库target在同一个实例上,数据库没有打开,所以无法获取相关的信息。

如果有两台机器,target是一台机器,catalog是一台机器,target目标库停掉,也能连接catalog 。





Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn