RMAN用来存放数据库元数据的schema。
the catalog includes the following types of metadata:
-Data file and archived redo log backup sets and backup pieces
-Data file copies
-Archived redo logs and their copies
-Database structure (tablespaces and datafiles)
-Stored scripts, which are named user-created sequences of RMAN commands
-Persistent RMAN configuration settings
创建Recovery Catalog
1.配置Recovery Catalog数据库
2.创建Recovery Catalog的属主
不可以让sys用户成为Recovery Catalog的属主。
SQL> create user rman identified by password temporary tablespace temp default tablespace tools quota unlimited on tools; SQL> grant recovery_catalog_owner to rman;
3.执行create catalog命令
从rman客户端登陆到catalog所在的数据库
RMAN> connect catalog rman/[email protected] RMAN> create catalog tablespace cat_tbs;
验证一下:
SQL> select table_name from user_tables;
注册数据库到Recovery Catalog
$ rman target / catalog rman/[email protected] Recovery Manager: Release 11.2.0.4.0 - Production on Mon Sep 21 09:10:48 2015 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. connected to target database: DB11 (DBID=1422808181) connected to recovery catalog database RMAN> register database; database registered in recovery catalog starting full resync of recovery catalog full resync complete RMAN> report schema; Report of database schema for database with db_unique_name DB11 List of Permanent Datafiles =========================== File Size(MB) Tablespace RB segs Datafile Name ---- -------- -------------------- ------- ------------------------ 1 750 SYSTEM YES /u11/app/oracle/oradata/db11/system01.dbf 2 520 SYSAUX NO /u11/app/oracle/oradata/db11/sysaux01.dbf 3 110 UNDOTBS1 YES /u11/app/oracle/oradata/db11/undotbs01.dbf 4 5 USERS NO /u11/app/oracle/oradata/db11/users01.dbf 5 313 EXAMPLE NO /u11/app/oracle/oradata/db11/example01.dbf List of Temporary Files ======================= File Size(MB) Tablespace Maxsize(MB) Tempfile Name ---- -------- -------------------- ----------- -------------------- 1 29 TEMP 32767 /u11/app/oracle/oradata/db11/temp01.dbf
向Recovery Catalog中注册备份集
RMAN> catalog datafilecopy ‘/disk1/old_datafiles/01_01_2003/users01.dbf‘; RMAN> catalog archivelog ‘/disk1/arch_logs/archive1_731.dbf‘, ‘/disk1/arch_logs/archive1_732.dbf‘; RMAN> catalog backuppiece ‘/disk1/backups/backup_820.bkp‘;
也可以将备份文件放到一个目录下,将整个目录注册进去:
RMAN> catalog start with ‘/disk1/backups/‘;
下面两个语法是不同的:
RMAN> CATALOG START WITH ‘/disk1/backups‘; #任何以backups开头的目录都被注册进去 RMAN> CATALOG START WITH ‘/disk1/backups/‘; #只是注册backups目录
创建和管理Virtual Private Catalogs
recovery catalog的拥有者是catowner
注册的数据库有:prod1、prod2、prod3
创建数据库用户vpc1,并被授予访问prod1、prod2
1.创建数据库用户(VPC的拥有者)并授权
登陆到recovery catalog所在的数据库 SQL> create user vpc1 identified by vpc1 default tablespace vpcusers quota unlimited on vpcusers; SQL> grant recovery_catalog_owner to vpc1; SQL> exit; 以base recovery catalog用户身份rman登陆到recovery catalog所在的数据库 $ rman RMAN> connect catalog [email protected]; RMAN> grant catalog for database prod1 to vpc1; RMAN> grant catalog for database prod2 to vpc1; RMAN> grant register database to vpc1;
2.创建VPC
$ rman RMAN> connect catalog [email protected]; RMAN> create virtual catalog;
3.收回Virtual Private Catalog Owner的权限
以base recovery catalog用户身份rman登陆到recovery catalog所在的数据库 $ rman RMAN> connect catalog [email protected]; RMAN> revoke catalog for database prod1 from vpc1; RMAN> revoke register database from vpc1;
4.删除Virtual Private Catalog
$ rman RMAN> connect catalog [email protected]; RMAN> drop catalog;
Stored Scripts
Stored Scripts有两种:本地的、全局的
创建Stored Scripts
本地stored scripts:
RMAN> create script full_backup{ backup database plus archivelog; delete obsolete; }
全局stored scripts:
RMAN> create global script global_full_backup comment ‘use only with archivelog mode databases‘ { backup database plus archivelog; delete obsolete; }
从其他文件读取创建stored scripts:
RMAN> create script full_backup from file ‘/tmp/my_script_file.txt‘;
更新stored scripts
使用关键字replace:
RMAN> replace script full_backup { backup database plus archivelog; }
运行stored scripts
RMAN> run { execute global script global_full_backup; } RMAN> run { execute script full_backup; }
打印stored scripts
使用关键字print scripts
RMAN> print script full_backup;