恢复目录:
复制控制文件数据,与控制文件相比可以存储更多的历史信息
存储更长的备份历史
服务与多个目标
存储RMAN脚本
可为所有已注册目标创建自定义报告
可以使用BACKUP命令的KEEP FOREVER子句
可以列出在给定时间位于或曾经位于目标数据库中的数据文件和表空间
配置恢复目录数据库:
创建恢复目录所用的表空间,这将称为恢复目录所有者的默认表空间。
创建恢复目录所有者,授予RECOVERY_CATALOG_OWNER。
以目录所有者的身份连接恢复目录,并执行CREATE CATALOG命令。
在恢复目录中注册目标数据库。
将其他备份文件列入目录CATALOG BACKUPPIECE ' ' 。
可在下列情况下手动重新同步恢复目录:RESYNC CATALOG
RMAN自动重新同步恢复目录时恢复目录不可用。
对目标数据库执行不常执行的备份时。
对目标数据库的物理结构进行更改后。
使用RMAN存储脚本:
CREATE SCRIPT script_name {<RMAN commands>}
存储脚本是:
命令文件的替代方式。
供可连接到目标数据库和恢复目录的任意RMAN客户机使用。
分为本地与全局两种类型。
可从文本文件中创建CREATE [GLOBAL] SCRIPT __ FROM FILE '__'
升级和删除恢复目录:
UPGRADE CATALOG;
复制控制文件数据,与控制文件相比可以存储更多的历史信息
存储更长的备份历史
服务与多个目标
存储RMAN脚本
可为所有已注册目标创建自定义报告
可以使用BACKUP命令的KEEP FOREVER子句
可以列出在给定时间位于或曾经位于目标数据库中的数据文件和表空间
配置恢复目录数据库:
创建恢复目录所用的表空间,这将称为恢复目录所有者的默认表空间。
创建恢复目录所有者,授予RECOVERY_CATALOG_OWNER。
以目录所有者的身份连接恢复目录,并执行CREATE CATALOG命令。
在恢复目录中注册目标数据库。
将其他备份文件列入目录CATALOG BACKUPPIECE ' ' 。
可在下列情况下手动重新同步恢复目录:RESYNC CATALOG
RMAN自动重新同步恢复目录时恢复目录不可用。
对目标数据库执行不常执行的备份时。
对目标数据库的物理结构进行更改后。
使用RMAN存储脚本:
CREATE SCRIPT script_name {<RMAN commands>}
存储脚本是:
命令文件的替代方式。
供可连接到目标数据库和恢复目录的任意RMAN客户机使用。
分为本地与全局两种类型。
可从文本文件中创建CREATE [GLOBAL] SCRIPT __ FROM FILE '__'
升级和删除恢复目录:
UPGRADE CATALOG;
DROP CATALOG;
--实验
RMAN> list backup; --查看备份文件
using target database control file instead of recovery catalog
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
40 Full 755.52M DISK 00:05:43 22-NOV-16
BP Key: 40 Status: AVAILABLE Compressed: YES Tag: TAG20161122T205913
Piece Name: /u01/app/oracle/fast_recovery_area/PROD1/backupset/2016_11_22/o1_mf_nnndf_TAG20161122T205913_d38j91rf_.bkp
List of Datafiles in backup set 40
--先重建控制文件
SYS@PROD1> alter database backup controlfile to trace as '/tmp/a.sql' reuse;--删除脚本中#2后的所有内容
Database altered.
SYS@PROD1> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS@PROD1> start /tmp/a.sql
ORACLE instance started.
Total System Global Area 732352512 bytes
Fixed Size 1347456 bytes
Variable Size 335544448 bytes
Database Buffers 394264576 bytes
Redo Buffers 1196032 bytes
Control file created.
PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.
ORA-00283: recovery session canceled due to errors
ORA-00264: no recovery required
System altered.
Database altered.
Tablespace altered.
Tablespace altered.
[oracle@ocm1 ~]$ rman target / --再进RMAN查看备份信息
Recovery Manager: Release 11.2.0.3.0 - Production on Sun Dec 11 19:44:02 2016
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: PROD1 (DBID=2133791648)
RMAN> list backup; --发现备份信息全部消失
using target database control file instead of recovery catalog
specification does not match any backup in the repository
--控制文件一丢失备份信息就会丢失
--创建恢复目录
SYS@PROD1> create tablespace catadb datafile '/u01/app/oracle/oradata/PROD1/catadb.dbf' size 10m autoextend on;
Tablespace created.
SYS@PROD1> create user catauser identified by oracle default tablespace catadb;
User created.
SYS@PROD1> grant resource,connect,recovery_catalog_owner to catauser;
Grant succeeded.
RMAN> create catalog;
recovery catalog created
RMAN> exit
Recovery Manager complete.
[oracle@ocm1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Sun Dec 11 19:50:23 2016
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SYS@PROD1> conn catauser/oracle
Connected.
CATAUSER@PROD1> select count(*) from tab; --存储大量数据
COUNT(*)
----------
174
RMAN> register database; --注册目标数据库
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
RMAN> backup spfile;
Starting backup at 11-DEC-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=42 device type=DISK
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 11-DEC-16
channel ORA_DISK_1: finished piece 1 at 11-DEC-16
piece handle=/u01/app/oracle/fast_recovery_area/PROD1/backupset/2016_12_11/o1_mf_nnsnf_TAG20161211T195133_d4thg5xr_.bkp tag=TAG20161211T195133 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 11-DEC-16
Starting Control File and SPFILE Autobackup at 11-DEC-16
piece handle=/u01/app/oracle/fast_recovery_area/PROD1/autobackup/2016_12_11/o1_mf_s_930340295_d4thg88m_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 11-DEC-16
[oracle@ocm1 ~]$ rman target sys/oracle@prod2 catalog catauser/oracle --连接远程数据库
Recovery Manager: Release 11.2.0.3.0 - Production on Sun Dec 11 19:52:42 2016
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database (not started)
connected to recovery catalog database
RMAN> register database;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of register command at 12/11/2016 19:52:48
RMAN-06403: could not obtain a fully authorized session
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux Error: 2: No such file or directory
RMAN> startup
Oracle instance started
database mounted
database opened
Total System Global Area 958341120 bytes
Fixed Size 1348972 bytes
Variable Size 322964116 bytes
Database Buffers 629145600 bytes
Redo Buffers 4882432 bytes
RMAN> register database; --注册远程数据库
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
RMAN> backup spfile;
Starting backup at 11-DEC-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=54 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 11-DEC-16
channel ORA_DISK_1: finished piece 1 at 11-DEC-16
piece handle=/u01/app/oracle/fast_recovery_area/PROD2/backupset/2016_12_11/o1_mf_nnsnf_TAG20161211T195337_d4thl2bm_.bkp tag=TAG20161211T195337 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 11-DEC-16
--创建脚本
RMAN> create script backup_spfile {
2> backup spfile;
3> }
created script backup_spfile
RMAN> run { exec script backup_spfile; }
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "identifier": expecting one of: "advise, allocate, alter, backup, @, catalog, change, configure, convert, copy, crosscheck, delete, duplicate, execute, flashback, host, mount, open, recover, release, repair, report, restore, resync, send, set, show, shutdown, sql, startup, switch, transport, validate, "
RMAN-01008: the bad identifier was: exec
RMAN-01007: at line 1 column 7 file: standard input
RMAN> run { execute script backup_spfile; }
executing script: backup_spfile
Starting backup at 11-DEC-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=30 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 11-DEC-16
channel ORA_DISK_1: finished piece 1 at 11-DEC-16
piece handle=/u01/app/oracle/fast_recovery_area/PROD3/backupset/2016_12_11/o1_mf_nnsnf_TAG20161211T203636_d4tl2o9l_.bkp tag=TAG20161211T203636 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 11-DEC-16
RMAN> list script names;
List of Stored Scripts in Recovery Catalog
Scripts of Target Database PROD3 --该脚本只能在PROD3中使用
Script Name
Description
-----------------------------------------------------------------------
backup_spfile
RMAN> print script backup_spfile; --打印脚本
printing stored script: backup_spfile
{
backup spfile;
}
RMAN> delete script backup_spfile; --删除脚本
deleted script: backup_spfile
RMAN> create global script backup_spfile { --创建全局脚本
2> backup spfile;
3> }
created global script backup_spfile
RMAN> list script names;
List of Stored Scripts in Recovery Catalog
Global Scripts
Script Name
Description
-----------------------------------------------------------------------
backup_spfile