rman之创建恢复目录笔记

晚上做了一下创建恢复目录的实验,整理了一下,供自己以后参考

环境:

源库:oracle10gr2 源OS:rhelas4 源sid=ora10 源库ip=192.168.1.200

目标库: oracle10gr2 目地OS:rhelas4 目的sid=ora10hha 目的库ip=192.168.1.10

实验目的:

要将源库192.168.1.200 上的数据文件、控制文件以及日志文件备份到 目的库192.168.1.10上,以便源库出现问题时,可以通过

备份目录恢复。

实验准备:

1:在虚拟机上安装好两个redhat系统,源库ip=192.168.1.200,目的库ip=192.168.1.10

并分别创建好两个库,一个ora10库 , 一个orahha库

同时关闭两个redhat系统上的防火墙,确保这两个OS都可以相互ping通

2:在目的库(192.168.1.10)上通过图形化界面执行netca命令,配置好监听,配置好的listener.ora 如下

ora10hha =

(DESCRIPTION_LIST =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.10)(PORT = 1521))

(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))

)

)

3:在源库(192.168.1.200)上通过图形化界面执行netca命令,配置好tnsname.ora ,配置好的内容如下:

ORA10HHA =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.10)(PORT = 1521))

)

(CONNECT_DATA =

(SERVICE_NAME = ora10hha)

)

)

4:在源库(192.168.1.200)上执行客户端到服务器端的连接是不是正常:

[oracle@sphost admin]$ tnsping ORA10HHA

TNS Ping Utility for Linux: Version 10.2.0.1.0 - Production on 03-MAY-2011 23:22:19

Copyright (c) 1997, 2005, Oracle. All rights reserved.

Used parameter files:

/home/oracle/10.2.0/network/admin/sqlnet.ora

Used TNSNAMES adapter to resolve the alias

Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.10)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = ora10hha)))

OK (80 msec)

[oracle@sphost admin]$

ok,这样就可以通过网络连接到目的库上了。

5:在源库(192.168.1.200)上执行

[oracle@sphost admin]$ sqlplus sys/sysdba@ORA10HHA as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Tue May 3 23:26:18 2011

Copyright (c) 1982, 2005, Oracle. All rights reserved.

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production

With the Partitioning, OLAP and Data Mining options

SQL>

6:在源库(192.168.1.200)上创建表空间,用于存放恢复目录数据,

并创建用户,该用户是恢复目录的拥有者;同时给用户授予查询、维护恢复目录的权限

SQL> create tablespace tbs_catalog datafile '/home/oracle/oradata/catalog.dbf' size 1G;

Tablespace created.

SQL> create user rman identified by rman temporary tablespace temp default tablespace tbs_catalog quota unlimited on tbs_catalog;

User created.

SQL> grant connect,resource,recovery_catalog_owner to rman;

Grant succeeded.

SQL>

7:启动rman

oracle@sphost admin]$rman

一定要注意:如果此处输入rman后,一直没有反应,那么就执行如下命令:

[oracle@sphost admin]$ export PATH=$ORACLE_HOME/binPATH:.

[oracle@sphost admin]$ rman

Recovery Manager: Release 10.2.0.1.0 - Production on Tue May 3 23:38:10 2011

Copyright (c) 1982, 2005, Oracle. All rights reserved.

RMAN>

8:以用户rman身份连接到恢复目录所在的数据库中

RMAN> connect catalog rman@ORA10HHA

recovery catalog database Password:

connected to recovery catalog database

RMAN>

当然,在这里我的恢复目录是已经创建好了的,如果还没有创建的话,在执行这条命令后,显示如下:

recovery catalog database Password:

connected to recovery catalog database

recovery catalog is not installed

9:因此要创建恢复目录

在这里一定要注意,创建的恢复目录名一定要和刚创建的表空间名字一直,否则无效。如下:

RMAN> connect catalog rman@ORA10HHA

recovery catalog database Password:

connected to recovery catalog database

RMAN> create catalog tablespace tt;

ORACLE error from recovery catalog database: ORA-00959: tablespace 'TT' does not exist

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-06433: error installing recovery catalog

RMAN> create catalog tablespace tbs_catalog;

recovery catalog created

RMAN> exit

10:测试恢复目录是否创建成功。

[oracle@sphost ~]$ sqlplus sys/sysdba@ORA10HHA as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Tue May 3 22:48:23 2011

Copyright (c) 1982, 2005, Oracle. All rights reserved.

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production

With the Partitioning, OLAP and Data Mining options

SQL> connect rman@ORA10HHA

Enter password:

Connected.

SQL> set linesize 2000;

SQL> select table_name from user_tables;

TABLE_NAME

------------------------------------------------------------

DB

NODE

CONF

DBINC

CKP

TS

TSATT

DF

DFATT

TF

TFATT

TABLE_NAME

------------------------------------------------------------

OFFR

RR

RT

ORL

RLH

AL

BS

BP

BCF

CCF

XCF

TABLE_NAME

------------------------------------------------------------

BSF

BDF

CDF

XDF

BRL

BCB

CCB

SCR

SCRL

CONFIG

XAL

TABLE_NAME

------------------------------------------------------------

RSR

FB

ROUT

RCVER

37 rows selected.

如果这些表不存在,则表示恢复目录没有创建成功。

11.将数据库注册到恢复目录

[oracle@catalog ~]$ rman

Recovery Manager: Release 10.2.0.1.0 - Production on Tue May 3 21:23:52 2011

Copyright (c) 1982, 2005, Oracle. All rights reserved.

RMAN> connect target ora10; ////连接到源库

target database Password:

connected to target database: ORA10HHA (DBID=3339398398)

RMAN> connect catalog rman@ORA10HHA ////连接到恢复目录,感觉这边随意输入任何密码都是可以的

recovery catalog database Password:

connected to recovery catalog database

RMAN> register database; /// 把源数据库的信息注册到恢复目录中

database registered in recovery catalog

starting full resync of recovery catalog

full resync complete

RMAN> exit

原文地址:https://www.cnblogs.com/weixun/p/3276487.html