概述
一.Nocatalog
Nocatalog方式 就是用control file作为catalog,每一次备份都要往控制文件里面写好多备份信息,控制文件里面会有越来越多的备份信息。因此,当使用rman nocatalog方式备份时,备份controlfile是非常重要的。
由于nocatalog时利用controlfile存放备份信息,建议将Oracle参数文件中的CONTROL_FILE_RECORD_KEEP_TIME值加大(缺省为7天), 参数在$ORACLE_HOME/dbs/initSID.ora中,该参数control_file__record_keep_time设置备份信息保存时间,到规定时间就自动清除以前的备份信息。
SQL> show parameter control
NAME
TYPE
VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time
integer
7
control_files
string
/data/incadg/control01.ctl, /d
ata/incadg/control02.ctl
control_management_pack_access
string
DIAGNOSTIC+TUNING
SQL>
二.Catalog
Catalog 则必须要首先要创建目录备份数据库,建立恢复目录。示例如下:
1.创建Catalog所需要的表空间
SQL>create tablespace rman_ts datafile '/data/rmants.dbf' size 2048M;
2.创建RMAN用户并授权
SQL>create user rman identified by rman default tablespace rman_ts quota unlimited on rman_ts;
SQL>grant recovery_catalog_owner to rman;(grant connect to rman)
查看角色所拥有的权限: select * from dba_sys_privs where grantee='RECOVERY_CATALOG_OWNER';
(RECOVER_CATALOG_OWNER,CONNECT,RESOURCE)
3.创建恢复目录
oracle>rman catalog rman/rman
RMAN>create catalog tablespace rman_ts;
RMAN>register database;(database是target database)
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
RMAN> connect target /;
以后要使用备份和恢复,需要连接到两个数据库中,命令:
oracle>rman target / catalog rman/rman (第一斜杠表示target数据库,catalog表示catalog目录 rman/rman表示catalog用户名和密码)
命令执行后显示:
Recovery Manager: Release 11.2.0.4.0 - Production on Thu Sep 27 13:36:44 2018
Copyright (c) 1982, 2013, Oracle. All rights reserved.
connected to target database: ORCL (DBID=1337382238)
connected to recovery catalog database
命令解释:
Report schema Report shema是指在数据库中需找schema
List backup 从control读取信息
Crosscheck backup 看一下backup的文件,检查controlfile中的目录或文件是否真正在磁盘上
Delete backupset 9 9代表backupset 的编号, 既delete目录,也delete你的文件
注意,当使用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。
三.catalog命令使用
在9i时代,如果在控制文件或者catalog数据库中的备份信息被覆盖或者清除,那么即使所有的备份文件都在,rman也无法简单的利用这些文件来做恢复了,必须得用些特别的方法才能办到,比如以前很多牛人写的使用dbms_backup_restore包从备份片中释放出数据文件,然后再使用手工方式做恢复。但是实际上,oracle完全可以将恢复时需要的一些信息保存在备份文件的文件头中,如果控制文件或者catalog数据库中的信息丢失,再扫描一遍文件头,取出这些信息就可以了。10g中就是这么实现的,扫描这些文件头的工作就是由这个新的catalog命令来实现的。注意这是10g rman的一个命令,虽然和以前的catalog database的名字长得一样,可不是同一个东西。catalog命令可以用来扫描备份片,文件拷贝(datafile or controlfile copy),也可以用来扫描归档日志,所以,只要你的备份还在,归档还在,即使catalog database崩溃,控制文件重建,照样可以用这些备份来做恢复。Oracle11g丰富了catalog命令,使用这个命令,可以将RMAN的备份集注册到控制文件(或者目录数据库中)
类似的一系列命令有:
#扫描归档日志
CATALOG ARCHIVELOG '/data/arch/1_1174_968856606.arc', '/data/arch/1_1175_968856606.arc', '/data/arch/1_1176_968856606.arc';
#扫描数据文件拷贝,并且将其做为增量备份的level 0
CATALOG DATAFILECOPY '/data/rman/INCA_4_1_20180925.bak' LEVEL 0;
#扫描整个目录,如果备份片或者归档日志文件太多,可以放到一个目录中,一次性扫描就行
CATALOG START WITH '/data/rman/';
#扫描闪回恢复区
CATALOG RECOVERY AREA NOPROMPT;
#扫描备份片
CATALOG BACKUPPIECE '/data/rman/INCA_13_1_20180925.bcp';
#扫描控制文件拷贝
CATALOG CONTROLFILECOPY 'controlfilecopy.ctl';
这里需要注意将备份的log和备份文件一起保存下来,不然就不知道哪些文件属于哪个备份集,恢复的时候就要多浪费些时间啦。 但是注意这些命令是有限制的,其中的一个限制是不能注册备份文件到不同的数据库:
You cannot use CATALOG to catalog a file that belongs to a different database.
也就是说你至少还需要原数据库的控制文件。
否则就会出现类似如下的错误:
[oracle@standby ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Thu Sep 27 13:36:44 2018
Copyright (c) 1982, 2013, Oracle.
All rights reserved.
connected to target database (not started)
RMAN> set dbid=1337382238
executing command: SET DBID
RMAN> startup mount;
Oracle instance started
database mounted
Total System Global Area
285212672 bytes
Fixed Size
1218992 bytes
Variable Size
92276304 bytes
Database Buffers
188743680 bytes
Redo Buffers
2973696 bytes
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of startup command at 09/27/2018 13:36:48
RMAN-06189: current DBID 1337382238 does not match target mounted database (101694595)
是否没有办法呢?当然是有的,我们可以先修改一个恢复数据库的DBID,然后再来注册这个备份集。
修改DBID可以使用之前我曾经写过的,Oracle10g 的 dbms_backup_restore 包。
修改之后就可以用来注册了,看看我注册一个种子数据库备份集的过程:
[oracle@cerp01 rman]$ rman target /
恢复管理器: Release 11.2.0.4.0 - Production on 星期三 9月 27 22:25:34 2018
Copyright (c) 1982, 2011, Oracle.
All rights reserved.
已连接到目标数据库 (未启动)
RMAN> startup mount;
Oracle 实例已启动
数据库已装载
系统全局区域总计
251658240 字节
Fixed Size
1289988 字节
Variable Size
171966716 字节
Database Buffers
75497472 字节
Redo Buffers
2904064 字节
RMAN> catalog start with '/data/rman';
使用目标数据库控制文件替代恢复目录
搜索与样式 /data/rman 匹配的所有文件
数据库未知文件的列表
=====================================
文件名: /data/rman/INCA_4_1_20180925.bak
文件名: /data/rman/INCA_4_2_20180925.bak
是否确实要将上述文件列入目录 (输入 YES 或 NO)? YES
正在编制文件目录...
目录编制完毕
已列入目录的文件的列表
=======================
文件名: /data/rman/INCA_4_1_20180925.bak
未列入目录的文件的列表
=======================================
文件名: /data/rman/INCA_4_2_20180925.bak
RMAN-07518: 原因: 外部数据库文件 DBID: 1052376487
数据库名: orcl
RMAN> list backup
2> ;
using target database control file instead of recovery catalog
List of Backup Sets
===================
BS Key
Size
------- ----------
1
571.92M
List of Archived Logs in backup set 1
Thrd Seq
Low SCN
Low Time
Next SCN
Next Time
---- ------- ---------- --------- ---------- ---------
1
1171
10351463167409 23-SEP-18 10351463394057 25-SEP-18
1
1172
10351463394057 25-SEP-18 10351463440057 25-SEP-18
1
1173
10351463440057 25-SEP-18 10351463440067 25-SEP-18
Backup Set Copy #1 of backup set 1
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK
00:00:10
25-SEP-18
NO
TAG20180925T102557
List of Backup Pieces for backup set 1 Copy #1
BP Key
Pc# Status
Piece Name
------- --- ----------- ----------
1
1
AVAILABLE
/backup/cerptraindb/rman/INCA_2_1_20180925.arc
Backup Set Copy #2 of backup set 1
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK
00:00:10
25-SEP-18
NO
TAG20180925T102557
List of Backup Pieces for backup set 1 Copy #2
BP Key
Pc# Status
Piece Name
------- --- ----------- ----------
29
1
AVAILABLE
/data/rman/INCA_2_1_20180925.arc
BS Key
Type LV Size
------- ---- -- ----------
2
Full
9.64M
SPFILE Included: Modification time: 24-SEP-18
SPFILE db_unique_name: INCA
Control File Included: Ckp SCN: 10351463440105
Ckp time: 25-SEP-18
Backup Set Copy #1 of backup set 2
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK
00:00:01
25-SEP-18
NO
TAG20180925T102613
List of Backup Pieces for backup set 2 Copy #1
BP Key
Pc# Status
Piece Name
------- --- ----------- ----------
2
1
AVAILABLE
/backup/cerptraindb/rman/INCA_3_1_20180925.ctl
Backup Set Copy #2 of backup set 2
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK
00:00:01
25-SEP-18
NO
TAG20180925T102613
List of Backup Pieces for backup set 2 Copy #2
BP Key
Pc# Status
Piece Name
------- --- ----------- ----------
31
1
AVAILABLE
/data/rman/INCA_3_1_20180925.ctl
BS Key
Type LV Size
------- ---- -- ----------
3
Full
25.77G
List of Datafiles in backup set 3
File LV Type Ckp SCN
Ckp Time
Name
---- -- ---- ---------- --------- ----
5
Full 10351463440514 25-SEP-18 /data/incadg/tasly20180102_01.dbf
13
Full 10351463440514 25-SEP-18 /data/incadg/tasly20180123_index_02.dbf
Backup Set Copy #1 of backup set 3
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK
00:20:13
25-SEP-18
NO
TAG20180925T103148
List of Backup Pieces for backup set 3 Copy #1
BP Key
Pc# Status
Piece Name
------- --- ----------- ----------
3
1
AVAILABLE
/backup/cerptraindb/rman/INCA_6_1_20180925.bak
4
2
AVAILABLE
/backup/cerptraindb/rman/INCA_6_2_20180925.bak
Backup Set Copy #2 of backup set 3
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK
00:20:13
25-SEP-18
NO
TAG20180925T103148
List of Backup Pieces for backup set 3 Copy #2
BP Key
Pc# Status
Piece Name
------- --- ----------- ----------
30
1
AVAILABLE
/data/rman/INCA_6_1_20180925.bak
21
2
AVAILABLE
/data/rman/INCA_6_2_20180925.bak
BS Key
Type LV Size
------- ---- -- ----------
4
Full
9.61M
Control File Included: Ckp SCN: 10351463442506
Ckp time: 25-SEP-18
Backup Set Copy #1 of backup set 4
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK
00:00:03
25-SEP-18
NO
TAG20180925T103148
List of Backup Pieces for backup set 4 Copy #1
BP Key
Pc# Status
Piece Name
------- --- ----------- ----------
5
1
AVAILABLE
/backup/cerptraindb/rman/INCA_8_1_20180925.bak
Backup Set Copy #2 of backup set 4
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK
00:00:03
25-SEP-18
NO
TAG20180925T103148
List of Backup Pieces for backup set 4 Copy #2
BP Key
Pc# Status
Piece Name
------- --- ----------- ----------
32
1
AVAILABLE
/data/rman/INCA_8_1_20180925.bak
BS Key
Type LV Size
------- ---- -- ----------
5
Full
80.00K
SPFILE Included: Modification time: 24-SEP-18
SPFILE db_unique_name: INCA
Backup Set Copy #1 of backup set 5
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK
00:00:01
25-SEP-18
NO
TAG20180925T103148
List of Backup Pieces for backup set 5 Copy #1
BP Key
Pc# Status
Piece Name
------- --- ----------- ----------
6
1
AVAILABLE
/backup/cerptraindb/rman/INCA_9_1_20180925.bak
Backup Set Copy #2 of backup set 5
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK
00:00:01
25-SEP-18
NO
TAG20180925T103148
List of Backup Pieces for backup set 5 Copy #2
BP Key
Pc# Status
Piece Name
------- --- ----------- ----------
37
1
AVAILABLE
/data/rman/INCA_9_1_20180925.bak
BS Key
Type LV Size
------- ---- -- ----------
6
Full
31.42G
List of Datafiles in backup set 6
File LV Type Ckp SCN
Ckp Time
Name
---- -- ---- ---------- --------- ----
3
Full 10351463440515 25-SEP-18 /data/incadg/undotbs01.dbf
4
Full 10351463440515 25-SEP-18 /data/incadg/users01.dbf
8
Full 10351463440515 25-SEP-18 /data/incadg/cerpzs.dbf
10
Full 10351463440515 25-SEP-18 /data/incadg/tasly20180123_01.dbf
Backup Set Copy #1 of backup set 6
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK
00:24:04
25-SEP-18
NO
TAG20180925T103148
List of Backup Pieces for backup set 6 Copy #1
BP Key
Pc# Status
Piece Name
------- --- ----------- ----------
7
1
AVAILABLE
/backup/cerptraindb/rman/INCA_7_1_20180925.bak
8
2
AVAILABLE
/backup/cerptraindb/rman/INCA_7_2_20180925.bak
Backup Set Copy #2 of backup set 6
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK
00:24:04
25-SEP-18
NO
TAG20180925T103148
List of Backup Pieces for backup set 6 Copy #2
BP Key
Pc# Status
Piece Name
------- --- ----------- ----------
26
1
AVAILABLE
/data/rman/INCA_7_1_20180925.bak
25
2
AVAILABLE
/data/rman/INCA_7_2_20180925.bak
BS Key
Type LV Size
------- ---- -- ----------
7
Full
59.33G
List of Datafiles in backup set 7
File LV Type Ckp SCN
Ckp Time
Name
---- -- ---- ---------- --------- ----
2
Full 10351463440513 25-SEP-18 /data/incadg/sysaux01.dbf
7
Full 10351463440513 25-SEP-18 /data/incadg/tasly20180102_index_01.dbf
9
Full 10351463440513 25-SEP-18 /data/incadg/cerpzs_index.dbf
11
Full 10351463440513 25-SEP-18 /data/incadg/tasly20180123_02.dbf
Backup Set Copy #1 of backup set 7
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK
00:35:11
25-SEP-18
NO
TAG20180925T103148
List of Backup Pieces for backup set 7 Copy #1
BP Key
Pc# Status
Piece Name
------- --- ----------- ----------
9
1
AVAILABLE
/backup/cerptraindb/rman/INCA_5_1_20180925.bak
10
2
AVAILABLE
/backup/cerptraindb/rman/INCA_5_2_20180925.bak
11
3
AVAILABLE
/backup/cerptraindb/rman/INCA_5_3_20180925.bak
Backup Set Copy #2 of backup set 7
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK
00:35:11
25-SEP-18
NO
TAG20180925T103148
List of Backup Pieces for backup set 7 Copy #2
BP Key
Pc# Status
Piece Name
------- --- ----------- ----------
28
1
AVAILABLE
/data/rman/INCA_5_1_20180925.bak
34
2
AVAILABLE
/data/rman/INCA_5_2_20180925.bak
23
3
AVAILABLE
/data/rman/INCA_5_3_20180925.bak
BS Key
Type LV Size
------- ---- -- ----------
8
Full
63.78G
List of Datafiles in backup set 8
File LV Type Ckp SCN
Ckp Time
Name
---- -- ---- ---------- --------- ----
1
Full 10351463440512 25-SEP-18 /data/incadg/system01.dbf
6
Full 10351463440512 25-SEP-18 /data/incadg/tasly20180102_02.dbf
12
Full 10351463440512 25-SEP-18 /data/incadg/tasly20180123_index_01.dbf
Backup Set Copy #1 of backup set 8
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK
00:36:21
25-SEP-18
NO
TAG20180925T103148
List of Backup Pieces for backup set 8 Copy #1
BP Key
Pc# Status
Piece Name
------- --- ----------- ----------
12
1
AVAILABLE
/backup/cerptraindb/rman/INCA_4_1_20180925.bak
13
2
AVAILABLE
/backup/cerptraindb/rman/INCA_4_2_20180925.bak
14
3
AVAILABLE
/backup/cerptraindb/rman/INCA_4_3_20180925.bak
15
4
AVAILABLE
/backup/cerptraindb/rman/INCA_4_4_20180925.bak
Backup Set Copy #2 of backup set 8
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK
00:36:21
25-SEP-18
NO
TAG20180925T103148
List of Backup Pieces for backup set 8 Copy #2
BP Key
Pc# Status
Piece Name
------- --- ----------- ----------
27
1
AVAILABLE
/data/rman/INCA_4_1_20180925.bak
24
2
AVAILABLE
/data/rman/INCA_4_2_20180925.bak
20
3
AVAILABLE
/data/rman/INCA_4_3_20180925.bak
36
4
AVAILABLE
/data/rman/INCA_4_4_20180925.bak
BS Key
Size
------- ----------
9
2.00K
List of Archived Logs in backup set 9
Thrd Seq
Low SCN
Low Time
Next SCN
Next Time
---- ------- ---------- --------- ---------- ---------
1
1175
10351463444143 25-SEP-18 10351463444151 25-SEP-18
Backup Set Copy #1 of backup set 9
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK
00:00:00
25-SEP-18
NO
TAG20180925T110819
List of Backup Pieces for backup set 9 Copy #1
BP Key
Pc# Status
Piece Name
------- --- ----------- ----------
16
1
AVAILABLE
/backup/cerptraindb/rman/INCA_11_1_20180925.arc
Backup Set Copy #2 of backup set 9
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK
00:00:00
25-SEP-18
NO
TAG20180925T110819
List of Backup Pieces for backup set 9 Copy #2
BP Key
Pc# Status
Piece Name
------- --- ----------- ----------
22
1
AVAILABLE
/data/rman/INCA_11_1_20180925.arc
BS Key
Size
------- ----------
10
7.22M
List of Archived Logs in backup set 10
Thrd Seq
Low SCN
Low Time
Next SCN
Next Time
---- ------- ---------- --------- ---------- ---------
1
1174
10351463440067 25-SEP-18 10351463444143 25-SEP-18
Backup Set Copy #1 of backup set 10
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK
00:00:00
25-SEP-18
NO
TAG20180925T110819
List of Backup Pieces for backup set 10 Copy #1
BP Key
Pc# Status
Piece Name
------- --- ----------- ----------
17
1
AVAILABLE
/backup/cerptraindb/rman/INCA_10_1_20180925.arc
Backup Set Copy #2 of backup set 10
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK
00:00:00
25-SEP-18
NO
TAG20180925T110819
List of Backup Pieces for backup set 10 Copy #2
BP Key
Pc# Status
Piece Name
------- --- ----------- ----------
35
1
AVAILABLE
/data/rman/INCA_10_1_20180925.arc
BS Key
Type LV Size
------- ---- -- ----------
11
Full
80.00K
SPFILE Included: Modification time: 24-SEP-18
SPFILE db_unique_name: INCA
Backup Set Copy #1 of backup set 11
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK
00:00:00
25-SEP-18
NO
TAG20180925T110820
List of Backup Pieces for backup set 11 Copy #1
BP Key
Pc# Status
Piece Name
------- --- ----------- ----------
18
1
AVAILABLE
/backup/cerptraindb/rman/INCA_13_1_20180925.ctl
Backup Set Copy #2 of backup set 11
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK
00:00:00
25-SEP-18
NO
TAG20180925T110820
List of Backup Pieces for backup set 11 Copy #2
BP Key
Pc# Status
Piece Name
------- --- ----------- ----------
33
1
AVAILABLE
/data/rman/INCA_13_1_20180925.ctl
BS Key
Type LV Size
------- ---- -- ----------
12
Full
9.61M
Control File Included: Ckp SCN: 10351463444196
Ckp time: 25-SEP-18
Backup Set Copy #1 of backup set 12
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK
00:00:02
25-SEP-18
NO
TAG20180925T110820
List of Backup Pieces for backup set 12 Copy #1
BP Key
Pc# Status
Piece Name
------- --- ----------- ----------
19
1
AVAILABLE
/backup/cerptraindb/rman/INCA_12_1_20180925.ctl
Backup Set Copy #2 of backup set 12
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK
00:00:02
25-SEP-18
NO
TAG20180925T110820
List of Backup Pieces for backup set 12 Copy #2
BP Key
Pc# Status
Piece Name
------- --- ----------- ----------
38
1
AVAILABLE
/data/rman/INCA_12_1_20180925.ctl
RMAN>
最后
以上就是粗暴棒棒糖为你收集整理的RMAN Catalog 和 Nocatalog的说明的全部内容,希望文章能够帮你解决RMAN Catalog 和 Nocatalog的说明所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复